← 开源
google-research

bleurt

BLEURT is a metric for Natural Language Generation based on transfer learning.

AI EngineeringTest & guardPython
在 GitHub 打开
增长势头
+024 小时新增 Star0.0%
792
Star
94
Fork
+1
本周
1
贡献者
创建于 2020-04-29 · 更新于 2026-10-13 · 今日第 13776 名
主要开发者
tsellam

google-research/bleurt 排名第 13,776,有 792 个星标。

同类别比较

google-research/bleurt 排名第 13,776,此处有 8 个同类条目;bosun-ai/swiftide 排名第 13,773。

同类别比较
名称排名指标
ru-yee/Life-Agent-RU-YEE13,767
语言:
Python
星标数:
793
分叉数:
65
Canner/vulcan-sql13,769
语言:
TypeScript
星标数:
792
分叉数:
42
简介:
Data API Framework for AI Agents and Data Apps
antvis/GPT-Vis13,771
语言:
TypeScript
星标数:
792
分叉数:
97
简介:
🤖 GPT Vision, Visualization for AI Friendly! AntV's entry for AI.
bosun-ai/swiftide13,773
语言:
Rust
星标数:
792
分叉数:
71
简介:
Fast, streaming indexing, query, and agentic LLM applications in Rust
ECNU-SII/MIA13,782
语言:
Python
星标数:
791
分叉数:
85
简介:
Memory Intelligence Agent
Microck/opencode-studio13,784
语言:
TypeScript
星标数:
791
分叉数:
61
简介:
web GUI for securely managing local OpenCode configuration
syedazharmbnr1/claude-chatgpt-mcp13,792
语言:
JavaScript
星标数:
791
分叉数:
103
简介:
A Claude MCP tool to interact with the ChatGPT desktop app on macOS
RobustBench/robustbench13,796
语言:
Python
星标数:
790
分叉数:
106
简介:
RobustBench: a standardized adversarial robustness benchmark [NeurIPS 2021 Benchmarks and Datasets Track]
关键参数与规格
关键参数与规格
参数值
语言Python
类别AI Engineering
子类别Test & guard
关键词Benchmarks, Evals, Similarity score
星标数792
分叉数94
贡献者1
创建日期2020-04-29
更新日期2026-10-13
1 天星标数0
7 天星标数1
排名13,776
上次排名13,672
排名变化-104
7 天星标排名10,684
上次 7 天星标排名10,740
7 天星标排名变化56
总星标排名13,469
上次总星标排名13,452
总星标排名变化-17
国家USA
README 摘录

BLEURT: a Transfer Learning-Based Metric for Natural Language Generation BLEURT is an evaluation metric for Natural Language Generation. It takes a pair of sentences as input, a *reference* and a *candidate*, and it returns a score that indicates to what extent the candidate is fluent and conveys the meaning of the reference. BLEURT is a *trained metric*, that is, it is a regression model trained on ratings data. This repository contains all the code necessary to use it and

/or fine-tune it for your own applications. BLEURT uses Tensorflow, and it benefits greatly from modern GPUs (it runs on CPU too). An overview of BLEURT can be found in our our blog post. Further details are provided in the ACL paper BLEURT: Learning Robust Metrics for Text Generation and our EMNLP paper. You may install it as follows: You may check your install with unit tests: Using BLEURT - TL;DR Version The following commands download the recommended checkpoint

and run BLEURT: The files and contain test sentences, included by default in the BLEURT distribution. The input format is one sentence per line. You may replace them with your own files. The command outputs one score per sentence pair. **Oct 8th 2021 Update:** we upgraded the recommended checkpoint to BLEURT-20, a more accurate, multilingual model 🎉. Using BLEURT - the Long Version Command-line tools and APIs Currently, there are three methods to invoke BLEURT: the command-line interface, the

Python API, and the Tensorflow API. Command-line interface The simplest way to use BLEURT is through command line, as shown below. The files and contain one sentence per line (see the folder for the exact format). Invoking the command should produce a file which contains one BLEURT score per sentence pair. Alternatively you may use a JSONL file, as follows: The flags and are optional. If is not specified, BLEURT will default to a test checkpoint, based on BERT

-Tiny, which is very light but also very inaccurate (we recommend against using it). If is not specified, BLEURT will use the standard output. The following command lists all the other command-line options: Python API BLEURT may be used as a Python library as follows: Here again, BLEURT will default to if no checkpoint is specified. 0), but the latter mode is slower and may be deprecated in the near future. Tensorflow API BLEURT may be embedded in a

TF computation graph, e. , to visualize it on the Tensorboard while training a model. The following piece of code shows an example: The crucial part is the call to , which creates the TF ops. Checkpoints A *BLEURT checkpoint* is a self-contained folder that contains a regression model and some information that BLEURT needs to run. BLEURT checkpoints can be downloaded, copy-pasted, and stored anywhere. Furthermore, checkpoints are tunable, which means that they can be fine-tuned on custom

ratings data. BLEURT defaults to the checkpoint, which is very inaccaurate. We recommend using for results reporting. You may use

常见问题

记录了多少星标和分叉?

google-research/bleurt 有 792 个星标和 94 个分叉。

仓库排名是多少?

google-research/bleurt 排名第 13,776。

记录的语言和类别是什么?

google-research/bleurt 有 792 个星标,语言为 Python,类别为 AI Engineering。

哪个仓库排名最接近?

google-research/bleurt 与 bosun-ai/swiftide 比较,后者排名第 13,773,有 792 个星标。

README

BLEURT: a Transfer Learning-Based Metric for Natural Language Generation

BLEURT is an evaluation metric for Natural Language Generation. It takes a pair of sentences as input, a reference and a candidate, and it returns a score that indicates to what extent the candidate is fluent and conveys the meaning of the reference. It is comparable to sentence-BLEU, BERTscore, and COMET.

BLEURT is a trained metric, that is, it is a regression model trained on ratings data. The model is based on BERT and RemBERT. This repository contains all the code necessary to use it and/or fine-tune it for your own applications. BLEURT uses Tensorflow, and it benefits greatly from modern GPUs (it runs on CPU too).

An overview of BLEURT can be found in our our blog post. Further details are provided in the ACL paper BLEURT: Learning Robust Metrics for Text Generation and our EMNLP paper.

Installation

BLEURT runs in Python 3. It relies heavily on Tensorflow (>=1.15) and the library tf-slim (>=1.1). You may install it as follows:

pip install --upgrade pip  # ensures that pip is current
git clone https://github.com/google-research/bleurt.git
cd bleurt
pip install .

You may check your install with unit tests:

python -m unittest bleurt.score_test
python -m unittest bleurt.score_not_eager_test
python -m unittest bleurt.finetune_test
python -m unittest bleurt.score_files_test

Using BLEURT - TL;DR Version

The following commands download the recommended checkpoint and run BLEURT:

# Downloads the BLEURT-base checkpoint.
wget https://storage.googleapis.com/bleurt-oss-21/BLEURT-20.zip .
unzip BLEURT-20.zip

# Runs the scoring.
python -m bleurt.score_files \
  -candidate_file=bleurt/test_data/candidates \
  -reference_file=bleurt/test_data/references \
  -bleurt_checkpoint=BLEURT-20

The files bleurt/test_data/candidates and references contain test sentences, included by default in the BLEURT distribution. The input format is one sentence per line. You may replace them with your own files. The command outputs one score per sentence pair.

Oct 8th 2021 Update: we upgraded the recommended checkpoint to BLEURT-20, a more accurate, multilingual model 🎉.

Using BLEURT - the Long Version

Command-line tools and APIs

Currently, there are three methods to invoke BLEURT: the command-line interface, the Python API, and the Tensorflow API.

Command-line interface

The simplest way to use BLEURT is through command line, as shown below.

python -m bleurt.score_files \
  -candidate_file=bleurt/test_data/candidates \
  -reference_file=bleurt/test_data/references \
  -bleurt_checkpoint=bleurt/test_checkpoint \
  -scores_file=scores

The files candidates and references contain one sentence per line (see the folder test_data for the exact format). Invoking the command should produce a file scores which contains one BLEURT score per sentence pair. Alternatively you may use a JSONL file, as follows:

python -m bleurt.score_files \
  -sentence_pairs_file=bleurt/test_data/sentence_pairs.jsonl \
  -bleurt_checkpoint=bleurt/test_checkpoint

The flags bleurt_checkpoint and scores_file are optional. If bleurt_checkpoint is not specified, BLEURT will default to a test checkpoint, based on BERT-Tiny, which is very light but also very inaccurate (we recommend against using it). If scores_files is not specified, BLEURT will use the standard output.

The following command lists all the other command-line options:

python -m bleurt.score_files -helpshort

Python API

BLEURT may be used as a Python library as follows:

from bleurt import score

checkpoint = "bleurt/test_checkpoint"
references = ["This is a test."]
candidates = ["This is the test."]

scorer = score.BleurtScorer(checkpoint)
scores = scorer.score(references=references, candidates=candidates)
assert isinstance(scores, list) and len(scores) == 1
print(scores)

Here again, BLEURT will default to BERT-Tiny if no checkpoint is specified.

BLEURT works both in eager_mode (default in TF 2.0) and in a tf.Session (TF 1.0), but the latter mode is slower and may be deprecated in the near future.

Tensorflow API

BLEURT may be embedded in a TF computation graph, e.g., to visualize it on the Tensorboard while training a model.

The following piece of code shows an example:

import tensorflow as tf
# Set tf.enable_eager_execution() if using TF 1.x.

from bleurt import score

references = tf.constant(["This is a test."])
candidates = tf.constant(["This is the test."])

bleurt_ops = score.create_bleurt_ops()
bleurt_out = bleurt_ops(references=references, candidates=candidates)

assert bleurt_out["predictions"].shape == (1,)
print(bleurt_out["predictions"])

The crucial part is the call to score.create_bleurt_ops, which creates the TF ops.

Checkpoints

A BLEURT checkpoint is a self-contained folder that contains a regression model and some information that BLEURT needs to run. BLEURT checkpoints can be downloaded, copy-pasted, and stored anywhere. Furthermore, checkpoints are tunable, which means that they can be fine-tuned on custom ratings data.

BLEURT defaults to the test checkpoint, which is very inaccaurate. We recommend using BLEURT-20 for results reporting. You may use it as follows:

wget https://storage.googleapis.com/bleurt-oss-21/BLEURT-20.zip .
unzip BLEURT-20.zip
python -m bleurt.score_files \
  -candidate_file=bleurt/test_data/candidates \
  -reference_file=bleurt/test_data/references \
  -bleurt_checkpoint=BLEURT-20

The checkpoints page provides more information about how these checkpoints were trained, as well as pointers to smaller models. Additionally, you can fine-tune BERT or existing BLEURT checkpoints on your own ratings data. The checkpoints page describes how to do so.

Interpreting BLEURT Scores

Different BLEURT checkpoints yield different scores. The currently recommended checkpoint BLEURT-20 generates scores which are roughly between 0 and 1 (sometimes less than 0, sometimes more than 1), where 0 indicates a random output and 1 a perfect one. As with all automatic metrics, BLEURT scores are noisy. For a robust evaluation of a system's quality, we recommend averaging BLEURT scores across the sentences in a corpus. See the WMT Metrics Shared Task for a comparison of metrics on this aspect.

In principle, BLEURT should measure adequacy: most of its training data was collected by the WMT organizers who asked to annotators "How much do you agree that the system output adequately expresses the meaning of the reference?" (WMT Metrics'18, Graham et al., 2015). In practice however, the answers tend to be very correlated with fluency ("Is the text fluent English?"), and we added synthetic noise in the training set which makes the distinction between adequacy and fluency somewhat fuzzy.

Language Coverage

Currently, BLEURT-20 was tested on 13 languages: Chinese, Czech, English, French, German, Japanese, Korean, Polish, Portugese, Russian, Spanish, Tamil, Vietnamese (these are languages for which we have held-out ratings data). In theory, it should work for the 100+ languages of multilingual C4, on which RemBERT was trained.

If you tried any other language and would like to share your experience, either positive or negative, please send us feedback!

Speeding Up BLEURT

We describe three methods to speed up BLEURT, and how to combine them.

Batch size tuning

You may specify the flag -bleurt_batch_size which determines the number of sentence pairs processed at once by BLEURT. The default value is 16, you may want to increase or decrease it based on the memory available and the presence of a GPU (we typically use 16 when using a laptop without a GPU, 100 on a workstation with a GPU).

Length-based batching

Length-based batching is an optimization which consists in batching examples that have a similar a length and cropping the resulting tensor, to avoid wasting computations on padding tokens. This technique oftentimes results in spectacular speed-ups (typically, ~2-10X). It is described here, and it was successfully used by BERTScore in the field of learned metrics.

You can enable length-based by specifying -batch_same_length=True when calling score_files with the command line, or by instantiating a LengthBatchingBleurtScorer instead of BleurtScorer when using the Python API.

Distilled models

We provide pointers to several compressed checkpoints on the checkpoints page. These models were obtained by distillation, a lossy process, and therefore the outputs cannot be directly compared to those of the original BLEURT model (though they should be strongly correlated).

Putting everything together

The following command illustrates how to combine these three techniques, speeding up BLEURT by an order of magnitude (up to 20X with our configuration) on larger files:

# Downloads the 12-layer distilled model, which is ~3.5X smaller.
wget https://storage.googleapis.com/bleurt-oss-21/BLEURT-20-D12.zip .
unzip BLEURT-20-D12.zip

python -m bleurt.score_files \
  -candidate_file=bleurt/test_data/candidates \
  -reference_file=bleurt/test_data/references \
  -bleurt_batch_size=100 \            # Optimization 1.
  -batch_same_length=True \           # Optimization 2.
  -bleurt_checkpoint=BLEURT-20-D12    # Optimization 3.

Reproducibility

You may find information about how to work with ratings from the WMT Metrics Shared Task, reproduce results from our ACL paper, and a selection of models from our EMNLP paper on this page.

How to Cite

Please cite our ACL paper:

@inproceedings{sellam2020bleurt,
  title = {BLEURT: Learning Robust Metrics for Text Generation},
  author = {Thibault Sellam and Dipanjan Das and Ankur P Parikh},
  year = {2020},
  booktitle = {Proceedings of ACL}
}

The latest model, BLEURT-20, is based on work that led to this follow-up paper:

@inproceedings{pu2021learning,
  title = {Learning compact metrics for MT},
  author = {Pu, Amy and Chung, Hyung Won and Parikh, Ankur P and Gehrmann, Sebastian and Sellam, Thibault},
  booktitle = {Proceedings of EMNLP},
  year = {2021}
}
排名相邻
同类项目