You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
chore: move rubrics based metric into single file (#1287)
```python
from ragas.dataset_schema import SingleTurnSample
from ragas.metrics._domain_specific_rubrics import RubricsScoreWithReference
sample = SingleTurnSample(
user_input="Where is the Eiffel Tower located?",
response="The Eiffel Tower is located in Paris.",
reference="The Eiffel Tower is located in Paris.",
)
rubrics = {
"score1_description": "The response is incorrect, irrelevant, or does not align with the ground truth.",
"score2_description": "The response partially matches the ground truth but includes significant errors, omissions, or irrelevant information.",
"score3_description": "The response generally aligns with the ground truth but may lack detail, clarity, or have minor inaccuracies.",
"score4_description": "The response is mostly accurate and aligns well with the ground truth, with only minor issues or missing details.",
"score5_description": "The response is fully accurate, aligns completely with the ground truth, and is clear and detailed.",
}
scorer = RubricsScoreWithReference(rubrics=rubrics)
scorer.llm = openai_model
await scorer.single_turn_ascore(sample)
```
---------
Co-authored-by: Jithin James <[email protected]>
instruction="""Given an user_input (which might contain an input along with it), a response to evaluate, and a score rubric representing evaluation criteria are given.
61
+
1. Write detailed feedback that assesses the quality of the response strictly based on the given score rubric, without evaluating in general.
62
+
2. After writing the feedback, assign a score between 1 and 5, referring to the score rubric."""
63
+
input_model=SingleTurnWithoutReferenceInput
64
+
output_model=ScoreFeedback
65
+
examples= [
66
+
(
67
+
SingleTurnWithoutReferenceInput(
68
+
user_input="What is the capital of France?",
69
+
response="The capital of France is Paris.",
70
+
rubrics=DEFAULT_REFERENCE_FREE_RUBRICS,
71
+
),
72
+
ScoreFeedback(
73
+
feedback="The response is completely accurate and directly answers the question about the capital of France.",
instruction="""Given an interaction between AI,Human and external Tool as input and reference that's desired outcome that get's a score of 5,and a score rubric representing evaluation criteria are given.
84
+
1. Write detailed feedback that assesses the quality of the responselet strictly based on the given score rubric, without evaluating in general.
85
+
2. After writing the feedback, assign a score between 1 and 5, referring to the score rubric."""
86
+
input_model=MultiTurnWithoutReferenceInput
87
+
output_model=ScoreFeedback
88
+
examples= [
89
+
(
90
+
MultiTurnWithoutReferenceInput(
91
+
user_input="""Human: Hey, book a table at the nearest best Chinese restaurant for 8:00pm\nAI: Sure, let me find the best options for you.\nTools:\n restaurant_search: {'cuisine': 'Chinese', 'time': '8:00pm'}\nToolOutput: Found a few options: 1. Golden Dragon, 2. Jade Palace\nAI: I found some great options: Golden Dragon and Jade Palace. Which one would you prefer?\nHuman: Let's go with Golden Dragon.\nAI: Great choice! I'll book a table for 8:00pm at Golden Dragon.\nTools:\n restaurant_book: {'name': 'Golden Dragon', 'time': '8:00pm'}\nToolOutput: Table booked at Golden Dragon for 8:00pm.\nAI: Your table at Golden Dragon is booked for 8:00pm. Enjoy your meal!\nHuman: thanks""",
instruction="""Given an interaction between AI,Human and external Tool as input and reference that's desired outcome that get's a score of 5,and a score rubric representing evaluation criteria are given.
55
-
1. Write detailed feedback that assesses the quality of the responselet strictly based on the given score rubric, without evaluating in general.
188
+
instruction="""Given user input, response and reference that's desired outcome that get's a score of 5,and a score rubric representing evaluation criteria are given.
189
+
1. Write detailed feedback that assesses the quality of the response strictly based on the given score rubric, without evaluating in general.
56
190
2. After writing the feedback, assign a score between 1 and 5, referring to the score rubric."""
57
-
input_model=SingleTurnWithRefernceInput
191
+
input_model=SingleTurnWithReferenceInput
58
192
output_model=ScoreFeedback
59
193
examples= [
60
194
(
61
-
SingleTurnWithRefernceInput(
195
+
SingleTurnWithReferenceInput(
62
196
user_input="What is the capital of France?",
63
197
response="The capital of France is Paris.",
64
198
reference="The capital of France is Paris.",
@@ -73,16 +207,16 @@ class SingleTurnWithReferencePrompt(
instruction="""Given an interaction between AI,Human and external Tool as input and reference that's desired outcome that get's a score of 5,and a score rubric representing evaluation criteria are given.
79
213
1. Write detailed feedback that assesses the quality of the responselet strictly based on the given score rubric, without evaluating in general.
80
214
2. After writing the feedback, assign a score between 1 and 5, referring to the score rubric."""
81
-
input_model=MultiTurnWithRefernceInput
215
+
input_model=MultiTurnWithReferenceInput
82
216
output_model=ScoreFeedback
83
217
examples= [
84
218
(
85
-
MultiTurnWithRefernceInput(
219
+
MultiTurnWithReferenceInput(
86
220
user_input="""Human: Hey, book a table at the nearest best Chinese restaurant for 8:00pm\nAI: Sure, let me find the best options for you.\nTools:\n restaurant_search: {'cuisine': 'Chinese', 'time': '8:00pm'}\nToolOutput: Found a few options: 1. Golden Dragon, 2. Jade Palace\nAI: I found some great options: Golden Dragon and Jade Palace. Which one would you prefer?\nHuman: Let's go with Golden Dragon.\nAI: Great choice! I'll book a table for 8:00pm at Golden Dragon.\nTools:\n restaurant_book: {'name': 'Golden Dragon', 'time': '8:00pm'}\nToolOutput: Table booked at Golden Dragon for 8:00pm.\nAI: Your table at Golden Dragon is booked for 8:00pm. Enjoy your meal!\nHuman: thanks""",
87
221
reference="The AI successfully books a table at the nearest best Chinese restaurant for 8:00pm, providing the user with options and confirming the booking.",
0 commit comments