Skip to main content

A fast bleu score calculator

Project description

bleuscore

Crates.io PyPI - Version npm version docs.rs codecov MIT licensed CodSpeed Badge

bleuscore is a fast BLEU score calculator written in rust. You can check try the web demo here for a quick experience.

Installation

The python package has been published to pypi, so we can install it directly:

  • uv: uv add bleuscore
  • pip: pip install bleuscore

Quick Start

The usage is exactly same with huggingface evaluate:

- import evaluate
+ import bleuscore

predictions = ["hello there general kenobi", "foo bar foobar"]
references = [
    ["hello there general kenobi", "hello there !"],
    ["foo bar foobar"]
]

- bleu = evaluate.load("bleu")
- results = bleu.compute(predictions=predictions, references=references)
+ results = bleuscore.compute(predictions=predictions, references=references)

print(results)
# {'bleu': 1.0, 'precisions': [1.0, 1.0, 1.0, 1.0], 'brevity_penalty': 1.0, 
# 'length_ratio': 1.1666666666666667, 'translation_length': 7, 'reference_length': 6}

Benchmark

TLDR: We got more than 10x speedup when the corpus size beyond 100K

Benchmark

We use the demo data shown in quick start to do this simple benchmark. You can check the benchmark/simple for the benchmark source code. Detailed per-PR results are tracked automatically via the Benchmark workflow.

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

bleuscore-0.2.0.tar.gz (29.8 kB view details)

Uploaded Source

Built Distributions

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

bleuscore-0.2.0-cp38-abi3-win_amd64.whl (725.6 kB view details)

Uploaded CPython 3.8+Windows x86-64

bleuscore-0.2.0-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (808.4 kB view details)

Uploaded CPython 3.8+manylinux: glibc 2.17+ x86-64

bleuscore-0.2.0-cp38-abi3-manylinux_2_12_i686.manylinux2010_i686.whl (802.0 kB view details)

Uploaded CPython 3.8+manylinux: glibc 2.12+ i686

bleuscore-0.2.0-cp38-abi3-macosx_11_0_arm64.whl (705.8 kB view details)

Uploaded CPython 3.8+macOS 11.0+ ARM64

File details

Details for the file bleuscore-0.2.0.tar.gz.

File metadata

  • Download URL: bleuscore-0.2.0.tar.gz
  • Upload date:
  • Size: 29.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: maturin/1.13.1

File hashes

Hashes for bleuscore-0.2.0.tar.gz
Algorithm Hash digest
SHA256 228ba2e64127f22cdcd9709884c03c1107e6b0e5b03fc076b03799d37ec254e1
MD5 fbe44bead28933d5b286a5e76f1f9f62
BLAKE2b-256 bb76033e45cc12f474eafd1b3d73402730c7e464df7c4f84453c21a5622b4db3

See more details on using hashes here.

File details

Details for the file bleuscore-0.2.0-cp38-abi3-win_amd64.whl.

File metadata

  • Download URL: bleuscore-0.2.0-cp38-abi3-win_amd64.whl
  • Upload date:
  • Size: 725.6 kB
  • Tags: CPython 3.8+, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: maturin/1.13.1

File hashes

Hashes for bleuscore-0.2.0-cp38-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 dff11497d4326e13d80a16e96903b5b20b4eef23da7b3197b0fc46720b7b9077
MD5 4c84169025f62250bdb794004bfcd181
BLAKE2b-256 1a99433077ec2f7e1733fa8d17e0e7eef9ea9af994800fae29be01b858c4f9ba

See more details on using hashes here.

File details

Details for the file bleuscore-0.2.0-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for bleuscore-0.2.0-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 5e9a2e31a222b4a5b1a3ded612721cf0bb3a10c00518f70a40d463dbd194fe21
MD5 8139c5e8e0796a58b5a055bcda934613
BLAKE2b-256 2448887beb2eb118d88b754cda5285d3f3ba2d581f6b1148b99c360b30996b7e

See more details on using hashes here.

File details

Details for the file bleuscore-0.2.0-cp38-abi3-manylinux_2_12_i686.manylinux2010_i686.whl.

File metadata

File hashes

Hashes for bleuscore-0.2.0-cp38-abi3-manylinux_2_12_i686.manylinux2010_i686.whl
Algorithm Hash digest
SHA256 b009b8a0be93cfcc7cfab53d59216e903e3b4549185788225e9c5ebddf25d957
MD5 8694ecafcc616ffc0a7af433cdec71ed
BLAKE2b-256 7043d09799214b6e1dcf2747b551533444ae2314508a4a419405c64f80e595d4

See more details on using hashes here.

File details

Details for the file bleuscore-0.2.0-cp38-abi3-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for bleuscore-0.2.0-cp38-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 eb735c52c0d413ed42b9b51c892335c3a3a2ec164f389c4498f5af90b3f3dd1c
MD5 820645915acb68f21ed1bb4a4d5714b5
BLAKE2b-256 11e9458acb0d4574110febc38ec2cfa75d7bcfca3c37af16e3071700b8dc7644

See more details on using hashes here.

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