mirror of
https://github.com/ParisNeo/lollms.git
synced 2024-12-19 20:57:58 +00:00
enhanced
This commit is contained in:
parent
a3c5b53542
commit
d259103fdf
@ -4461,39 +4461,38 @@ transition-all duration-300 ease-in-out">
|
|||||||
Returns:
|
Returns:
|
||||||
int: Index of the selected option within the possible_ansers list. Or -1 if there was not match found among any of them.
|
int: Index of the selected option within the possible_ansers list. Or -1 if there was not match found among any of them.
|
||||||
"""
|
"""
|
||||||
start_header_id_template = self.config.start_header_id_template
|
|
||||||
end_header_id_template = self.config.end_header_id_template
|
|
||||||
system_message_template = self.config.system_message_template
|
|
||||||
|
|
||||||
choices = "\n".join([f"{i}. {possible_answer}" for i, possible_answer in enumerate(possible_answers)])
|
choices = "\n".join([f"{i}. {possible_answer}" for i, possible_answer in enumerate(possible_answers)])
|
||||||
elements = [conditionning] if conditionning!="" else []
|
elements = [conditionning] if conditionning!="" else []
|
||||||
elements += [
|
elements += [
|
||||||
f"{start_header_id_template}{system_message_template}{end_header_id_template}",
|
f"{self.system_full_header}",
|
||||||
"Answer this multi choices question.",
|
"Answer this multi choices question in form of a json in this form:\n",
|
||||||
|
"""```json
|
||||||
|
{
|
||||||
|
"justification": "A justification for your choice",
|
||||||
|
"choice_index": the index of the choice made
|
||||||
|
}
|
||||||
|
```
|
||||||
|
""",
|
||||||
]
|
]
|
||||||
if context!="":
|
if context!="":
|
||||||
elements+=[
|
elements+=[
|
||||||
f"{start_header_id_template}Context{end_header_id_template}",
|
self.system_custom_header("Context"),
|
||||||
f"{context}",
|
f"{context}",
|
||||||
]
|
]
|
||||||
elements +=[
|
|
||||||
"Answer with an id from the possible answers.",
|
|
||||||
"Do not answer with an id outside this possible answers.",
|
|
||||||
"Do not explain your reasons or add comments.",
|
|
||||||
"the output should be an integer."
|
|
||||||
]
|
|
||||||
elements += [
|
elements += [
|
||||||
f"{start_header_id_template}question{end_header_id_template}{question}",
|
self.system_custom_header("question"),
|
||||||
f"{start_header_id_template}possible answers{end_header_id_template}",
|
question,
|
||||||
|
self.system_custom_header("possible answers"),
|
||||||
f"{choices}",
|
f"{choices}",
|
||||||
]
|
]
|
||||||
elements += [f"{start_header_id_template}answer{end_header_id_template}"]
|
elements += [self.system_custom_header("answer")]
|
||||||
prompt = self.build_prompt(elements)
|
prompt = self.build_prompt(elements)
|
||||||
|
|
||||||
gen = self.generate(prompt, max_answer_length, temperature=0.1, top_k=50, top_p=0.9, repeat_penalty=1.0, repeat_last_n=50, callback=self.sink).strip().replace("</s>","").replace("<s>","")
|
code = self.generate_code(prompt, self.personality.image_files, max_answer_length, temperature=0.1, top_k=50, top_p=0.9, repeat_penalty=1.0, repeat_last_n=50, callback=self.sink).strip().replace("</s>","").replace("<s>","")
|
||||||
if len(gen)>0:
|
if len(code)>0:
|
||||||
selection = gen.strip().split()[0].replace(",","").replace(".","")
|
json_code = json.loads(code)
|
||||||
self.print_prompt("Multi choice selection",prompt+gen)
|
selection = json_code["choice_index"]
|
||||||
|
self.print_prompt("Multi choice selection",prompt+code)
|
||||||
try:
|
try:
|
||||||
return int(selection)
|
return int(selection)
|
||||||
except:
|
except:
|
||||||
|
Loading…
Reference in New Issue
Block a user