File size: 8,163 Bytes
237451b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
# gemma = """
# <start_of_turn>user
# Below is a question, please answer it directly and keep your answer as short as possible.
# Question: {query}<end_of_turn><start_of_turn>model
# """
# gemma ="""
# """
# llama = """
# <|begin_of_text|><|start_header_id|>user<|end_header_id|>
# Below is a question, please answer it directly and keep your answer as short as possible.
# Question: {query}<|eot_id|><|start_header_id|>assistant<|end_header_id|>
# """
llama = """
{query}"""
gemma = """
{query}"""
mistral = """
{query}"""
qwen = """
{query}"""
phi = """
{query}"""

generate_answer = '''
Below is a question, please answer it directly and keep your answer as short as possible.
Question: {query}
Answer:
'''

generate_answer_based_on_context = '''
Given some related documents: {re_content}.
This is a  question: {question}
Please answer the question directly. Please keep your answer as short as possible.
Answer:
'''

generate_subquestion = '''
Given a main question and optional previous subquestion-answer pairs, you may need to generate subquestions to help answer this main question. Please ensure to only generate subquestions that are relevant to answering the main question. When there are no more subquestions needed, output "finish".

## Input Format
Required:
- Main Question: [question]

Optional:
- Previous Subquestion: [subquestion]
- Previous Answer: [subanswer]

## Output Format
One of:
- Next Subquestion: [new subquestion]
- "finish" (when no further subquestions are needed)

## Generation Guidelines
1. Subquestions should:
   - Break down complex aspects of the main question
   - Follow a logical progression
   - Be specific and focused
   - Build upon previous answers when available

2. Output "finish" when:
   - All relevant aspects have been covered
   - Further breakdown would not add value
   - The question has been fully addressed

## There are some examples

Example 1:
Input:
- Main Question: "What is the  location of the headquarters of the institution where Percival Lowell was educated?"
- Previous Subquestion: "Where did Percival Lowell receive his education?""
- Previous Answer: "Harvard University."

Output:
- Next Subquestion: "Where is the headquarters of the Harvard University?"

Example 2:
Input:
- Main Question: "What is the capital of France?"

Output:
- "finish"

Main Question: {question}
{previous_subquestion_answer_pairs}

Output:
'''

generate_summary_prompt = '''
Based on the main question and all subquestion-answer pairs, please provide a comprehensive final answer. Please keep your answer as short as possible.

Main Question: {main_question}

Previous Subquestions and Answers:
{history_str}

Final Answer:
'''
# def generate_summary_prompt(main_question: str, subquestion_answers: List[Dict]) -> str:
#     """生成总结性提示"""
#     history_str = "\n".join([
#         f"Subquestion: {qa['question']}\nAnswer: {qa['answer']}"
#         for qa in subquestion_answers
#     ])
    
#     return f""""""

# generate_confidence_prompt = '''Answer the following question based on your internal knowledge with one or few words. 
# If you are sure the answer is accurate and correct, please say “certain” after the answer. 
# If you are not confident with the answer, please say “uncertain”.'''
generate_confidence_prompt = '''
Answer the following question based on your internal knowledge with one or few words.
Add a confidence indicator after your answer:
- "certain" if you are completely confident in the accuracy
- "uncertain" if you have any doubts

## Input Format
Input:
- Question: [question]

## Output Format
Output:
- Answer: [brief answer]
- Confidence: [certain/uncertain]


Question: {question}
Output: 
'''
## Confidence Criteria
# - Use "certain" when:
#   * The answer is based on widely accepted facts
#   * The information is verifiable through authoritative sources
#   * There is no reasonable doubt about the accuracy

# - Use "uncertain" when:
#   * The answer involves estimates or approximations
#   * Multiple valid interpretations are possible
#   * The information might be outdated or context-dependent
#   * There is any doubt about the completeness or accuracy

# judgement_prompt_part1 = '''
# In the following task, you are given a Question, a model Prediction for the Question, and a Ground-truth Answer to the Question. You should decide whether the model Prediction implies the Ground-truth Answer.
# Question {question}
# Prediction {model output}
# Ground-truth Answer {answer}
# Does the Prediction imply the Ground-truth Answer? Output Yes or No:
# '''

judgement_prompt_qa= '''
Given a question and a model-generated answer, determine if we can be highly confident that the model's answer is definitively correct for this question.

## Input Format
Input:
- Question: [question]
- Model Answer: [model output]

## Output Format
Output:
- Confidence: [Yes/No]
  - Yes: The answer can be definitively confirmed as correct
  - No: The answer cannot be definitively confirmed as correct

Note: Only output "Yes" if there is a very high degree of certainty that the answer is correct and complete.
Question: {question}
Model Answer: {model_output}

Output:
'''


# judgement_prompt = '''Input:
# <SYS> You are a helpful assistant. Your task is to parse user input into structured formats and accomplish the task according to the heuristic answer. </SYS>
# Heuristic answer: {Heuristic Answer} Question: {user question}
# Retrieval Necessity Judgment Output: Output:
#   Known (True / False)'''
judgement_prompt_retrieval = ''' 
Determine whether external document retrieval is necessary to provide an accurate and complete answer to the given question. Please keep your answer as short as possible.

## Input Format
Input:
- Question: [question]

## Output Format
Output:
- Retrieval Needed: [Yes/No]

Question: {question}

Output:
'''
# first_hop_prompt = '''Given some related documents: {document}. 
# This is a  question: {question}
# Please answer the question directly. Please keep your answer as short as possible.
# Answer:'''

# multi_hop_prompt ='''Given a question: {question}
# The subsequent sub-questions: {sub_questions} 
# You have two choices now.
# <choice A> answer the final sub-question directly.
# <choice B> retrieve some document to help you answer the question. Just output retrieval as a placeholder.
# If you choose <choice A> please output {{"choice A": {{"answer": "your_answer_here"}}}}
# If you choose <choice B> please output {{"choice B": retrieval}}
# The final output should be in the form of a JSON string, without any additional content. Please keep your answer as short as possible.
# Output: '''

# multi_hop_prompt_2_1 = '''Given a question: {question}
# And subquestion-answer pairs: {subquestion_answer_pairs}
# Please judge if the question has been finished. You have two choices now.
# <choice A> The answer can be found in the subquestion-answer pairs.
# <choice B> The answer cannot be found and a new sub-question needs to be generated.
# If you choose <choice A>, please output {{"choice A": {{"answer": "final_answer_here"}}}}
# If you choose <choice B>, please output {{"choice B": {{"subquestion": "new_subquestion_here"}}}}
# The final output should be in the form of a JSON string, without any additional content. Please keep your answer as short as possible.
# Output:'''

# multi_hop_prompt_2_2 = '''Given some related documents: {documents} 
# This is a question: {question}
# The subsequent sub-questions: {sub_questions}
# please answer the final sub-question. You can use the information in the related documents.
# Please keep your answer as short as possible.
# Answer: '''
# mistral = """
# text = "<s>[INST] Below is a question, please answer it directly and keep your answer as short as possible.
# Question: {query} [/INST]"
# """
# qwen = """
# <|im_start|>user
# Below is a question, please answer it directly and keep your answer as short as possible.
# Question: {query}<|im_end|>
# <|im_start|>assistant
# """
# phi = """
# <|user|>
# Below is a question, please answer it directly and keep your answer as short as possible.
# Question: {query}<|end|>
# <|assistant|>
# """