|
--- |
|
language: |
|
- en |
|
- th |
|
tags: |
|
- translation |
|
license: cc-by-4.0 |
|
datasets: |
|
- quickmt/quickmt-train.th-en |
|
model-index: |
|
- name: quickmt-th-en |
|
results: |
|
- task: |
|
name: Translation tha-eng |
|
type: translation |
|
args: tha-eng |
|
dataset: |
|
name: flores101-devtest |
|
type: flores_101 |
|
args: tha_Thai eng_Latn devtest |
|
metrics: |
|
- name: BLEU |
|
type: bleu |
|
value: 29.32 |
|
- name: CHRF |
|
type: chrf |
|
value: 58.4 |
|
- name: COMET |
|
type: comet |
|
value: 87.15 |
|
--- |
|
|
|
|
|
# `quickmt-th-en` Neural Machine Translation Model |
|
|
|
`quickmt-th-en` is a reasonably fast and reasonably accurate neural machine translation model for translation from `th` into `en`. |
|
|
|
|
|
## Try it on our Huggingface Space |
|
|
|
Give it a try before downloading here: https://huggingface.co/spaces/quickmt/QuickMT-Demo |
|
|
|
|
|
## Model Information |
|
|
|
* Trained using [`eole`](https://github.com/eole-nlp/eole) |
|
* 195M parameter transformer 'big' with 8 encoder layers and 2 decoder layers |
|
* 20k separate Sentencepiece vocabs |
|
* Expested for fast inference to [CTranslate2](https://github.com/OpenNMT/CTranslate2) format |
|
* Training data: https://huggingface.co/datasets/quickmt/quickmt-train.th-en/tree/main |
|
|
|
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: |
|
|
|
```bash |
|
git clone https://github.com/quickmt/quickmt.git |
|
pip install ./quickmt/ |
|
|
|
quickmt-model-download quickmt/quickmt-th-en ./quickmt-th-en |
|
``` |
|
|
|
Finally use the model in python: |
|
|
|
```python |
|
from quickmt impest Translator |
|
|
|
# Auto-detects GPU, set to "cpu" to force CPU inference |
|
t = Translator("./quickmt-th-en/", device="auto") |
|
|
|
# Translate - set beam size to 1 for faster speed (but lower quality) |
|
sample_text = 'ดร.เอฮุด อูร์ ศาสตราจารย์แพทยศาสตร์แห่งมหาวิทยาลัยดัลเฮาซีในแฮลิแฟกซ์ รัฐโนวาสโกเชีย และประธานแผนกคลินิกและวิทยาศาสตร์แห่งสมาคมโรคเบาหวานแคนาดาได้กล่าวเตือนว่าการวิจัยนี้ยังอยู่ในระยะแรกเริ่มเท่านั้น' |
|
|
|
t(sample_text, beam_size=5) |
|
``` |
|
|
|
> 'Dr. Ehud Ur, Professor of Medicine at the University of Dalhousie in Halifax, Nova Scotia, and Chairman of the Clinical and Science Department of the Canadian Diabetes Association, warned that the research is only in the early stages.' |
|
|
|
```python |
|
# 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) |
|
``` |
|
|
|
> 'Dr Ehud Ur, medical professor of the University of Dalhousi in Halifax, Nova Scotia and president of the Clinical and Scientific Department of the Canadian Diabetic Association, warned that the research is in its early stages.' |
|
|
|
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](https://libretranslate.com/) which also uses `ctranslate2` and `sentencepiece`. |
|
|
|
|
|
## Metrics |
|
|
|
`bleu` and `chrf2` are calculated with [sacrebleu](https://github.com/mjpost/sacrebleu) on the [Flores200 `devtest` test set](https://huggingface.co/datasets/facebook/flores) ("tha_Thai"->"eng_Latn"). `comet22` with the [`comet`](https://github.com/Unbabel/COMET) library and the [default model](https://huggingface.co/Unbabel/wmt22-comet-da). "Time (s)" is the time in seconds to translate the flores-devtest dataset (1012 sentences) on an RTX 4070s GPU with batch size 32 (faster speed is possible using a larger batch size). |
|
|
|
| | bleu | chrf2 | comet22 | Time (s) | |
|
|:---------------------------------|-------:|--------:|----------:|-----------:| |
|
| quickmt/quickmt-th-en | 29.32 | 58.4 | 87.15 | 1.34 | |
|
| Helsinki-NLP/opus-mt-th-en | 19.76 | 48.86 | 81.59 | 3.84 | |
|
| facebook/nllb-200-distilled-600M | 26.54 | 54.97 | 85.26 | 22.27 | |
|
| facebook/nllb-200-distilled-1.3B | 29.38 | 57 | 86.59 | 39.43 | |
|
| facebook/m2m100_418M | 16.57 | 47.88 | 77.69 | 20.1 | |
|
| facebook/m2m100_1.2B | 21.71 | 52.63 | 82.51 | 37.8 | |
|
|