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 Adolf, 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.0.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.0-py3-none-any.whl (24.6 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: gemba-0.1.0.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.0.tar.gz
Algorithm Hash digest
SHA256 19e0d53f7af88bf278126f664b93c5f749eecf3fbfdf6d1eaa0121f37f97e94f
MD5 410fca54ad00e9d935bc17a190f1c749
BLAKE2b-256 bfa417c44cbcf6d317dfdb1994748ea174719c0dec1549563a07e77ef6d7c26f

See more details on using hashes here.

File details

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

File metadata

  • Download URL: gemba-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 24.6 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.0-py3-none-any.whl
Algorithm Hash digest
SHA256 f7a893542c2de9a3a6f72aa500bf705dad4293c24031d1e8cf24617ffaf957e6
MD5 7eced9fd11f71e7d6181f185c844b24b
BLAKE2b-256 2acff5368f1d4fdf981506b1fad6c096b303f059714fd37d6a27c53448e2cfc0

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