Skip to content

About

Model-agnostic toolkit to evaluate text-summarization models — ROUGE/BLEU/BERTScore + perplexity + LLM-as-judge, MLflow tracking, CLI + library with unit-tested metrics.

Topics

Resources

Stars

1 star

Watchers

0 watching

Forks

Latest commit

 

History

4 Commits

Folders and files

Repository files navigation

summarization-eval-toolkit

A model-agnostic toolkit for evaluating text-summarization models. It generates summaries with any Hugging Face seq2seq model, scores them with a suite of complementary metrics, reference-based lexical (ROUGE, BLEU), reference-based semantic (BERTScore), reference-free fluency (perplexity), and an LLM-as-judge, and logs everything to MLflow. It can also (optionally) fine-tune a T5/BART model on a summarization dataset. Usable as a CLI and as an importable library.


Architecture

architecture

Interactive/exportable version: docs/assets/architecture.html.

The problem: how do you know a summarizer is good?

"Good summary" is not one thing. A summary can have high word overlap with the reference yet hallucinate a fact; it can paraphrase perfectly yet share almost no words with the reference; it can be fluent but irrelevant. No single number captures all of this, so this toolkit reports several signals that each measure a different failure mode, and lets you compare them.

The metric suite (what each one actually captures)

Metric Type Measures Blind spot
ROUGE-1 reference, lexical unigram overlap, did the right content words appear? rewards copying; ignores meaning
ROUGE-2 reference, lexical bigram overlap, local phrasing very sparse on short summaries
ROUGE-L reference, lexical longest common subsequence, sentence-level structure still surface-level
BLEU reference, lexical n-gram precision + brevity penalty precision-oriented, harsh on paraphrase
BERTScore reference, semantic contextual-embedding similarity, same meaning, different words needs a transformer; can't catch hallucination vs. source
Perplexity reference-free, fluency how predictable/fluent the summary is under a causal LM fluent nonsense still scores well
LLM-as-judge reference-free, qualitative coherence / faithfulness / relevance, rated 1-5 judge bias, cost, non-determinism

ROUGE vs. BERTScore vs. LLM-judge is the key axis:

  • ROUGE/BLEU ask "did you use the same words as the reference?", cheap, deterministic, reproducible, but they punish a correct summary that simply worded things differently.
  • BERTScore asks "do you mean the same thing as the reference?", robust to paraphrase, but it is still tied to a single gold reference and cannot tell you whether the summary is faithful to the source document.
  • The LLM judge asks "is this a good summary of the document?", it reads the source, so it can reward a good summary the reference-metrics undervalue and can flag a high-overlap summary that hallucinates (faithfulness). The cost is that the judge itself is a model with its own biases and variance.

Reporting all three is the point: when they agree you can trust the verdict, and when they disagree (common, see examples/sample_eval.md) the disagreement is itself the finding.

Architecture

config.yaml ──▶ sumeval.cli ──▶ sumeval.evaluate.evaluate_model
                                        │
   data.py  ─ load HF dataset ──────────┤  (document, reference) pairs
   generate.py ─ load model, batch-gen ─┤  summaries
   metrics.py ─ ROUGE/BLEU/BERTScore ───┤  reference metrics
              ─ perplexity (causal LM) ─┤  fluency
   judge.py ─ LLM rates 1-5, parse ─────┤  coherence/faithfulness/relevance
                                        ▼
                          aggregate ─▶ MLflow (params + metrics)

train.py ─ optional Seq2SeqTrainer fine-tune ─▶ outputs/  (point model_id here)

Every component is model-agnostic: model ids, dataset, judge, and metric toggles all come from config.yaml, nothing is hardcoded to one checkpoint. The T5 "summarize: " task prefix is the only checkpoint-specific quirk and it is auto-applied for T5-style ids (and overridable).

Installation

python -m venv .venv && source .venv/bin/activate
pip install -r requirements.txt

For just the lexical-metric unit tests you only need the light deps: pip install rouge_score sacrebleu pytest pyyaml.

CLI usage

# Full evaluation driven by config.yaml
python -m sumeval.cli evaluate --config config.yaml

# Override on the fly; cheap CPU lexical-only run
python -m sumeval.cli evaluate --config config.yaml \
    --model-id t5-small --num-samples 20 \
    --no-judge --no-bertscore --no-perplexity \
    --out results/run.json

# Different model / dataset entirely (model-agnostic)
python -m sumeval.cli evaluate --config config.yaml \
    --model-id facebook/bart-large-cnn --dataset xsum

python -m sumeval.cli evaluate -h lists every flag.

Library usage

from sumeval.evaluate import evaluate_model
from sumeval.metrics import compute_reference_metrics

# one-shot pipeline
results = evaluate_model({"model_id": "sshleifer/distilbart-cnn-12-6",
                          "data": {"num_samples": 20}})
print(results["metrics"])

# or use metrics directly on your own predictions/references
m = compute_reference_metrics(predictions, references, include_bertscore=True)

Configuration (config.yaml)

Key options (full file is documented inline):

  • model_id, any HF seq2seq id or local fine-tuned directory.
  • data.*, dataset name/config/split, num_samples, optional explicit document_column / summary_column (auto-detected otherwise).
  • generation.*, beam search, input/summary lengths, task_prefix.
  • metrics.*, toggle rouge_bleu, bertscore, perplexity independently; pick the perplexity LM.
  • judge.*, judge model_id, temperature (0 = deterministic), scale_max.
  • mlflow.*, tracking_uri, experiment_name, run_name.

MLflow tracking

evaluate_model flattens the config into MLflow params and logs every metric:

mlflow ui --backend-store-uri ./mlruns

Compare runs (e.g. base vs. fine-tuned, or model A vs. model B) side by side. NaN/ inf metrics are skipped so a partial run still logs cleanly.

Optional fine-tuning

train.py wraps Seq2SeqTrainer to fine-tune any seq2seq checkpoint, then you point model_id at the output directory to evaluate it:

python -m sumeval.cli train --config config.yaml \
    --model-id t5-small --epochs 3 --output-dir outputs/ft
python -m sumeval.cli evaluate --config config.yaml --model-id outputs/ft

Limitations (honest)

  • Compute. A full pass over CNN/DailyMail with BERTScore + an LLM judge downloads several GB of models and is GPU-bound. This was not executed in this repo, only the lightweight metric unit tests run here (pytest). The numbers in examples/sample_eval.md are illustrative, in the expected output format, not a measured run.
  • Single reference. ROUGE/BLEU/BERTScore compare against one gold summary; CNN/DailyMail "highlights" are extractive-leaning, which biases lexical metrics.
  • Judge is a model. The LLM judge has its own biases/variance and can be gamed; temperature: 0 improves reproducibility but does not remove bias. Treat judge scores as one signal, not ground truth.
  • Perplexity ≠ quality. Fluent-but-wrong text scores well; it is a fluency check, not a correctness check.
  • BLEU was designed for translation; it is reported for completeness but ROUGE is the standard for summarization.

Tech stack

transformers · datasets · evaluate · rouge_score · bert-score · sacrebleu · mlflow · torch · PyYAML · pytest.

Origin

The metric/judge/MLflow logic was extracted and rewritten from a LUMS Large Language Models course lab (fine-tuning T5/BART on CNN/DailyMail; ROUGE/BLEU/ BERTScore/perplexity + an LLM-as-judge + MLflow + SOTA comparison). This repo generalizes that notebook into a reusable, model-agnostic library + CLI.

About

Model-agnostic toolkit to evaluate text-summarization models — ROUGE/BLEU/BERTScore + perplexity + LLM-as-judge, MLflow tracking, CLI + library with unit-tested metrics.

Topics

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages