Update app.py
Browse files
app.py
CHANGED
@@ -24,14 +24,12 @@ model_name = "gpt-3.5-turbo"
|
|
24 |
# Define the template
|
25 |
template = PromptTemplate(
|
26 |
prompt="""
|
27 |
-
Answer the given question using the following documents \
|
28 |
-
Formulate your answer in the style of an academic report \
|
29 |
Provide example quotes and citations using extracted text from the documents. \
|
30 |
Use facts and numbers from the documents in your answer. \
|
31 |
Reference information used from documents at the end of each applicable sentence (ex: [source: document_name]), where 'document_name' is the text provided at the start of each document (demarcated by '- &&&' and '&&&:')'. \
|
32 |
If no relevant information to answer the question is present in the documents, just say you don't have enough information to answer. \
|
33 |
-
Format your response as a JSON object with "answer" and "sources" as the keys. \
|
34 |
-
The "answer" key is the response to the query and "sources" key is the reference information used from the documents. \
|
35 |
|
36 |
Context: {' - '.join(['&&& '+d.meta['document_name']+' ref. '+str(d.meta['ref_id'])+' &&&: '+d.content for d in documents])}; Question: {query}; Answer:""",
|
37 |
)
|
@@ -118,7 +116,7 @@ retriever = EmbeddingRetriever(
|
|
118 |
)
|
119 |
|
120 |
# Initialize the PromptNode
|
121 |
-
pn = PromptNode(model_name_or_path=model_name, default_prompt_template=template, api_key=openai_key, max_length=
|
122 |
|
123 |
# Initialize the pipeline
|
124 |
pipe = Pipeline()
|
|
|
24 |
# Define the template
|
25 |
template = PromptTemplate(
|
26 |
prompt="""
|
27 |
+
Answer the given question using the following documents. \
|
28 |
+
Formulate your answer in the style of an academic report. \
|
29 |
Provide example quotes and citations using extracted text from the documents. \
|
30 |
Use facts and numbers from the documents in your answer. \
|
31 |
Reference information used from documents at the end of each applicable sentence (ex: [source: document_name]), where 'document_name' is the text provided at the start of each document (demarcated by '- &&&' and '&&&:')'. \
|
32 |
If no relevant information to answer the question is present in the documents, just say you don't have enough information to answer. \
|
|
|
|
|
33 |
|
34 |
Context: {' - '.join(['&&& '+d.meta['document_name']+' ref. '+str(d.meta['ref_id'])+' &&&: '+d.content for d in documents])}; Question: {query}; Answer:""",
|
35 |
)
|
|
|
116 |
)
|
117 |
|
118 |
# Initialize the PromptNode
|
119 |
+
pn = PromptNode(model_name_or_path=model_name, default_prompt_template=template, api_key=openai_key, max_length=2000, model_kwargs={"generation_kwargs": {"do_sample": False, "temperature": 0}})
|
120 |
|
121 |
# Initialize the pipeline
|
122 |
pipe = Pipeline()
|