opus-mt-es-en (CTranslate2 INT8)

CTranslate2 INT8-quantized conversion of Helsinki-NLP/opus-mt-es-en, the OPUS-MT Spanish→English machine translation model.

Used by PruGlobal as the local MT backend for the Free tier: runs entirely on the user's CPU with no cloud calls, so we can offer a baseline translation experience without consuming EVOR credits.

Why CT2 INT8

  • ~75 MB on disk vs ~300 MB FP32 original
  • No PyTorch dependency at inference time — only ctranslate2 + sentencepiece are needed
  • 2-4× faster than the original on CPU thanks to the C++ kernels and INT8 ops
  • Runs on low-end machines without GPU

Usage

import ctranslate2
import sentencepiece as spm
from huggingface_hub import snapshot_download

path = snapshot_download("Prukario/opus-mt-es-en-ct2-int8")
translator = ctranslate2.Translator(path, device="cpu", compute_type="int8")
sp_src = spm.SentencePieceProcessor(model_file=f"{path}/source.spm")
sp_tgt = spm.SentencePieceProcessor(model_file=f"{path}/target.spm")

def translate(text: str) -> str:
    tokens = sp_src.encode(text, out_type=str) + ["</s>"]  # Marian needs EOS
    out = translator.translate_batch([tokens], beam_size=2)[0].hypotheses[0]
    if "</s>" in out:
        out = out[: out.index("</s>")]
    return sp_tgt.decode(out)

print(translate("Hola, ¿cómo estás?"))
# -> "Hello, how are you?"

Reproducing the conversion

pip install torch transformers ctranslate2 sentencepiece
ct2-transformers-converter \
  --model Helsinki-NLP/opus-mt-es-en \
  --output_dir opus-mt-es-en-ct2-int8 \
  --quantization int8 \
  --copy_files source.spm target.spm tokenizer_config.json

Citation

If you use this model, please cite the original OPUS-MT paper:

@inproceedings{TiedemannThottingal:EAMT2020,
  author = {J{\"o}rg Tiedemann and Santhosh Thottingal},
  title = {{OPUS-MT} — {B}uilding open translation services for the {W}orld},
  booktitle = {Proceedings of the 22nd Annual Conference of the European Association for Machine Translation (EAMT)},
  year = {2020},
  address = {Lisbon, Portugal}
}

License

CC-BY 4.0, inherited from the Helsinki-NLP/opus-mt-es-en base model.

Downloads last month
42
Inference Providers NEW
This model isn't deployed by any Inference Provider. 🙋 Ask for provider support

Model tree for Prukario/opus-mt-es-en-ct2-int8

Finetuned
(30)
this model