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.

Memory for rougeL grows linearly with text length (at most 8 MiB of bit masks, then a two-row table). rougeLsum reproduces the backtracking of rouge-score and needs, like it, a full table of (m + 1) × (n + 1) counters for every pair of a target sentence of m tokens and a prediction sentence of n tokens, at 4 bytes per counter. Unless split_summaries=True, sentences are lines, so a long text without newlines is a single sentence: two of 20,000 tokens need about 1.6 GB, and score_batch holds one such table per thread at the same time. Splitting a batch into chunks does not lower this peak; for such inputs, limit the threads with RAYON_NUM_THREADS or score the longest pairs one at a time with score. A table that cannot be allocated raises MemoryError in Python; in Rust, scoring panics with a std::collections::TryReserveError payload.

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.

Wheels use the stable ABI of CPython 3.9 and later. Free-threaded CPython such as 3.14t builds the package from the sdist and re-enables the GIL when it is imported.

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.2

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.2
File Size Uploaded Provenance Actions
rouge_score_rs-0.2.2.tar.gz 155.6 kB With provenance Details for rouge_score_rs-0.2.2.tar.gz

Built distributions (wheels)

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

Total release size: 3.7 MB

Release files / rouge_score_rs-0.2.2.tar.gz

Download URL rouge_score_rs-0.2.2.tar.gz
Size 155.6 kB
Tags Source
SHA-256 checksum
How to use checksums
5a08ea171ef47d400839fded72f61da7187cb3155e12fb1d569c159d44d7cdfb
BLAKE2b-256 checksum
How to use checksums
a3c5ac52b23a54828315ff325bcbd97dcf678ff3f276d8d911abe9a51df087f0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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 Nov 15, 2026.

Transparency log

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

Download URL rouge_score_rs-0.2.2-cp39-abi3-win_amd64.whl
Size 347.8 kB
Tags CPython 3.9 Windows x86-64 abi3
SHA-256 checksum
How to use checksums
b581668d2700cc5993e7f7ba81a00bc03616a4120e7e3b1b70e08ee536f2d8a5
BLAKE2b-256 checksum
How to use checksums
176083607e2f162d3fda9624683df9016c2f3451ce0d27aa5c4e8c1c4b6a7b42
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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 Nov 15, 2026.

Transparency log

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

Download URL rouge_score_rs-0.2.2-cp39-abi3-musllinux_1_2_x86_64.whl
Size 701.3 kB
Tags CPython 3.9 Linux musl 1.2+ x86-64 abi3
SHA-256 checksum
How to use checksums
1d999cfd07a723aa6b5d448366d2889567432eb92dd8df7ef095d4a573930316
BLAKE2b-256 checksum
How to use checksums
a8a4f8ccba372cd1d5cdeb46f1e50a9c729f961222694c31ec66ce534c96c0a9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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 Nov 15, 2026.

Transparency log

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

Download URL rouge_score_rs-0.2.2-cp39-abi3-musllinux_1_2_aarch64.whl
Size 666.2 kB
Tags CPython 3.9 Linux musl 1.2+ ARM64 abi3
SHA-256 checksum
How to use checksums
80d1143c5463b3575b717648f23026e2308ca8d6271ddd45e31b33ae6c3aa6fe
BLAKE2b-256 checksum
How to use checksums
866cb850059db78b41ef71664dc7a0a54d49cc58e1715d74eb4db697a6fa40d4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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 Nov 15, 2026.

Transparency log

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

Download URL rouge_score_rs-0.2.2-cp39-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
Size 488.0 kB
Tags CPython 3.9 Linux glibc 2.17+ x86-64 abi3
SHA-256 checksum
How to use checksums
d749142df075f8d14c40dbb88ea5217556ba6d7f442555e7ab9d08cc97373693
BLAKE2b-256 checksum
How to use checksums
359af3bba1702d06a3b784dc2f6d983ff3332e2dfb4608c191bd310d7fe72d0e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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 Nov 15, 2026.

Transparency log

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

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

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 Nov 15, 2026.

Transparency log

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

Download URL rouge_score_rs-0.2.2-cp39-abi3-macosx_11_0_arm64.whl
Size 444.3 kB
Tags CPython 3.9 abi3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
8f0d8db5afe3b2560246df994e3cf612a61db4f50efb4b97d88373e14f9b6582
BLAKE2b-256 checksum
How to use checksums
0e37db63a4e62b1267de153a607dfbf3bbe6b7ded3be5690eec6c49938d6cf98
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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 Nov 15, 2026.

Transparency log

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

Download URL rouge_score_rs-0.2.2-cp39-abi3-macosx_10_12_x86_64.whl
Size 446.9 kB
Tags CPython 3.9 abi3 macOS 10.12+ x86-64
SHA-256 checksum
How to use checksums
6796b43341afbe63b35a99165ddcba3c9195205766e9bec75de85691022cb4b7
BLAKE2b-256 checksum
How to use checksums
817437c3dd04712a6e3faceab56dcca7680da9fe78c1e895c6be15cd0c8648a6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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 Nov 15, 2026.

Transparency log

Security for rouge-score-rs 0.2.2

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.

Full provenance

All 8 files in this release have been uploaded with provenance metadata.

Select from 8 files

Attestation for rouge_score_rs-0.2.2.tar.gz

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 Nov 15, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

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