Implementation:Explodinggradients Ragas RougeScore Metric
| Field | Value |
|---|---|
| source | Repo |
| domains | Metrics, NLP |
| last_updated | 2026-02-10 |
Overview
RougeScore computes ROUGE (Recall-Oriented Understudy for Gisting Evaluation) n-gram overlap scores between a reference and a generated response using the rouge-score library.
Description
The RougeScore class evaluates text generation quality by computing ROUGE scores, which measure n-gram overlap between a reference and response text. It supports two ROUGE variants (rouge1 for unigrams and rougeL for longest common subsequence) and three scoring modes (fmeasure, precision, recall). The metric uses stemming for improved matching. It does not require an LLM and inherits only from SingleTurnMetric.
Key attributes:
- rouge_type -- The type of ROUGE score:
"rouge1"or"rougeL"(default"rougeL"). - mode -- The scoring mode:
"fmeasure"(default),"precision", or"recall".
Dependency: Requires the rouge-score package (pip install rouge-score).
Usage
The metric requires reference and response columns.
Code Reference
| Property | Value |
|---|---|
| Source Location | src/ragas/metrics/_rouge_score.py L11-43
|
| Class Signature | class RougeScore(SingleTurnMetric)
|
| Import | from ragas.metrics import RougeScore
|
I/O Contract
Inputs
| Parameter | Type | Required | Description |
|---|---|---|---|
| reference | str | Yes | The ground truth reference text |
| response | str | Yes | The generated response to evaluate |
Outputs
| Output | Type | Description |
|---|---|---|
| score | float | ROUGE score (0.0 to 1.0) based on the selected type and mode |
Usage Examples
from ragas.metrics import RougeScore
from ragas.dataset_schema import SingleTurnSample
metric = RougeScore(rouge_type="rougeL", mode="fmeasure")
sample = SingleTurnSample(
reference="The cat sat on the mat.",
response="The cat is sitting on the mat."
)
# score = await metric.single_turn_ascore(sample)
Related Pages
- Explodinggradients_Ragas_BleuScore_Metric -- BLEU-based n-gram precision metric
- Explodinggradients_Ragas_ChrfScore_Metric -- Character n-gram F-score metric
- Explodinggradients_Ragas_StringMetrics_Module -- Non-LLM string comparison metrics