quickmt-en-fa / README.md
radinplaid's picture
Upload folder using huggingface_hub
d77c8f7 verified
metadata
language:
  - en
  - fa
tags:
  - translation
license: cc-by-4.0
datasets:
  - quickmt/quickmt-train.fa-en
model-index:
  - name: quickmt-en-fa
    results:
      - task:
          name: Translation eng-pes
          type: translation
          args: eng-pes
        dataset:
          name: flores101-devtest
          type: flores_101
          args: eng_Latn pes_Arab devtest
        metrics:
          - name: BLEU
            type: bleu
            value: 26.22
          - name: CHRF
            type: chrf
            value: 54.08
          - name: COMET
            type: comet
            value: 85.79

quickmt-en-fa Neural Machine Translation Model

quickmt-en-fa is a reasonably fast and reasonably accurate neural machine translation model for translation from en into fa.

Model Information

See the eole model configuration in this repository for further details and the eole-model for the raw eole (pytorch) model.

Usage with quickmt

You must install the Nvidia cuda toolkit first, if you want to do GPU inference.

Next, install the quickmt python library and download the model:

git clone https://github.com/quickmt/quickmt.git
pip install ./quickmt/

quickmt-model-download quickmt/quickmt-en-fa ./quickmt-en-fa

Finally use the model in python:

from quickmt import Translator

# Auto-detects GPU, set to "cpu" to force CPU inference
t = Translator("./quickmt-en-fa/", device="auto")

# Translate - set beam size to 5 for higher quality (but slower speed)
sample_text = 'Dr. Ehud Ur, professor of medicine at Dalhousie University in Halifax, Nova Scotia and chair of the clinical and scientific division of the Canadian Diabetes Association cautioned that the research is still in its early days.'
t(sample_text, beam_size=5)

'دکتر ایهود اور، استاد پزشکی در دانشگاه دالهوزی در هالیفاکس، نوا اسکوشیا و رئیس بخش بالینی و علمی انجمن دیابت کانادا هشدار داد که این تحقیق هنوز در روزهای اولیه خود است.'

# Get alternative translations by sampling
# You can pass any cTranslate2 `translate_batch` arguments
t([sample_text], sampling_temperature=1.2, beam_size=1, sampling_topk=50, sampling_topp=0.9)

'آقای دکتر اهود اور، استاد دارو در دانشگاه دالهوزي در هلیفکس، نوا اسکوشیا و رئیس بخش پزشکی و علمی جمعیت دیابت کانادا هشدار داد که تحقیقات انجام شده هنوز در روزهای اولیه هستند.'

The model is in ctranslate2 format, and the tokenizers are sentencepiece, so you can use ctranslate2 directly instead of through quickmt. It is also possible to get this model to work with e.g. LibreTranslate which also uses ctranslate2 and sentencepiece.

Metrics

bleu and chrf2 are calculated with sacrebleu on the Flores200 devtest test set ("eng_Latn"->"pes_Arab"). comet22 with the comet library and the default model. "Time (s)" is the time in seconds to translate (using ctranslate2) the flores-devtest dataset (1012 sentences) on an RTX 4070s GPU with batch size 32 (faster speed is possible with a larger batch size).

bleu chrf2 comet22 Time (s)
quickmt-en-fa 26.22 54.08 85.79 1.18
facebook/nllb-200-distilled-600M 20.59 49.58 84.44 22.77
facebook/nllb-200-distilled-1.3B 21.85 50.88 86.46 39.55
facebook/m2m100_418M 19.95 48.23 81.46 19.71
facebook/m2m100_1.2B 16.97 45.22 78.93 38.79