Skip to main content

rougers

CI PyPI Crates.io License

ROUGE metrics in Rust, with scores identical to Google's rouge-score. On CNN/DailyMail, XSum and PubMed test samples it scores 30–80 times faster on one core and 80–350 times faster with all eight cores of an M1 Pro (benchmarks).

rouge-score is the ROUGE implementation behind Hugging Face evaluate and many summarization and LLM evaluation pipelines. It is written in pure Python, so scoring large sets of outputs, or scoring repeatedly, takes noticeable time. rougers reproduces it exactly, down to the last bit of every float, including the tokenizer, NLTK's Porter stemmer and the summary-level rougeLsum.

The Rust crate is rougers; the Python package built on it is rouge-score-rs. This is an independent project, not affiliated with Google or the authors of rouge-score.

Python

pip install rouge-score-rs

Change the import and keep the rest of your code:

from rouge_score_rs import rouge_scorer  # was: from rouge_score import rouge_scorer

scorer = rouge_scorer.RougeScorer(["rouge1", "rouge2", "rougeL", "rougeLsum"], use_stemmer=True)
scores = scorer.score(
    "The quick brown fox jumps over the lazy dog",
    "The quick brown dog jumps on the log.",
)
scores["rouge1"]
# Score(precision=0.75, recall=0.6666666666666666, fmeasure=0.7058823529411765)

score_multi, custom tokenizers, split_summaries, scoring.BootstrapAggregator and tokenize.tokenize work the same way as in rouge-score, and scorers can be pickled for use in worker processes.

To score many pairs, use score_batch. With the default tokenizer it runs on all CPU cores and releases the GIL:

results = scorer.score_batch(references, predictions)  # list of dicts, one per pair

Set RAYON_NUM_THREADS to limit the number of threads. With a custom tokenizer or split_summaries=True, and in a process forked after a parallel call, pairs are scored one by one. The built-in tokenizers described below also run in parallel.

Other languages

The default tokenizer is the one from rouge-score: it keeps only the ASCII letters a–z and digits, so Russian, Arabic, Hindi or Chinese text scores zero. Two opt-in tokenizers cover other languages and run natively, including in score_batch:

from rouge_score_rs import rouge_scorer, tokenizers

scorer = rouge_scorer.RougeScorer(["rouge1", "rougeL"], tokenizer=tokenizers.UnicodeTokenizer())
scorer.score("Правительство объявило новые меры.", "Объявлены новые меры правительства.")

chinese = rouge_scorer.RougeScorer(["rouge1", "rougeL"], tokenizer=tokenizers.CharacterTokenizer())
chinese.score("今天天气很好", "今天天气不错")
Tokenizer Profile Tokens
DefaultTokenizer rouge-score runs of [a-z0-9] after lowercasing; optional Porter stemming
UnicodeTokenizer unicode-v1 words by the Unicode word boundary rules (UAX #29) that contain an alphabetic character or a number
CharacterTokenizer character-v1 grapheme clusters that contain an alphabetic character or a number

Both profiles first normalize the text: NFKC, full Unicode case folding, then NFKC again, so Straße, STRASSE and strasse give the same token.

UnicodeTokenizer suits languages that separate words with spaces. It makes each Chinese or Japanese ideograph a separate token and does not split Thai, Lao, Khmer or Burmese into words; for those, pass your own tokenizer. CharacterTokenizer gives character-level ROUGE, a common choice for Chinese. Neither stems. Scores from these profiles are not comparable with rouge-score defaults or with other tokenization schemes, so report the profile name with your results. The profiles use Unicode 17.0 data from pinned dependencies, so their output does not depend on the platform or the Rust version, and a profile's behaviour will not change under the same name.

Hugging Face Evaluate

The SyntaxSpirits/rouge metric has the same inputs, options and scores as Evaluate's built-in rouge metric and computes them with this package:

import evaluate

rouge = evaluate.load("SyntaxSpirits/rouge")  # was: evaluate.load("rouge")
results = rouge.compute(predictions=predictions, references=references)

It needs pip install evaluate 'rouge-score-rs[aggregate]>=0.1.1'.

Rust

[dependencies]
rougers = "0.2"
use rougers::{RougeScorer, RougeType};

let scorer = RougeScorer::new(["rouge1", "rougeL"], true)?;
let scores = scorer.score(
    "The quick brown fox jumps over the lazy dog",
    "The quick brown dog jumps on the log.",
);
let rouge_l = scores.get(RougeType::L).unwrap();
println!("{:.4}", rouge_l.fmeasure);

RougeScorer is Send + Sync, so it can be shared across threads, for example with Rayon.

Performance

The benchmark uses fixed samples from the CNN/DailyMail, XSum and PubMed test sets with lead-sentence predictions. It checks score parity, measures serial and parallel scoring with and without stemming, and includes Hugging Face Evaluate's default bootstrap aggregation.

See BENCHMARKS.md for measured results, pinned data sources, package comparisons and reproduction commands. Speedups depend on summary length, requested metrics, stemming and thread count; timings for packages computing different scores are reported separately.

Compatibility

The test suite compares rouge-score-rs with rouge-score and fails on any difference in any float:

  • the stemmer against NLTK on all 235,976 words of a system dictionary (NLTK 3.8–3.10 stem them identically);
  • tokenization against Python's str.lower for every Unicode code point;
  • thousands of random texts with repeated words, punctuation, digits, newlines and non-Latin scripts, plus property-based tests on arbitrary Unicode;
  • score_multi, custom tokenizers, split_summaries and bootstrap aggregation with a fixed NumPy seed.

Known differences:

  • An invalid ROUGE type raises ValueError when the scorer is created, not on the first call to score. Type names must be exactly rouge1…rouge9, rougeL or rougeLsum.
  • Texts must be str; rouge-score also accepts UTF-8 bytes.
  • BootstrapAggregator needs NumPy (pip install 'rouge-score-rs[aggregate]') and split_summaries=True needs NLTK (pip install 'rouge-score-rs[sentences]'). Without them, rouge-score-rs has no Python dependencies.

Development

cargo test -p rougers
cd bindings/python
uv sync --group dev
uv run pytest

License

Apache-2.0, the same licence as rouge-score and NLTK, whose scoring, tokenization and stemming logic this project ports. See NOTICE.

Metadata

Release files for rouge-score-rs 0.2.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for rouge-score-rs 0.2.1
File Size Uploaded
rouge_score_rs-0.2.1.tar.gz 153.2 kB Details

Built distributions (wheels)

Table of built distributions (wheels) for rouge-score-rs 0.2.1
File
rouge_score_rs-0.2.1-cp39-abi3-win_amd64.whl CPython 3.9 abi3 Windows x86-64 Details
rouge_score_rs-0.2.1-cp39-abi3-musllinux_1_2_x86_64.whl CPython 3.9 abi3 Linux musl 1.2+ x86-64 Details
rouge_score_rs-0.2.1-cp39-abi3-musllinux_1_2_aarch64.whl CPython 3.9 abi3 Linux musl 1.2+ ARM64 Details
rouge_score_rs-0.2.1-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl CPython 3.9 abi3 Linux glibc 2.17+ x86-64 Details
rouge_score_rs-0.2.1-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl CPython 3.9 abi3 Linux glibc 2.17+ ARM64 Details
rouge_score_rs-0.2.1-cp39-abi3-macosx_11_0_arm64.whl CPython 3.9 abi3 macOS 11.0+ ARM64 Details
rouge_score_rs-0.2.1-cp39-abi3-macosx_10_12_x86_64.whl CPython 3.9 abi3 macOS 10.12+ x86-64 Details

Total release size: 3.7 MB

Release files / rouge_score_rs-0.2.1.tar.gz

Download URL rouge_score_rs-0.2.1.tar.gz
Size 153.2 kB
Tags Source
SHA-256 checksum
How to use checksums
69c6a3bc0f89b1aa90e27a2874f56ad27bd5823b2b98eac3eb9b0ca2c1d968b4
BLAKE2b-256 checksum
How to use checksums
416b0a211652826275f63d4fe1544bf8d70eed17f9caebf56c1a6418b4fad556
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 11, 2026.

Transparency log

Release files / rouge_score_rs-0.2.1-cp39-abi3-win_amd64.whl

Download URL rouge_score_rs-0.2.1-cp39-abi3-win_amd64.whl
Size 340.9 kB
Tags CPython 3.9 Windows x86-64 abi3
SHA-256 checksum
How to use checksums
b39418bfdfd54b36d038988953864ac4ff6399bbe0216e35bef46a0688e8c417
BLAKE2b-256 checksum
How to use checksums
314a9a0ff480f09a97d33f1166a484a1dd5e5f402fa77192a33e8254ff7a65bb
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 11, 2026.

Transparency log

Release files / rouge_score_rs-0.2.1-cp39-abi3-musllinux_1_2_x86_64.whl

Download URL rouge_score_rs-0.2.1-cp39-abi3-musllinux_1_2_x86_64.whl
Size 693.4 kB
Tags CPython 3.9 Linux musl 1.2+ x86-64 abi3
SHA-256 checksum
How to use checksums
e40dfce3f96a7624a0dc4de658c1735a12b2305dfd6e4deb4437cea2758420be
BLAKE2b-256 checksum
How to use checksums
57bb8a341cf1ae39b3c709146294b5901fc548ba89b4d101c7fbb54ef405a4f5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 11, 2026.

Transparency log

Release files / rouge_score_rs-0.2.1-cp39-abi3-musllinux_1_2_aarch64.whl

Download URL rouge_score_rs-0.2.1-cp39-abi3-musllinux_1_2_aarch64.whl
Size 656.6 kB
Tags CPython 3.9 Linux musl 1.2+ ARM64 abi3
SHA-256 checksum
How to use checksums
1f6258c12e74d0c8b8c5462b3039ea8f2907823bca60f1310ce34c07453b8bca
BLAKE2b-256 checksum
How to use checksums
7c3a705412b09e262437c0e24c0a0ff6ef0d05e5a5d31cf1cf0f7a1c7cdb1d02
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 11, 2026.

Transparency log

Release files / rouge_score_rs-0.2.1-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl

Download URL rouge_score_rs-0.2.1-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Size 480.1 kB
Tags CPython 3.9 Linux glibc 2.17+ x86-64 abi3
SHA-256 checksum
How to use checksums
4e51ba048aa88a3d661f5b0ea1fd126ddf863ff3763af9626a850fd90ea83339
BLAKE2b-256 checksum
How to use checksums
a4d73aaf98dbb22ae469af06990c019a6b94c3b8c11a4887b181ed0c836e6c9d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 11, 2026.

Transparency log

Release files / rouge_score_rs-0.2.1-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl

Download URL rouge_score_rs-0.2.1-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Size 478.9 kB
Tags CPython 3.9 Linux glibc 2.17+ ARM64 abi3
SHA-256 checksum
How to use checksums
d0bab75591ded83d0a300bbd6f51e2c735aa04278b020d9279a9c25b717b51cf
BLAKE2b-256 checksum
How to use checksums
d7381ef019f1be88881ee3027229730876d7b7a220ef42a23b64886399781cc4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 11, 2026.

Transparency log

Release files / rouge_score_rs-0.2.1-cp39-abi3-macosx_11_0_arm64.whl

Download URL rouge_score_rs-0.2.1-cp39-abi3-macosx_11_0_arm64.whl
Size 437.6 kB
Tags CPython 3.9 abi3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
1e09f2e2886af26a5d752846ac13335f97e840b6f3bad01f02f260c649b26581
BLAKE2b-256 checksum
How to use checksums
1d48bcf770bdce9c231cf08c93a2f4431826d69292ac8de7fd31e6e234db2117
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 11, 2026.

Transparency log

Release files / rouge_score_rs-0.2.1-cp39-abi3-macosx_10_12_x86_64.whl

Download URL rouge_score_rs-0.2.1-cp39-abi3-macosx_10_12_x86_64.whl
Size 439.4 kB
Tags CPython 3.9 abi3 macOS 10.12+ x86-64
SHA-256 checksum
How to use checksums
ae8476f8061c4ff54fa0e2bc0759646e848e57d85f612c1971f751581293a252
BLAKE2b-256 checksum
How to use checksums
35614d7938202358a4c098917bc2fcd63d99389d79c771777cef87c651ab63a9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 11, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

0.2.1 This release

8 release files

0.2.0

8 release files

0.1.1

8 release files

0.1.0

8 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page