OPUS-MT Spanish to French (CTranslate2 int8)

This model is a CTranslate2 conversion of Helsinki-NLP/opus-mt-es-fr with int8 quantization for efficient CPU inference.

Languages

  • Source language (code): Spanish (es)
  • Target language (code): French (fr)

Model details

Property Value
Original model Helsinki-NLP/opus-mt-es-fr
Architecture MarianMT (encoder-decoder)
Encoder layers 6
Decoder layers 6
Attention heads 8
d_model 512
FFN dimension 2048
Activation function swish
Vocabulary size 74822
Max sequence length 512
Beam size 4
Quantization int8
Format CTranslate2
Tokenizer SentencePiece (source.spm / target.spm)

Usage

With CTranslate2

import ctranslate2
import sentencepiece as spm

model_path = "mijuanlo/opus-mt-es-fr-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!"))

Load from Hugging Face Hub

from huggingface_hub import snapshot_download
import ctranslate2
import sentencepiece as spm

model_id = "mijuanlo/opus-mt-es-fr-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")

Conversion details

ct2-transformers-converter \
    --model Helsinki-NLP/opus-mt-es-fr \
    --output_dir opus-mt-es-fr-ct2-int8 \
    --quantization int8 \
    --force

License

MIT. The original model from Helsinki-NLP is also MIT.

Citation

@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},
}
Downloads last month
16
Inference Providers NEW
This model isn't deployed by any Inference Provider. 🙋 Ask for provider support

Collection including mijuanlo/opus-mt-es-fr-ct2-int8