Skip to main content

GEMBA — GPT Estimation Metric Based Assessment

Project description

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",
}

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

gemba-0.1.2.tar.gz (2.2 MB view details)

Uploaded Source

Built Distribution

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

gemba-0.1.2-py3-none-any.whl (24.8 kB view details)

Uploaded Python 3

File details

Details for the file gemba-0.1.2.tar.gz.

File metadata

  • Download URL: gemba-0.1.2.tar.gz
  • Upload date:
  • Size: 2.2 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.12.7

File hashes

Hashes for gemba-0.1.2.tar.gz
Algorithm Hash digest
SHA256 f8ca3f6c395bd1ff7230f6a24ef9ac473ba6fdfcc2d46d7ba9b09de07edef3ae
MD5 e1d85affe8fd39e7a47905b1e8b7ed47
BLAKE2b-256 7fc9c8de0f9732906fde444f60bb7a34c3e201cb8f0a2cf2abd0afc510549408

See more details on using hashes here.

File details

Details for the file gemba-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: gemba-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 24.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.12.7

File hashes

Hashes for gemba-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 a42394096e81501a1fd4d340cd31c8f6051438d811596cbea516ec36c74212ee
MD5 a0e1721ffe159cb6be458554855333d8
BLAKE2b-256 33df7da490ddf9f8d7e812933cf766ca5513214c9e4b218ff2456f6c5e930736

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