Opus
Collection
Helsinki-NLP opus models • 20 items • Updated
This model is a CTranslate2 conversion of Helsinki-NLP/opus-mt-es-ro with int8 quantization for efficient CPU inference.
| Property | Value |
|---|---|
| Original model | Helsinki-NLP/opus-mt-es-ro |
| Architecture | MarianMT (encoder-decoder) |
| Encoder layers | 6 |
| Decoder layers | 6 |
| Attention heads | 8 |
| d_model | 512 |
| FFN dimension | 2048 |
| Activation function | swish |
| Vocabulary size | 56140 |
| Max sequence length | 512 |
| Beam size | 4 |
| Quantization | int8 |
| Format | CTranslate2 |
| Tokenizer | SentencePiece (source.spm / target.spm) |
import ctranslate2
import sentencepiece as spm
model_path = "mijuanlo/opus-mt-es-ro-ct2-int8"
sp_source = spm.SentencePieceProcessor(f"{model_path}/source.spm")
sp_target = spm.SentencePieceProcessor(f"{model_path}/target.spm")
translator = ctranslate2.Translator(model_path)
def translate(text: str) -> str:
input_ids = sp_source.encode(text, out_type=str)
results = translator.translate_batch([input_ids], beam_size=4)
output_ids = results[0].hypotheses[0]
return sp_target.decode(output_ids)
print(translate("¡Hola, mundo!"))
from huggingface_hub import snapshot_download
import ctranslate2
import sentencepiece as spm
model_id = "mijuanlo/opus-mt-es-ro-ct2-int8"
model_path = snapshot_download(repo_id=model_id)
translator = ctranslate2.Translator(model_path)
sp_source = spm.SentencePieceProcessor(f"{model_path}/source.spm")
sp_target = spm.SentencePieceProcessor(f"{model_path}/target.spm")
ct2-transformers-converter \
--model Helsinki-NLP/opus-mt-es-ro \
--output_dir opus-mt-es-ro-ct2-int8 \
--quantization int8 \
--force
MIT. The original model from Helsinki-NLP is also MIT.
@inproceedings{tiedemann-2020-tatoeba,
title = {The Tatoeba Translation Challenge – Realistic Data Sets for Low Resource and Multilingual MT},
author = {Tiedemann, J{\"o}rg},
booktitle = {Proceedings of the Fifth Conference on Machine Translation (WMT)},
year = {2020},
publisher = {Association for Computational Linguistics},
}