Skip to main content

High-performance Rust-backed ROUGE scoring for Python

Project description

rouge-rust

rouge-rust is a Rust-powered replacement for Google's rouge-score Python package. It provides matching ROUGE-1, ROUGE-2, and ROUGE-L metrics through a PyO3 extension module, with fast batch APIs for large-scale evaluation workloads.

Features

  • ROUGE-1, ROUGE-2, and ROUGE-L scoring
  • score() for drop-in per-pair scoring
  • score_batch() for list-of-dicts batch scoring
  • score_batch_flat() for high-throughput struct-of-arrays batch scoring
  • Rust core optimized for large datasets

Installation

pip install rouge-rust

Usage

import fast_rouge

single = fast_rouge.score("the cat sat", "the cat sat")
print(single["rouge1"].fmeasure)

batch = fast_rouge.score_batch(
    ["the cat sat", "hello world"],
    ["the dog sat", "hello there"],
)
print(batch[0]["rougeL"].precision)

flat = fast_rouge.score_batch_flat(
    ["the cat sat", "hello world"],
    ["the dog sat", "hello there"],
)
print(flat.rouge1_fmeasure[0])

Development

Build the extension into the active virtual environment:

source "$HOME/.cargo/env"
.venv/bin/maturin develop --release

Run tests:

source "$HOME/.cargo/env"
cargo test
.venv/bin/pytest -q

Run the benchmark:

PAIR_COUNT=100000 REPEATS=3 .venv/bin/python benchmark.py

Contributing

See CONTRIBUTING.md.

License

This project is released under the MIT License. See LICENSE.

Release

Build a source distribution and wheel:

source "$HOME/.cargo/env"
.venv/bin/maturin build --release --sdist -o dist

Validate the distributions:

.venv/bin/python -m twine check dist/*

Upload to PyPI:

source "$HOME/.cargo/env"
.venv/bin/maturin upload dist/*

GitHub Actions release flow

This repo includes a GitHub Actions pipeline in .github/workflows/release.yml.

  • pushes and pull requests to main and develop build and test wheels
  • tags matching v* build release artifacts
  • tag builds publish to PyPI and create a GitHub Release

One-time PyPI setup

Configure PyPI trusted publishing for:

  • owner: kyle-mirich
  • repository: rouge-rust
  • workflow: release.yml
  • environment: pypi

After that, creating and pushing a tag such as v0.1.0 will trigger publishing.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

rouge_rust-0.1.4.tar.gz (11.4 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

rouge_rust-0.1.4-cp313-cp313-macosx_11_0_arm64.whl (284.5 kB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

rouge_rust-0.1.4-cp312-cp312-macosx_11_0_arm64.whl (284.3 kB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

rouge_rust-0.1.4-cp311-cp311-macosx_11_0_arm64.whl (285.3 kB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

rouge_rust-0.1.4-cp310-cp310-macosx_11_0_arm64.whl (285.4 kB view details)

Uploaded CPython 3.10macOS 11.0+ ARM64

rouge_rust-0.1.4-cp39-cp39-macosx_11_0_arm64.whl (286.8 kB view details)

Uploaded CPython 3.9macOS 11.0+ ARM64

File details

Details for the file rouge_rust-0.1.4.tar.gz.

File metadata

  • Download URL: rouge_rust-0.1.4.tar.gz
  • Upload date:
  • Size: 11.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for rouge_rust-0.1.4.tar.gz
Algorithm Hash digest
SHA256 eb260c9ee08222c0a658696cd061d13c27b0d275e9fc1a61fb8f374b5505b09e
MD5 e6b16221f687d33beb98c3c43ea01069
BLAKE2b-256 88b4172ab66a6d9e16094b95e70b05f509bf4c77466fab535149a8bc1d640296

See more details on using hashes here.

Provenance

The following attestation bundles were made for rouge_rust-0.1.4.tar.gz:

Publisher: release.yml on kyle-mirich/rouge-rust

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file rouge_rust-0.1.4-cp313-cp313-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for rouge_rust-0.1.4-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 9b05f557c8159684731d41dfcb1bbec641e450f7e2ebc2f25c0544b7c643e84c
MD5 f3a3cbd078cc6dd3b8fdd88feb452171
BLAKE2b-256 1efca9a7a7c76463a0d0914e0fa67d438dd6ef6ede6c396c6dcd5ce9ce59bbb5

See more details on using hashes here.

Provenance

The following attestation bundles were made for rouge_rust-0.1.4-cp313-cp313-macosx_11_0_arm64.whl:

Publisher: release.yml on kyle-mirich/rouge-rust

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file rouge_rust-0.1.4-cp312-cp312-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for rouge_rust-0.1.4-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 26152ed5e6e20a512d0688b6d2eb597343360ac500c7da79a0e98ab72ca9fa92
MD5 b3b79045efdfb2a8a990a39c45e3302f
BLAKE2b-256 3f5f3448ef7f735a2859a07d62a1c396aedd5a4ca508626473c89f422e3cfed7

See more details on using hashes here.

Provenance

The following attestation bundles were made for rouge_rust-0.1.4-cp312-cp312-macosx_11_0_arm64.whl:

Publisher: release.yml on kyle-mirich/rouge-rust

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file rouge_rust-0.1.4-cp311-cp311-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for rouge_rust-0.1.4-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 ce969e6f45f95895f7c9087c60048b316a396653a486f27e42072c7a2e64da27
MD5 1b35050c1acad090383463d5ea1a8432
BLAKE2b-256 97b36def8dbc5923f44b21dfdcf6718b3d811ed72a03a62d0c0bf5621125e33f

See more details on using hashes here.

Provenance

The following attestation bundles were made for rouge_rust-0.1.4-cp311-cp311-macosx_11_0_arm64.whl:

Publisher: release.yml on kyle-mirich/rouge-rust

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file rouge_rust-0.1.4-cp310-cp310-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for rouge_rust-0.1.4-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 72a5f9264063fbe666bec2c52fc77dac375d04834ec57e2cc1e3b2302b59e49f
MD5 e30d245bd54fb0ab2774190e7f976c64
BLAKE2b-256 c063f4f10a9b19d8c8ba8d0422e78a48799eece4651dc97b269e5230d5034b79

See more details on using hashes here.

Provenance

The following attestation bundles were made for rouge_rust-0.1.4-cp310-cp310-macosx_11_0_arm64.whl:

Publisher: release.yml on kyle-mirich/rouge-rust

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file rouge_rust-0.1.4-cp39-cp39-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for rouge_rust-0.1.4-cp39-cp39-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 9d4bfeab4c39a3e4dd37995c69a90c8735697b2c0d5f2447246bbe7d667d1797
MD5 d6f7293e55805fe0eac5e7b60b8fb99c
BLAKE2b-256 24fca5da65e60df63b8c70b63e003cad7ccc7135168032a9acd3f7665697b370

See more details on using hashes here.

Provenance

The following attestation bundles were made for rouge_rust-0.1.4-cp39-cp39-macosx_11_0_arm64.whl:

Publisher: release.yml on kyle-mirich/rouge-rust

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page