Skip to main content

bleu-mp

Multi-process BLEU evaluation tool.
多进程BLEU评估工具。

Modified from the bleu scoring tool of huggingface evaluation.
改自 huggingface evaluate 的 bleu 评分工具。
https://github.com/huggingface/evaluate/blob/main/metrics/bleu/bleu.py

Install / 安装

pip

pip install -U bleu-mp

dev

git clone https://github.com/One-sixth/bleu-mp
cd bleu-mp
pip install -e .

New Features / 新特性

  1. Faster!
  2. The built-in multi-process implementation of python is not used. I use my own multi-process implementation, which is very friendly to the compatibility of Windows and Linux. The memory occupied by each calculation subprocess is very low.

  1. 更快!
  2. 不使用python内置的多进程实现。使用我自己的多进程实现,从而对windows和linux的兼容性非常友好,每个计算子进程占用的内存非常低。

Features / 特性

Both string and integer sequences are supported for bleu calculation.
同时支持 字符串和整数序列 进行bleu计算。

Speed test / 速度测试

Test code is in unittest/test.py.
测试代码位于 unittest/test.py。

CPU:i7-8750H

# short str / 短字符串
score (1.0, [1.0, 1.0, 1.0, 1.0], 1.0, 1.0, 2200000, 2200000) (1.0, [1.0, 1.0, 1.0, 1.0], 1.0, 1.0, 2200000, 2200000)
1  process cost time 16.979528665542603
10 process cost time 3.5354034900665283

# long str / 长字符串
score (1.0, [1.0, 1.0, 1.0, 1.0], 1.0, 1.0, 22000000, 22000000) (1.0, [1.0, 1.0, 1.0, 1.0], 1.0, 1.0, 22000000, 22000000)
1  process cost time 103.8217351436615
10 process cost time 22.66322374343872

# short int list / 短整数序列
score (1.0, [1.0, 1.0, 1.0, 1.0], 1.0, 1.0, 800000, 800000) (1.0, [1.0, 1.0, 1.0, 1.0], 1.0, 1.0, 800000, 800000)
1  process cost time 4.874496936798096
10 process cost time 1.1751139163970947

# long int list / 长整数序列
score (1.0, [1.0, 1.0, 1.0, 1.0], 1.0, 1.0, 16000000, 16000000) (1.0, [1.0, 1.0, 1.0, 1.0], 1.0, 1.0, 16000000, 16000000)
1  process cost time 47.34107685089111
10 process cost time 10.046519994735718

Warning / 警告

Don't input pytorch's tensor type. It will causes unnecessary memory consumption, and a lot of performance loss.
Please convert to numpy array or list type first.

不要传入 pytorch 的 tensor 类型,这会导致额外的内存消耗和大量的性能损失。
请先转换到 numpy数组 或 list类型。

Demo / 示例

from bleu_mp import compute_bleu

# str
pred_data = ['床前明月光,疑是地上霜', '举头望明月,低头思故乡'] * 1000
tgt_data = [['床前明月光,疑是地上霜'], ['举头望明月,低头思故乡', '静夜思']] * 1000
result = compute_bleu(pred_data, tgt_data)
print('bleu score', result[0])

# int list
pred_data = [[1, 2, 3, 4], [2, 3, 4, 5]] * 1000
tgt_data = [[[1, 2, 3, 4]], [[2, 3, 4, 5], [4, 5, 6]]] * 1000
result = compute_bleu(pred_data, tgt_data)
print('bleu score', result[0])

Reference / 引用

https://github.com/huggingface/evaluate

Metadata

Release files for bleu-mp 0.0.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 bleu-mp 0.0.1
File Size Uploaded Provenance Actions
bleu-mp-0.0.1.tar.gz 6.3 kB Without provenance Details for bleu-mp-0.0.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for bleu-mp 0.0.1
File Interpreter ABI Platform Actions
bleu_mp-0.0.1-py3-none-any.whl Python 3 none any Details for bleu_mp-0.0.1-py3-none-any.whl

Total release size: 13.2 kB

Release files / bleu-mp-0.0.1.tar.gz

Download URL bleu-mp-0.0.1.tar.gz
Size 6.3 kB
Tags Source
SHA-256 checksum
How to use checksums
e8792eff60fe4b23dce8d18bd537b1b6787e82a2b613100efeb8b807b5274546
BLAKE2b-256 checksum
How to use checksums
ccc33c72b3abfe2fc0c5aa07c28337dbe085b5482b599458bc2531b5c4efdb6b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.10.8

Release files / bleu_mp-0.0.1-py3-none-any.whl

Download URL bleu_mp-0.0.1-py3-none-any.whl
Size 6.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
f0a0eaeb65248f01b5f13cccfbde2f2e4ebbf7e656bd6d6eb9fb79b0e3652565
BLAKE2b-256 checksum
How to use checksums
475cbf38014eeebdd9cb09fd31ebd8008a2b01c09f356950e34a9caa548dc8d8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.10.8

Security for bleu-mp 0.0.1

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.

No provenance found

None of the files in this release were uploaded with provenance metadata.

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.

Release history Release notifications | RSS feed

This release

0.0.1 This release

2 release files No provenance

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