Skip to content
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

Bump ragas version #212

Merged
merged 1 commit into from
Jan 18, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
18 changes: 12 additions & 6 deletions src/instructlab/eval/ragas.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,24 @@
from pydantic import BaseModel, ConfigDict, Field
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
DEFAULT_WITH_REFERENCE_RUBRICS,
RubricsScore,
)
from ragas.metrics._domain_specific_rubrics import RubricsScore

# Local
from .evaluator import Evaluator
from .logger_config import setup_logger

logger = setup_logger(__name__)

# DEFAULT_WITH_REFERENCE_RUBRICS from ragas v0.2.11.
# This rubric is hardcoded in case ragas makes any changes to their DEFAULT_WITH_REFERENCE_RUBRICS in the future
SCORING_RUBRICS = {
"score1_description": "The response is entirely incorrect, irrelevant, or does not align with the reference in any meaningful way.",
"score2_description": "The response partially matches the reference but contains major errors, significant omissions, or irrelevant information.",
"score3_description": "The response aligns with the reference overall but lacks sufficient detail, clarity, or contains minor inaccuracies.",
"score4_description": "The response is mostly accurate, aligns closely with the reference, and contains only minor issues or omissions.",
"score5_description": "The response is fully accurate, completely aligns with the reference, and is clear, thorough, and detailed.",
}


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

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