πŸ€– AI/ML

ROUGE

Recall-Oriented Understudy for Gisting Evaluation

A family of metrics for measuring summary quality. ROUGE-1, ROUGE-L, and others.

πŸ“– Detailed Explanation

ROUGE (Recall-Oriented Understudy for Gisting Evaluation) is a family of metrics that automatically evaluate the quality of text summaries. It calculates scores by measuring n-gram overlap between a generated summary and a reference summary, and it has several variants such as ROUGE-1, ROUGE-2, and ROUGE-L.

ROUGE was developed by Chin-Yew Lin at USC in 2004 and was originally designed to evaluate document summarization systems. While BLEU focuses on precision in machine translation, ROUGE emphasizes recall, which makes it better suited to evaluating summaries.

The core principle of ROUGE is n-gram matching. ROUGE-1 measures word (unigram) overlap, and ROUGE-2 measures overlap of two consecutive words (bigrams). ROUGE-L uses the longest common subsequence (LCS) to calculate similarity that takes word order into account. In general, the F1 score (the harmonic mean of precision and recall) is used as the final metric.

In practice, ROUGE is a standard evaluation metric for NLG tasks such as summarization, question answering, and dialogue generation. However, it has a limitation in that it cannot fully capture semantic similarity, so there is a trend of using it together with embedding-based metrics such as BERTScore and BLEURT. In the LLM era, GPT-4-based evaluation is also used in parallel.

πŸ’» Code Example

This is an example of calculating ROUGE scores using the rouge-score library.

# pip install rouge-score
from rouge_score import rouge_scorer

# ROUGE Scorer μ΄ˆκΈ°ν™”
scorer = rouge_scorer.RougeScorer(['rouge1', 'rouge2', 'rougeL'], use_stemmer=True)

# μ°Έμ‘° μš”μ•½ (μ •λ‹΅)
reference = "인곡지λŠ₯은 기계가 μΈκ°„μ²˜λŸΌ ν•™μŠ΅ν•˜κ³  νŒλ‹¨ν•˜λŠ” κΈ°μˆ μž…λ‹ˆλ‹€."

# μƒμ„±λœ μš”μ•½ (λͺ¨λΈ 좜λ ₯)
candidate = "AIλŠ” 기계가 ν•™μŠ΅ν•˜κ³  μΆ”λ‘ ν•˜λŠ” κΈ°μˆ μž…λ‹ˆλ‹€."

# ROUGE 점수 계산
scores = scorer.score(reference, candidate)

print("=== ROUGE Scores ===")
for metric, score in scores.items():
    print(f"{metric}:")
    print(f"  Precision: {score.precision:.4f}")
    print(f"  Recall:    {score.recall:.4f}")
    print(f"  F1:        {score.fmeasure:.4f}")

# μ—¬λŸ¬ μƒ˜ν”Œμ˜ 평균 계산
def calculate_avg_rouge(references, candidates):
    """μ—¬λŸ¬ μƒ˜ν”Œμ˜ 평균 ROUGE 점수 계산"""
    total_scores = {'rouge1': 0, 'rouge2': 0, 'rougeL': 0}
    for ref, cand in zip(references, candidates):
        scores = scorer.score(ref, cand)
        for metric in total_scores:
            total_scores[metric] += scores[metric].fmeasure
    return {k: v / len(references) for k, v in total_scores.items()}

πŸ—£οΈ Say It Like This in Practice

πŸ’¬ In a Meeting
"The summarization model's performance is 0.45 in terms of ROUGE-L F1. It means there is about 45% word overlap with the reference summary."
πŸ’¬ In an Interview
"ROUGE-1 measures similarity at the word level, and ROUGE-2 measures it at the phrase level. ROUGE-L is better suited to abstractive summarization."
πŸ’¬ In a Technical Discussion
"ROUGE alone makes it hard to evaluate semantic similarity. It's best to use it together with BERTScore, or to run LLM-based evaluation alongside it."

Take a mock interview on this topic β†’ WIA SOOM AI Interview Β· Start for free

⚠️ Common Mistakes & Cautions

❌
Judging quality by ROUGE alone: ROUGE measures only surface-level word overlap. Even if the meaning is the same, different wording results in a lower score.
❌
Not using a stemmer: For English, you need to apply stemming with use_stemmer=True for a fair comparison. For Korean, morphological analysis preprocessing is required.
βœ…
Using multiple metrics: Using ROUGE + BERTScore + Human Evaluation together enables a more reliable evaluation.

πŸ”— Related Terms

πŸ“š Learn More