Skip to content

Commit

Permalink
ragas: bump ragas version, pass old rubric in RubricScore
Browse files Browse the repository at this point in the history
Before ragas v0.2.11 RubricScores.rubrics wasn't
being applied properly. This commit sets that
as the minimum version for this library.

A change in v0.2.11 from previous versions was a
change in the prompt for domain specific knowledge
evaluation with reference. The prompt from previous
versions is now explicitly passed in.

Signed-off-by: Ali Maredia <[email protected]>
  • Loading branch information
alimaredia committed Jan 17, 2025
1 parent 03afb6c commit 46b86fd
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ pandas
pandas-stubs
lm-eval>=0.4.4
httpx
ragas
ragas>=0.2.11
13 changes: 10 additions & 3 deletions src/instructlab/eval/ragas.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
from ragas.evaluation import EvaluationDataset, EvaluationResult, RunConfig, evaluate
from ragas.metrics import Metric
from ragas.metrics._domain_specific_rubrics import ( # the rubrics we must instantiate are located inside of a file marked as private

Check warning on line 14 in src/instructlab/eval/ragas.py

View workflow job for this annotation

GitHub Actions / pylint

W0611: Unused SingleTurnPrompt imported from ragas.metrics._domain_specific_rubrics (unused-import)
DEFAULT_WITH_REFERENCE_RUBRICS,
RubricsScore,
SingleTurnPrompt,
)

# Local
Expand All @@ -22,6 +22,14 @@

logger = setup_logger(__name__)

OLD_DEFAULT_WITH_REFERENCE_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.",
}


class Sample(TypedDict):
"""
Expand Down Expand Up @@ -256,9 +264,8 @@ def _generate_answers_from_model(

@staticmethod
def _get_metrics() -> List[Metric]:
# default set of metrics
return [
RubricsScore(
rubrics=DEFAULT_WITH_REFERENCE_RUBRICS,
rubrics=OLD_DEFAULT_WITH_REFERENCE_RUBRICS,
)
]

0 comments on commit 46b86fd

Please sign in to comment.