mirror of
https://github.com/danswer-ai/danswer.git
synced 2025-05-04 17:00:24 +02:00
prompts
This commit is contained in:
parent
b46c09ac6c
commit
4b0d22fae3
@ -1,5 +1,6 @@
|
|||||||
# Standards
|
# Standards
|
||||||
SEPARATOR_LINE = "-------"
|
SEPARATOR_LINE = "-------"
|
||||||
|
SEPARATOR_LINE_LONG = "---------------"
|
||||||
UNKNOWN_ANSWER = "I do not have enough information to answer this question."
|
UNKNOWN_ANSWER = "I do not have enough information to answer this question."
|
||||||
NO_RECOVERED_DOCS = "No relevant information recovered"
|
NO_RECOVERED_DOCS = "No relevant information recovered"
|
||||||
YES = "yes"
|
YES = "yes"
|
||||||
@ -300,7 +301,7 @@ INITIAL_ANSWER_PROMPT_W_SUB_QUESTIONS = (
|
|||||||
"Try to keep your answer concise. But also highlight uncertainties you may have should there be substantial ones,\n"
|
"Try to keep your answer concise. But also highlight uncertainties you may have should there be substantial ones,\n"
|
||||||
"or assumptions you made.\n\n"
|
"or assumptions you made.\n\n"
|
||||||
"Here is the contextual information:\n"
|
"Here is the contextual information:\n"
|
||||||
"---------------\n\n"
|
f"{SEPARATOR_LINE_LONG}\n\n"
|
||||||
"*Answered Sub-questions (these should really matter!):\n"
|
"*Answered Sub-questions (these should really matter!):\n"
|
||||||
f"{SEPARATOR_LINE}\n"
|
f"{SEPARATOR_LINE}\n"
|
||||||
"{answered_sub_questions}\n"
|
"{answered_sub_questions}\n"
|
||||||
@ -417,166 +418,125 @@ REFINEMENT_QUESTION_DECOMPOSITION_PROMPT = (
|
|||||||
|
|
||||||
|
|
||||||
REFINED_ANSWER_PROMPT_W_SUB_QUESTIONS = (
|
REFINED_ANSWER_PROMPT_W_SUB_QUESTIONS = (
|
||||||
"""\n
|
"{persona_specification}\n\n"
|
||||||
{persona_specification}
|
"Your task is to improve on a given answer to a question, as the initial answer was found to be lacking in some way.\n\n"
|
||||||
|
"Use the information provided below - and only the provided information - to write your new and improved answer.\n\n"
|
||||||
Your task is to improve on a given answer to a question, as the initial answer was found to be lacking in some way.
|
"The information provided below consists of:\n"
|
||||||
|
" 1) an initial answer that was given but found to be lacking in some way.\n"
|
||||||
Use the information provided below - and only the provided information - to write your new and improved answer.
|
" 2) a number of answered sub-questions - these are very important(!) and definitely should help you to answer "
|
||||||
|
"the main question. Note that the sub-questions have a type, 'initial' and 'refined'. The 'initial' "
|
||||||
The information provided below consists of:
|
"ones were available for the creation of the initial answer, but the 'refined' were not, they are new. So please use "
|
||||||
1) an initial answer that was given but found to be lacking in some way.
|
"the 'refined' sub-questions in particular to update/extend/correct/enrich the initial answer and to add "
|
||||||
2) a number of answered sub-questions - these are very important(!) and definitely should help you to answer
|
"more details/new facts!\n"
|
||||||
the main question. Note that the sub-questions have a type, 'initial' and 'refined'. The 'initial'
|
" 3) a number of documents that were deemed relevant for the question. This is the context that you use largely for "
|
||||||
ones were available for the creation of the initial answer, but the 'refined' were not, they are new. So please use
|
"citations (see below). So consider the answers to the sub-questions as guidelines to construct your new answer, but "
|
||||||
the 'refined' sub-questions in particular to update/extend/correct/enrich the initial answer and to add
|
"make sure you cite the relevant document for a fact!\n\n"
|
||||||
more details/new facts!
|
"It is critical that you provide proper inline citations to documents in the format [D1], [D2], [D3], etc! "
|
||||||
|
"It is important that the citation is close to the information it supports. "
|
||||||
3) a number of documents that were deemed relevant for the question. This the is the context that you use largely for
|
"DO NOT just list all of the citations at the very end. "
|
||||||
citations (see below). So consider the answers to the sub-questions as guidelines to construct your new answer, but
|
"Feel free to also cite sub-questions in addition to documents, but make sure that you have documents cited with the "
|
||||||
make sure you cite the relevant document for a fact!
|
"sub-question citation. If you want to cite both a document and a sub-question, please use [D1][Q3], or [D2][D7][Q4], etc. "
|
||||||
|
"and always place the document citation before the sub-question citation. "
|
||||||
It is critical that you provide proper inline citations to documents in the format [D1], [D2], [D3], etc!
|
"Again, please NEVER cite sub-questions without a document citation!\n"
|
||||||
It is important that the citation is close to the information it supports. If you have multiple
|
"Proper citations are very important for the user!\n\n"
|
||||||
citations, please cite for example as [D1][D3], or [D2][D4], etc.
|
"{history}\n\n"
|
||||||
Feel free to also cite sub-questions in addition to documents, but make sure that you have documents cited with the sub-question
|
"IMPORTANT RULES:\n"
|
||||||
citation. If you want to cite both a document and a sub-question, please use [D1][Q3], or [D2][D7][Q4], etc.
|
" - If you cannot reliably answer the question solely using the provided information, say that you cannot reliably answer. "
|
||||||
Again, please NEVER cite sub-questions without a document citation!
|
"You may give some additional facts you learned, but do not try to invent an answer.\n"
|
||||||
Proper citations are very important for the user!\n\n
|
f' - If the information is empty or irrelevant, just say "{UNKNOWN_ANSWER}".\n'
|
||||||
|
" - If the information is relevant but not fully conclusive, provide an answer to the extent you can but also "
|
||||||
{history}
|
"specify that the information is not conclusive and why.\n"
|
||||||
|
" - Ignore any existing citations within the answered sub-questions, like [D1]... and [Q2]! "
|
||||||
IMPORTANT RULES:
|
"The citations you will need to use will need to refer to the documents (and sub-questions) that you are explicitly "
|
||||||
- If you cannot reliably answer the question solely using the provided information, say that you cannot reliably answer.
|
"presented with below!\n\n"
|
||||||
You may give some additional facts you learned, but do not try to invent an answer.
|
"Again, you should be sure that the answer is supported by the information provided!\n\n"
|
||||||
- If the information is empty or irrelevant, just say """
|
"Try to keep your answer concise. But also highlight uncertainties you may have should there be substantial ones, "
|
||||||
+ f'"{UNKNOWN_ANSWER}"'
|
"or assumptions you made.\n\n"
|
||||||
+ """.
|
"Here is the contextual information:\n"
|
||||||
- If the information is relevant but not fully conclusive, provide an answer to the extent you can but also
|
f"{SEPARATOR_LINE_LONG}\n\n"
|
||||||
specify that the information is not conclusive and why.
|
"*Initial Answer that was found to be lacking:\n"
|
||||||
- Ignore any existing citations within the answered sub-questions, like [D1]... and [Q2]!
|
f"{SEPARATOR_LINE}\n"
|
||||||
The citations you will need to use will need to refer to the documents (and sub-questions) that you are explicitly
|
"{initial_answer}\n"
|
||||||
presented with below!
|
f"{SEPARATOR_LINE}\n\n"
|
||||||
|
"*Answered Sub-questions (these should really help you to research your answer! They also contain questions/answers "
|
||||||
Again, you should be sure that the answer is supported by the information provided!
|
"that were not available when the original answer was constructed):\n"
|
||||||
|
"{answered_sub_questions}\n\n"
|
||||||
Try to keep your answer concise. But also highlight uncertainties you may have should there be substantial ones,
|
"And here are the relevant documents that support the sub-question answers, and that are relevant for the actual question:\n"
|
||||||
or assumptions you made.
|
f"{SEPARATOR_LINE}\n"
|
||||||
|
"{relevant_docs}\n"
|
||||||
Here is the contextual information:
|
f"{SEPARATOR_LINE}\n\n"
|
||||||
---------------
|
"Lastly, here is the main question I want you to answer based on the information above:\n"
|
||||||
|
f"{SEPARATOR_LINE}\n"
|
||||||
*Initial Answer that was found to be lacking:
|
"{question}\n"
|
||||||
\n-------\n
|
f"{SEPARATOR_LINE}\n\n"
|
||||||
{initial_answer}
|
"Please keep your answer brief and concise, and focus on facts and data.\n\n"
|
||||||
\n-------\n
|
"Answer:"
|
||||||
|
).strip()
|
||||||
*Answered Sub-questions (these should really help you to research your answer! They also contain questions/answers
|
|
||||||
that were not available when the original answer was constructed):
|
|
||||||
{answered_sub_questions}
|
|
||||||
|
|
||||||
And here are the relevant documents that support the sub-question answers, and that are relevant for the actual question:\n
|
|
||||||
\n-------\n
|
|
||||||
{relevant_docs}
|
|
||||||
\n-------\n
|
|
||||||
|
|
||||||
\n
|
|
||||||
Lastly, here is the main question I want you to answer based on the information above:
|
|
||||||
\n-------\n
|
|
||||||
{question}
|
|
||||||
\n-------\n
|
|
||||||
|
|
||||||
Please keep your answer brief and concise, and focus on facts and data.
|
|
||||||
|
|
||||||
Answer:"""
|
|
||||||
)
|
|
||||||
|
|
||||||
# sub_question_answer_str is empty
|
# sub_question_answer_str is empty
|
||||||
REFINED_ANSWER_PROMPT_WO_SUB_QUESTIONS = (
|
REFINED_ANSWER_PROMPT_WO_SUB_QUESTIONS = (
|
||||||
"""\n
|
"{answered_sub_questions}{persona_specification}\n\n"
|
||||||
{answered_sub_questions}\n
|
"Use the information provided below - and only the provided information - to answer the provided question.\n\n"
|
||||||
{persona_specification}
|
"The information provided below consists of:\n"
|
||||||
|
" 1) an initial answer that was given but found to be lacking in some way.\n"
|
||||||
Use the information provided below - and only the
|
" 2) a number of documents that were also deemed relevant for the question.\n\n"
|
||||||
provided information - to answer the provided question.
|
"It is critical that you provide proper inline citations to documents in the format [D1], [D2], [D3], etc! "
|
||||||
|
"It is important that the citation is close to the information it supports. "
|
||||||
The information provided below consists of:
|
"DO NOT just list all of the citations at the very end of your response. Citations are very important for the user!\n\n"
|
||||||
1) an initial answer that was given but found to be lacking in some way.
|
"{history}\n\n"
|
||||||
2) a number of documents that were also deemed relevant for the question.
|
"IMPORTANT RULES:\n"
|
||||||
|
" - If you cannot reliably answer the question solely using the provided information, say that you cannot reliably answer. "
|
||||||
It is critical that you provide proper] inline citations to documents in the format [D1], [D2], [D3], etc!
|
"You may give some additional facts you learned, but do not try to invent an answer.\n"
|
||||||
It is important that the citation is close to the information it supports. If you have multiple
|
f' - If the information is empty or irrelevant, just say "{UNKNOWN_ANSWER}".\n'
|
||||||
citations, please cite for example as [D1][D3], or [D2][D4], etc. Citations are very important for the user!\n\n
|
" - If the information is relevant but not fully conclusive, provide an answer to the extent you can but also "
|
||||||
\n-------\n
|
"specify that the information is not conclusive and why.\n\n"
|
||||||
{history}
|
"Again, you should be sure that the answer is supported by the information provided!\n\n"
|
||||||
\n-------\n
|
"Try to keep your answer concise. But also highlight uncertainties you may have should there be substantial ones, "
|
||||||
IMPORTANT RULES:
|
"or assumptions you made.\n\n"
|
||||||
- If you cannot reliably answer the question solely using the provided information, say that you cannot reliably answer.
|
"Here is the contextual information:\n"
|
||||||
You may give some additional facts you learned, but do not try to invent an answer.
|
f"{SEPARATOR_LINE_LONG}\n\n"
|
||||||
- If the information is empty or irrelevant, just say """
|
"*Initial Answer that was found to be lacking:\n"
|
||||||
+ f'"{UNKNOWN_ANSWER}"'
|
f"{SEPARATOR_LINE}\n"
|
||||||
+ """.
|
"{initial_answer}\n"
|
||||||
- If the information is relevant but not fully conclusive, provide and answer to the extent you can but also
|
f"{SEPARATOR_LINE}\n\n"
|
||||||
specify that the information is not conclusive and why.
|
"And here are relevant document information that support the sub-question answers, "
|
||||||
|
"or that are relevant for the actual question:\n"
|
||||||
Again, you should be sure that the answer is supported by the information provided!
|
f"{SEPARATOR_LINE}\n"
|
||||||
|
"{relevant_docs}\n"
|
||||||
Try to keep your answer concise. But also highlight uncertainties you may have should there be substantial ones,
|
f"{SEPARATOR_LINE}\n\n"
|
||||||
or assumptions you made.
|
"Lastly, here is the question I want you to answer based on the information above:\n"
|
||||||
|
f"{SEPARATOR_LINE}\n"
|
||||||
Here is the contextual information:
|
"{question}\n"
|
||||||
---------------
|
f"{SEPARATOR_LINE}\n\n"
|
||||||
|
"Please keep your answer brief and concise, and focus on facts and data.\n\n"
|
||||||
*Initial Answer that was found to be lacking:
|
"Answer:"
|
||||||
\n-------\n
|
).strip()
|
||||||
{initial_answer}
|
|
||||||
\n-------\n
|
|
||||||
|
|
||||||
And here are relevant document information that support the sub-question answers, or that are relevant for the actual question:\n
|
|
||||||
\n-------\n
|
|
||||||
{relevant_docs}
|
|
||||||
\n-------\n
|
|
||||||
\n
|
|
||||||
Lastly, here is the question I want you to answer based on the information above:
|
|
||||||
\n-------\n
|
|
||||||
{question}
|
|
||||||
\n-------\n\n
|
|
||||||
Please keep your answer brief and concise, and focus on facts and data.
|
|
||||||
|
|
||||||
Answer:"""
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
INITIAL_REFINED_ANSWER_COMPARISON_PROMPT = """
|
INITIAL_REFINED_ANSWER_COMPARISON_PROMPT = (
|
||||||
For the given question, please compare the initial answer and the refined answer and determine if
|
"For the given question, please compare the initial answer and the refined answer and determine if "
|
||||||
the refined answer is substantially better than the initial answer, not just a bit better. Better could mean:
|
"the refined answer is substantially better than the initial answer, not just a bit better. Better could mean:\n"
|
||||||
- additional information
|
" - additional information\n"
|
||||||
- more comprehensive information
|
" - more comprehensive information\n"
|
||||||
- more concise information
|
" - more concise information\n"
|
||||||
- more structured information
|
" - more structured information\n"
|
||||||
- morde details
|
" - more details\n"
|
||||||
- new bullet points
|
" - new bullet points\n"
|
||||||
- substantially more document citations ([D1], [D2], [D3], etc.)
|
" - substantially more document citations ([D1], [D2], [D3], etc.)\n\n"
|
||||||
|
"Put yourself in the shoes of the user and think about whether the refined answer is really substantially "
|
||||||
Put yourself in the shoes of the user and think about whether the refined answer is really substantially
|
"better and delivers really new insights than the initial answer.\n\n"
|
||||||
better and delivers really new insights than the initial answer.
|
"Here is the question:\n"
|
||||||
|
f"{SEPARATOR_LINE}\n"
|
||||||
Here is the question:
|
"{question}\n"
|
||||||
\n-------\n
|
f"{SEPARATOR_LINE}\n\n"
|
||||||
{question}
|
"Here is the initial answer:\n"
|
||||||
\n-------\n
|
f"{SEPARATOR_LINE}\n"
|
||||||
|
"{initial_answer}\n"
|
||||||
Here is the initial answer:
|
f"{SEPARATOR_LINE}\n\n"
|
||||||
\n-------\n
|
"Here is the refined answer:\n"
|
||||||
{initial_answer}
|
f"{SEPARATOR_LINE}\n"
|
||||||
\n-------\n
|
"{refined_answer}\n"
|
||||||
|
f"{SEPARATOR_LINE}\n\n"
|
||||||
Here is the refined answer:
|
"With these criteria in mind, is the refined answer substantially better than the initial answer?\n\n"
|
||||||
\n-------\n
|
f'Please answer with a simple "{YES}" or "{NO}".'
|
||||||
{refined_answer}
|
).strip()
|
||||||
\n-------\n
|
|
||||||
|
|
||||||
With these criteria in mind, is the refined answer substantially better than the initial answer?
|
|
||||||
|
|
||||||
Please answer with a simple 'yes' or 'no'.
|
|
||||||
"""
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user