-
Notifications
You must be signed in to change notification settings - Fork 33
Add XmlMultipleChoicePromptTemplate and ExtractDiscreteAnswerFromXml
#922
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very nice, some comments on alignment between templates
| IMPORTANT: Respond with a valid JSON object where the "{{ answer_key }}" key | ||
| contains your answer, and "{{ reason_key }}" should contain a brief | ||
| explanation for why the provided answer was chosen. | ||
| IMPORTANT: Respond with a valid JSON object where the "{{ answer_key }}" key contains your answer. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| IMPORTANT: Respond with a valid JSON object where the "{{ answer_key }}" key contains your answer. | |
| IMPORTANT: Respond with a valid JSON object with a single "{{ answer_key }}" key that contains your answer. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In the raw template it says
IMPORTANT: You must provide your reasoning first, then end your response with only your final answer
- I suggest we either explicitly mention here to reason first as well, or we leave it out in both cases. I'd be in favor of keeping it everywhere if CoT is enabled and use the phrasing here if not.
So with enable_cot:
IMPORTANT: You must provide your reasoning first, then end your response with a valid JSON object with a single "{{ answer_key }}" key that contains your answer.
Without:
IMPORTANT: Respond with a valid JSON object with a single "{{ answer_key }}" key that contains your answer.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Or we keep the phrasing "reasoning" in general, since this can also apply to non-CoT responses. What do you think? Also related to the comment below
| Example JSON Answer: | ||
| Your explanation for why you chose this answer can go here... | ||
| {{ '{' }} | ||
| "{{ answer_key }}": "{{ example_answer }}", | ||
| "{{ reason_key }}": "{{ example_reason }}" | ||
| "{{ answer_key }}": "{{ example_answer }}" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Suggestion:
Example Answer:
Your reasoning for why you chose this answer can go here...
{{ '{' }}
"{{ answer_key }}": "{{ example_answer }}"
{{ '}' }}
| {{ context }} | ||
| {% endif %} | ||
| IMPORTANT: Provide your final answer within <{{ answer_key }}></{{ answer_key }}> tags. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same as above, let's align the instruction across templates
| {{ answer_options }} | ||
| Example Answer: | ||
| Your explanation for why you chose this answer can go here... <{{ answer_key }}>{{ example_answer }}</{{ answer_key }}> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And same here with the phrasing of "reasoning"
| self.answer_key = answer_key | ||
|
|
||
| @override | ||
| def render( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems like this and the JSON template render func are the same, perhaps we can unify that
Closes #921
ExtractDiscreteAnswerFromStructuredOutputabstract base class which is implemented by both the JSON & XML extractors.JsonMultipleChoicePromptTemplateremoving thereasonkey from the requested JSON format and allowing the models to provide their reasoning outside the structured JSON answer template.Example
results in this prompt: