quickmt-en-zh
Neural Machine Translation Model
Usage
Install quickmt
git clone https://github.com/quickmt/quickmt.git
pip install ./quickmt/
Download model
quickmt-model-download quickmt/quickmt-en-zh ./quickmt-en-zh
Use model
Inference with quickmt
:
from quickmt import Translator
# Auto-detects GPU, set to "cpu" to force CPU inference
t = Translator("./quickmt-en-zh/", device="auto")
# Translate - set beam size to 5 for higher quality (but slower speed)
t(["The roe deer (Capreolus capreolus), also known as the roe, western roe deer,[3][4] or European roe,[3] is a species of deer."], beam_size=1)
# Get alternative translations by sampling
# You can pass any cTranslate2 `translate_batch` arguments
t(["The roe deer (Capreolus capreolus), also known as the roe, western roe deer,[3][4] or European roe,[3] is a species of deer."], 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 the model files directly if you want. It would be fairly easy to get them to work with e.g. LibreTranslate which also uses ctranslate2
and sentencepiece
.
Model Information
- Trained using
eole
- Trained for 82k steps with an effective batch size of 49152, which took less than 1 day on a single RTX 4090 on vast.ai
- Exported for fast inference to []CTranslate2](https://github.com/OpenNMT/CTranslate2) format
- Training data: https://huggingface.co/datasets/quickmt/quickmt-train.zh-en/tree/main
- Seperate source and target Sentencepiece tokenizers (size 32k)
- Transformer "Big"
- 241,870,080 parameters
- 8 encoder layers and 2 decoder layers
- Gated-silu activations
- Trained and saved in bfloat16
See eole-config.yaml
for more detail.
Metrics
CHRF2 calculated with sacrebleu on the Flores200 devtest
test set ("eng_Latn"->"zho_Hans").
"GPU Time" is the time to translate the flores-devtest corpus using a batch size of 32 on a GTX 1080 GPU. "CPU Time" is the time to translate the following input with a single CPU core:
James Joyce (2 February 1882 β 13 January 1941) was an Irish novelist, poet and literary critic who contributed to the modernist avant-garde movement and is regarded as one of the most influential and important writers of the 20th century.
Model | chrf2 | comet22 | CPU Time (s) | GPU Time (s) |
---|---|---|---|---|
quickmt/quickmt-zh-en | 34.53 | 0.8512 | 1.91 | 3.92 |
Helsinki-NLP/opus-mt-zh-en | 29.20 | 0.8236 | 1.50 | 10.10 |
facebook/m2m100_418M | 26.63 | 0.7376 | 10.2 | 49.02 |
facebook/nllb-200-distilled-600M | 24.68 | 0.7840 | 13.2 | 55.92 |
quickmt-en-zh
is the highest quality and is the fastest on GPU (and not far behind on CPU).
Helsinki-NLP/opus-mt-en-zh is one of the most downloaded machine translation models on HuggingFace, and this model is considerably more accurate and similar in speed.
- Downloads last month
- 8