Skip to main content

GEMBA-MQM and GEMBA-DA

Setup

Install required packages with python >= 3.8 (tested with 3.12.7)

pip install -r requirements.txt

Set up secrets either for Azure API or OpenAI API:

export OPENAI_AZURE_ENDPOINT=
export OPENAI_AZURE_KEY=

or

export OPENAI_API_KEY=

Scoring with GEMBA

Install the gemba package with pip install gemba and use the following code:

from gemba import get_gemba_scores

source = ["Hello, how are you?", "I am fine, thank you.", "I am not fine, thank you."]
hypothesis = ["Hallo, wie geht es dir?", "Ich bin gut, danke.", "Ich bin Joel, wer bist du?"]
source_lang = "en"
target_lang = "de"

answers, errors = get_gemba_scores(source, hypothesis, source_lang, target_lang, method="GEMBA-MQM_norm", model="gpt-4o")

for answer, error in zip(answers, errors):
    print(answer, error)

Alternatively, you can run the main file on two text files. It assumes two files with the same number of lines. It prints the score for each line pair:

python main.py --source=source.txt --hypothesis=hypothesis.txt --source_lang=English --target_lang=Czech --method="GEMBA-MQM" --model="gpt-4"

The main recommended methods: GEMBA-MQM and GEMBA-DA with the model gpt-4.

Collecting and evaluating experiments for GEMBA-DA

Get mt-metric-eval and download resources:

git clone https://github.com/google-research/mt-metrics-eval.git
cd mt-metrics-eval
pip install .
alias mtme='python3 -m mt_metrics_eval.mtme'
mtme --download
cd ..
mv ~/.mt-metrics-eval/mt-metrics-eval-v2 mt-metrics-eval-v2

Collect data and run the scorer

python gemba_da.py 

export PYTHONPATH=mt-metrics-eval:$PYTHONPATH
python evaluate.py

License

GEMBA code and data are released under the CC BY-SA 4.0 license.

Paper

You can read more about GEMBA-DA in our arXiv paper or GEMBA-MQM in our arXiv paper.

How to Cite

GEMBA-MQM

@inproceedings{kocmi-federmann-2023-gemba-mqm,
    title = {GEMBA-MQM: Detecting Translation Quality Error Spans with GPT-4},
    author = {Kocmi, Tom  and Federmann, Christian},
    booktitle = "Proceedings of the Eighth Conference on Machine Translation",
    month = dec,
    year = "2023",
    address = "Singapore",
    publisher = "Association for Computational Linguistics",
}

GEMBA-DA

@inproceedings{kocmi-federmann-2023-large,
    title = "Large Language Models Are State-of-the-Art Evaluators of Translation Quality",
    author = "Kocmi, Tom and Federmann, Christian",
    booktitle = "Proceedings of the 24th Annual Conference of the European Association for Machine Translation",
    month = jun,
    year = "2023",
    address = "Tampere, Finland",
    publisher = "European Association for Machine Translation",
    url = "https://aclanthology.org/2023.eamt-1.19",
    pages = "193--203",
}

Metadata

Release files for gemba 0.1.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for gemba 0.1.3
File Size Uploaded Provenance Actions
gemba-0.1.3.tar.gz 2.2 MB Without provenance Details for gemba-0.1.3.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for gemba 0.1.3
File Interpreter ABI Platform Actions
gemba-0.1.3-py3-none-any.whl Python 3 none any Details for gemba-0.1.3-py3-none-any.whl

Total release size: 2.2 MB

Release files / gemba-0.1.3.tar.gz

Download URL gemba-0.1.3.tar.gz
Size 2.2 MB
Tags Source
SHA-256 checksum
How to use checksums
0618995163be0c1cfe8afd9d27b8c29cf9ceb2b50e90b96f37d607a4425d0431
BLAKE2b-256 checksum
How to use checksums
b31c405218389a6387a1a31dfe3fe85c351c3dfda5362a8adca846a9a47b9806
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.0.1 CPython/3.12.7

Release files / gemba-0.1.3-py3-none-any.whl

Download URL gemba-0.1.3-py3-none-any.whl
Size 25.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
036e9cb6439c7b8e7b3bbbc856a9c0f313792428d978f8b2ad55d870667f0c76
BLAKE2b-256 checksum
How to use checksums
cbbdf1ba35b40b8509582fe53af57d54f1005ca560327f72867208775d32f29a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.0.1 CPython/3.12.7

Security for gemba 0.1.3

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.

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