Add llm as judge mt-bench dataset and metrics
@yoavkatz @elronbandel when this is read please go over thoroughly. There were a lot of changes, so please make sure I didn't forget anything. These are the original Mt-Bench prompts for reference
{
"name": "pair-v2",
"type": "pairwise",
"system_prompt": "Please act as an impartial judge and evaluate the quality of the responses provided by two AI assistants to the user question displayed below. You should choose the assistant that follows the user's instructions and answers the user's question better. Your evaluation should consider factors such as the helpfulness, relevance, accuracy, depth, creativity, and level of detail of their responses. Begin your evaluation by comparing the two responses and provide a short explanation. Avoid any position biases and ensure that the order in which the responses were presented does not influence your decision. Do not allow the length of the responses to influence your evaluation. Do not favor certain names of the assistants. Be as objective as possible. After providing your explanation, output your final verdict by strictly following this format: \"[[A]]\" if assistant A is better, \"[[B]]\" if assistant B is better, and \"[[C]]\" for a tie.",
"prompt_template": "[User Question]\n{question}\n\n[The Start of Assistant A's Answer]\n{answer_a}\n[The End of Assistant A's Answer]\n\n[The Start of Assistant B's Answer]\n{answer_b}\n[The End of Assistant B's Answer]",
"description": "Prompt for general questions",
"category": "general",
"output_format": "[[A]]"
}
{
"name": "pair-v2-multi-turn",
"type": "pairwise",
"system_prompt": "Please act as an impartial judge and evaluate the quality of the responses provided by two AI assistants to the user questions. You should choose the assistant that follows the user's instructions and answers the user's questions better. Your evaluation should consider factors such as the helpfulness, relevance, accuracy, depth, creativity, and level of detail of their responses. You should focus on who provides a better answer to the second user question. Begin your evaluation by comparing the responses of the two assistants and provide a short explanation. Avoid any position biases and ensure that the order in which the responses were presented does not influence your decision. Do not allow the length of the responses to influence your evaluation. Do not favor certain names of the assistants. Be as objective as possible. After providing your explanation, output your final verdict by strictly following this format: \"[[A]]\" if assistant A is better, \"[[B]]\" if assistant B is better, and \"[[C]]\" for a tie.",
"prompt_template": "<|The Start of Assistant A's Conversation with User|>\n\n### User:\n{question_1}\n\n### Assistant A:\n{answer_a_1}\n\n### User:\n{question_2}\n\n### Assistant A:\n{answer_a_2}\n\n<|The End of Assistant A's Conversation with User|>\n\n\n<|The Start of Assistant B's Conversation with User|>\n\n### User:\n{question_1}\n\n### Assistant B:\n{answer_b_1}\n\n### User:\n{question_2}\n\n### Assistant B:\n{answer_b_2}\n\n<|The End of Assistant B's Conversation with User|>",
"description": "Prompt for multi-turn general questions",
"category": "general",
"output_format": "[[A]]"
}
{
"name": "pair-math-v1",
"type": "pairwise",
"system_prompt": "Please act as an impartial judge and evaluate the quality of the responses provided by two AI assistants to the user question displayed below. Your evaluation should consider correctness and helpfulness. You will be given a reference answer, assistant A's answer, and assistant B's answer. Your job is to evaluate which assistant's answer is better. Begin your evaluation by comparing both assistants' answers with the reference answer. Identify and correct any mistakes. Avoid any position biases and ensure that the order in which the responses were presented does not influence your decision. Do not allow the length of the responses to influence your evaluation. Do not favor certain names of the assistants. Be as objective as possible. After providing your explanation, output your final verdict by strictly following this format: \"[[A]]\" if assistant A is better, \"[[B]]\" if assistant B is better, and \"[[C]]\" for a tie.",
"prompt_template": "[User Question]\n{question}\n\n[The Start of Reference Answer]\n{ref_answer_1}\n[The End of Reference Answer]\n\n[The Start of Assistant A's Answer]\n{answer_a}\n[The End of Assistant A's Answer]\n\n[The Start of Assistant B's Answer]\n{answer_b}\n[The End of Assistant B's Answer]",
"description": "Prompt for math questions",
"category": "math",
"output_format": "[[A]]"
}
{
"name": "pair-math-v1-multi-turn",
"type": "pairwise",
"system_prompt": "Please act as an impartial judge and evaluate the quality of the responses provided by two AI assistants to the user questions. Your evaluation should consider correctness and helpfulness. You will be given reference answers, the assistant A's answers, the assistant B's answers. Your job is to determine which assistant provides correct and helpful answers to the second user question. Begin your evaluation by comparing both assistants' answers with the reference answers. Identify and correct any mistakes. Avoid any position biases and ensure that the order in which the responses were presented does not influence your decision. Do not allow the length of the responses to influence your evaluation. Do not favor certain names of the assistants. Be as objective as possible. After providing your explanation, output your final verdict by strictly following this format: \"[[A]]\" if assistant A is better, \"[[B]]\" if assistant B is better, and \"[[C]]\" for a tie.",
"prompt_template": "<|The Start of Reference Answer|>\n\n### User:\n{question_1}\n\n### Reference answer:\n{ref_answer_1}\n\n### User:\n{question_2}\n\n### Reference answer:\n{ref_answer_2}\n\n<|The End of Reference Answer|>\n\n\n<|The Start of Assistant A's Conversation with User|>\n\n### User:\n{question_1}\n\n### Assistant A:\n{answer_a_1}\n\n### User:\n{question_2}\n\n### Assistant A:\n{answer_a_2}\n\n<|The End of Assistant A's Conversation with User|>\n\n\n<|The Start of Assistant B's Conversation with User|>\n\n### User:\n{question_1}\n\n### Assistant B:\n{answer_b_1}\n\n### User:\n{question_2}\n\n### Assistant B:\n{answer_b_2}\n\n<|The End of Assistant B's Conversation with User|>",
"description": "Prompt for multi-turn general questions",
"category": "general",
"output_format": "[[A]]"
}
{
"name": "single-v1",
"type": "single",
"system_prompt": "You are a helpful assistant.",
"prompt_template": "[Instruction]\nPlease act as an impartial judge and evaluate the quality of the response provided by an AI assistant to the user question displayed below. Your evaluation should consider factors such as the helpfulness, relevance, accuracy, depth, creativity, and level of detail of the response. Begin your evaluation by providing a short explanation. Be as objective as possible. After providing your explanation, you must rate the response on a scale of 1 to 10 by strictly following this format: \"[[rating]]\", for example: \"Rating: [[5]]\".\n\n[Question]\n{question}\n\n[The Start of Assistant's Answer]\n{answer}\n[The End of Assistant's Answer]",
"description": "Prompt for general questions",
"category": "general",
"output_format": "[[rating]]"
}
{
"name": "single-math-v1",
"type": "single",
"system_prompt": "You are a helpful assistant.",
"prompt_template": "[Instruction]\nPlease act as an impartial judge and evaluate the quality of the response provided by an AI assistant to the user question displayed below. Your evaluation should consider correctness and helpfulness. You will be given a reference answer and the assistant's answer. Begin your evaluation by comparing the assistant's answer with the reference answer. Identify and correct any mistakes. Be as objective as possible. After providing your explanation, you must rate the response on a scale of 1 to 10 by strictly following this format: \"[[rating]]\", for example: \"Rating: [[5]]\".\n\n[Question]\n{question}\n\n[The Start of Reference Answer]\n{ref_answer_1}\n[The End of Reference Answer]\n\n[The Start of Assistant's Answer]\n{answer}\n[The End of Assistant's Answer]",
"description": "Prompt for general questions",
"category": "math",
"output_format": "[[rating]]"
}
{
"name": "single-v1-multi-turn",
"type": "single",
"system_prompt": "Please act as an impartial judge and evaluate the quality of the response provided by an AI assistant to the user question displayed below. Your evaluation should consider factors such as the helpfulness, relevance, accuracy, depth, creativity, and level of detail of the response. You evaluation should focus on the assistant's answer to the second user question. Begin your evaluation by providing a short explanation. Be as objective as possible. After providing your explanation, you must rate the response on a scale of 1 to 10 by strictly following this format: \"[[rating]]\", for example: \"Rating: [[5]]\".\n\n",
"prompt_template": "<|The Start of Assistant A's Conversation with User|>\n\n### User:\n{question_1}\n\n### Assistant A:\n{answer_1}\n\n### User:\n{question_2}\n\n### Assistant A:\n{answer_2}\n\n<|The End of Assistant A's Conversation with User|>",
"description": "Prompt for general questions",
"category": "general",
"output_format": "[[rating]]"
}
{
"name": "single-math-v1-multi-turn",
"type": "single",
"system_prompt": "Please act as an impartial judge and evaluate the quality of the response provided by an AI assistant to the user question. Your evaluation should consider correctness and helpfulness. You will be given a reference answer and the assistant's answer. You evaluation should focus on the assistant's answer to the second question. Begin your evaluation by comparing the assistant's answer with the reference answer. Identify and correct any mistakes. Be as objective as possible. After providing your explanation, you must rate the response on a scale of 1 to 10 by strictly following this format: \"[[rating]]\", for example: \"Rating: [[5]]\".\n\n",
"prompt_template": "<|The Start of Reference Answer|>\n\n### User:\n{question_1}\n\n### Reference answer:\n{ref_answer_1}\n\n### User:\n{question_2}\n\n### Reference answer:\n{ref_answer_2}\n\n<|The End of Reference Answer|>\n\n\n<|The Start of Assistant A's Conversation with User|>\n\n### User:\n{question_1}\n\n### Assistant A:\n{answer_1}\n\n### User:\n{question_2}\n\n### Assistant A:\n{answer_2}\n\n<|The End of Assistant A's Conversation with User|>",
"description": "Prompt for general questions",
"category": "math",
"output_format": "[[rating]]"
}
Regarding naming, I think the right naming for the tasks are:
evaluation.response_rating(single turn)evaluation.response_rating.with_referenceevaluation.response_selectionorevaluation.response_preferenceetcalso in the task fields i would change
model_answertoresponseThe reason is to make sure it is general enough to systems which are not only just model. As well as having the task name fit to other tasks in the unitxt taxonomy. "evaluation" i think is the core task here, which is to evaluate responses esentially.
I think "evaluation" (and the other names you proposed) are not very descriptive (evaluation of what?). In the end the number one job of the "task name" is to be descriptive so people can easily understand what it means and to find it if they need to. And even that is not ideally, as people will look for "llm_as_judge" probably. response_evaluation might be better. Also I don't think we should nest things too much (i.e. response_rating.with_reference), unless we need to because we have too many stuff in a dir. It's messy and imo not comfortable to work with or view.
@OfirArviv can you use this operator: https://github.com/IBM/unitxt/pull/813#pullrequestreview-2047817508 once merged?
Regarding naming, I think the right naming for the tasks are:
evaluation.response_rating(single turn)evaluation.response_rating.with_referenceevaluation.response_selectionorevaluation.response_preferenceetc also in the task fields i would changemodel_answertoresponseThe reason is to make sure it is general enough to systems which are not only just model. As well as having the task name fit to other tasks in the unitxt taxonomy. "evaluation" i think is the core task here, which is to evaluate responses esentially.I think "evaluation" (and the other names you proposed) are not very descriptive (evaluation of what?). In the end the number one job of the "task name" is to be descriptive so people can easily understand what it means and to find it if they need to. And even that is not ideally, as people will look for "llm_as_judge" probably. response_evaluation might be better. Also I don't think we should nest things too much (i.e. response_rating.with_reference), unless we need to because we have too many stuff in a dir. It's messy and imo not comfortable to work with or view.
We decided on:
--Task-- response_assessment.pairwise_comparison response_assessment.rating
pairwise_comparison rating
--Cards-- mt_bench.pairwise_comparison mt_bench.rating
--Template-- response_assessment.pairwise_comparison response_assessment.rating
pairwise_comparison.model rating.model_outputs
@OfirArviv - Overall loogs good to me, but tests seem to fail.
- AssertionError: Error while trying to run IbmGenAiInferenceEngine. Please set the environment param 'GENAI_KEY'.
We should not set an API in the CI/CD environment, but we can set a dummy key, just so the 'prepare' will pass.
024-05-12T19:32:30.4173530Z File "/home/runner/work/unitxt/unitxt/prepare/metrics/llm_as_judge/rating/llama_3_ibm_genai_mt_bench_template.py", line 29, in
-
Unitest fail with ERROR: Could not find a version that satisfies the requirement ibm-generative-ai (from versions: none) ERROR: No matching distribution found for ibm-generative-ai
-
Also, you can not have the mt bench LoadHF link to local file and have the test pass.
@yoavkatz I updated the catalog test pyhon to 3.9, as bam require this as a minimum. I kept the 3.8 for the core unitxt test so we ca still claim it support python 3.8
@yoavkatz I updated the catalog test pyhon to 3.9, as bam require this as a minimum. I kept the 3.8 for the core unitxt test so we ca still claim it support python 3.8
@yoavkatz the main test still run - run: pip install -r requirements/tests.rqr which contain ibm_genai. But we could so is
- update unitxt entirely to 3.9
- split the catalog tests requirements from the rest of the tests requirements
Codecov Report
Attention: Patch coverage is 64.55026% with 67 lines in your changes are missing coverage. Please review.
Project coverage is 91.65%. Comparing base (
4064804) to head (c40166d).
:exclamation: Current head c40166d differs from pull request most recent head 109d501
Please upload reports for the commit 109d501 to get more accurate results.
| Files | Patch % | Lines |
|---|---|---|
| src/unitxt/templates.py | 39.18% | 45 Missing :warning: |
| src/unitxt/operators.py | 33.33% | 14 Missing :warning: |
| src/unitxt/llm_as_judge.py | 83.72% | 7 Missing :warning: |
| src/unitxt/inference.py | 93.33% | 1 Missing :warning: |
Additional details and impacted files
@@ Coverage Diff @@
## main #791 +/- ##
==========================================
- Coverage 92.06% 91.65% -0.41%
==========================================
Files 104 104
Lines 10738 10871 +133
==========================================
+ Hits 9886 9964 +78
- Misses 852 907 +55
:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.