Spaces:
Sleeping
Sleeping
separate the llms
Browse files- utils/haystack.py +5 -3
utils/haystack.py
CHANGED
@@ -33,6 +33,8 @@ def start_haystack(huggingface_token):
|
|
33 |
llm.warm_up()
|
34 |
# start_keyword_pipeline(llm)
|
35 |
# start_qa_pipeline(llm)
|
|
|
|
|
36 |
keyword_prompt_template = """
|
37 |
Your task is to convert the follwing question into 3 keywords that can be used to find relevant medical research papers on PubMed.
|
38 |
Here is an examples:
|
@@ -65,10 +67,10 @@ Articles:
|
|
65 |
pipe = Pipeline()
|
66 |
|
67 |
pipe.add_component("keyword_prompt_builder", keyword_prompt_builder)
|
68 |
-
pipe.add_component("keyword_llm",
|
69 |
pipe.add_component("pubmed_fetcher", fetcher)
|
70 |
pipe.add_component("prompt_builder", prompt_builder)
|
71 |
-
pipe.add_component("llm",
|
72 |
|
73 |
pipe.connect("keyword_prompt_builder.prompt", "keyword_llm.prompt")
|
74 |
pipe.connect("keyword_llm.replies", "pubmed_fetcher.queries")
|
@@ -83,7 +85,7 @@ def query(query, _pipeline):
|
|
83 |
try:
|
84 |
result = _pipeline.run(data={"keyword_prompt_builder":{"question":query},
|
85 |
"prompt_builder":{"question": query},
|
86 |
-
"
|
87 |
except Exception as e:
|
88 |
result = ["Please make sure you are providing a correct, public Mastodon account"]
|
89 |
return result
|
|
|
33 |
llm.warm_up()
|
34 |
# start_keyword_pipeline(llm)
|
35 |
# start_qa_pipeline(llm)
|
36 |
+
keyword_llm = llm
|
37 |
+
answer_llm = llm
|
38 |
keyword_prompt_template = """
|
39 |
Your task is to convert the follwing question into 3 keywords that can be used to find relevant medical research papers on PubMed.
|
40 |
Here is an examples:
|
|
|
67 |
pipe = Pipeline()
|
68 |
|
69 |
pipe.add_component("keyword_prompt_builder", keyword_prompt_builder)
|
70 |
+
pipe.add_component("keyword_llm", keyword_llm)
|
71 |
pipe.add_component("pubmed_fetcher", fetcher)
|
72 |
pipe.add_component("prompt_builder", prompt_builder)
|
73 |
+
pipe.add_component("llm", answer_llm)
|
74 |
|
75 |
pipe.connect("keyword_prompt_builder.prompt", "keyword_llm.prompt")
|
76 |
pipe.connect("keyword_llm.replies", "pubmed_fetcher.queries")
|
|
|
85 |
try:
|
86 |
result = _pipeline.run(data={"keyword_prompt_builder":{"question":query},
|
87 |
"prompt_builder":{"question": query},
|
88 |
+
"answer_llm":{"generation_kwargs": {"max_new_tokens": 500}}})
|
89 |
except Exception as e:
|
90 |
result = ["Please make sure you are providing a correct, public Mastodon account"]
|
91 |
return result
|