Skip to main content

A fast(not yet :) bleu score calculator

Project description

bleuscore

codecov MIT licensed Crates.io PyPI - Version docs.rs

bleuscore is a fast(not yet :) BLEU score calculator written in rust.

Installation

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

  • pip

    pip install bleuscore
    
  • poetry

    poetry add bleuscore
    
  • uv

    uv 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

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.

  • Benchmark1: bleuscore
  • Benchmark2: huggingface evaluate bleu algorithm in local
  • Benchmark3: sacrebleu
    • Note that we got different result with sacrebleu in the simple demo data and all the rests have same result
  • Benchmark4: huggingface evaluate bleu algorithm with evaluate package

The N is used to enlarge the predictions/references size by simply duplication the demo data as shown before.

We can see that as N increase, the bleuscore gets better performance.

N=1

N=100

We will only test the bleuscore and evaluate local results from here, because the other two methods are too slow to test quickly.

N=10,000

N=100,000

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.1.1.tar.gz (995.2 kB view details)

Uploaded Source

Built Distributions

bleuscore-0.1.1-cp38-abi3-win_amd64.whl (714.0 kB view details)

Uploaded CPython 3.8+ Windows x86-64

bleuscore-0.1.1-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.7 MB view details)

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

bleuscore-0.1.1-cp38-abi3-manylinux_2_5_i686.manylinux1_i686.whl (1.7 MB view details)

Uploaded CPython 3.8+ manylinux: glibc 2.5+ i686

bleuscore-0.1.1-cp38-abi3-macosx_11_0_arm64.whl (826.5 kB view details)

Uploaded CPython 3.8+ macOS 11.0+ ARM64

bleuscore-0.1.1-cp38-abi3-macosx_10_12_x86_64.whl (871.1 kB view details)

Uploaded CPython 3.8+ macOS 10.12+ x86-64

File details

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

File metadata

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

File hashes

Hashes for bleuscore-0.1.1.tar.gz
Algorithm Hash digest
SHA256 95f15f44929e104bc66f7223c92080a00bad9b6bf129bd96f076630059204cc2
MD5 acf6084dac8399d47698f9ec2b5e0e1c
BLAKE2b-256 a07c2fee15d42ce80013b881a1db1a5327a8c96231e83586fde9281f8517b2da

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for bleuscore-0.1.1-cp38-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 a73e9f4b939db2c6795f56aff03dd3c1f47116111aba29349d06d1895e1b2451
MD5 790e745c53957ac2d4d0fd91826ab711
BLAKE2b-256 fc067bc59016fca380e8dd711733d3b99d6a14f5ae9a5948c102887fa0a736eb

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for bleuscore-0.1.1-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 bef1ecc651d29161dc99e4b027f1f459f4c6d69973ea6407135b8573e93a9b52
MD5 7c20e28eae00fc14dd754f36a417020a
BLAKE2b-256 2f32313529bd316ed433872f8802547f8d2569f37c4a0ca8bd811068c92b8ace

See more details on using hashes here.

File details

Details for the file bleuscore-0.1.1-cp38-abi3-manylinux_2_5_i686.manylinux1_i686.whl.

File metadata

File hashes

Hashes for bleuscore-0.1.1-cp38-abi3-manylinux_2_5_i686.manylinux1_i686.whl
Algorithm Hash digest
SHA256 8ee9f5ffae60326e96a113a212ab79aaf53caf957e6ea836a72fde3d2d820bd2
MD5 c8f3c3bb53dd1abed70ca5eb4dd079ae
BLAKE2b-256 0f22a3bdb0c5fad58956e7f5cfbdfddd840da7de5a54d2f118f4612d4058e4d0

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for bleuscore-0.1.1-cp38-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 e5045144dc0d466935ca9a469a09cd73d210a762c93134f8ca08841e9bb0796f
MD5 a1fe2de89aaab1392465a0f0698c7587
BLAKE2b-256 3859ff60c24017e43b2f7c57e8c716a14cb2b43307fdef879dd36e46ca3944c4

See more details on using hashes here.

File details

Details for the file bleuscore-0.1.1-cp38-abi3-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for bleuscore-0.1.1-cp38-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 795fc4db196f8b43eace9aa11959e10b46462797aeae8ec8dccfa186323633a2
MD5 fa29c6f74321495a400cb7b0c1011b8b
BLAKE2b-256 9c56923fb6956586de3d7c0c908e30a2117e2be6f178b9f9ef0f560b21c1210b

See more details on using hashes here.

Supported by

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