opus-mt-pt-ca-onnx

ONNX export of Helsinki-NLP/opus-mt-pt-ca, a MarianMT model for direct Portuguese → Catalan translation.

Licence: apache-2.0 (verbatim from the upstream model card).

Attribution: model trained and published by Helsinki-NLP / University of Helsinki as part of the OPUS-MT project (Tatoeba-Challenge, por-cat, opus-2020-06-17). This repository only republishes an ONNX conversion of their weights; no model changes were made.

Target-language token

This model is a single-pair model (Portuguese → Catalan only). No >>xxx<< target token is required or supported.

File layout

encoder_model.onnx, decoder_model.onnx, decoder_with_past_model.onnx      (fp32, repo root)
source.spm, target.spm, vocab.json, tokenizer_config.json, special_tokens_map.json, config.json, generation_config.json
int8/
  encoder_model.onnx, decoder_model.onnx, decoder_with_past_model.onnx    (dynamic QUInt8 quantization)
  (+ copies of the tokenizer files)

Export command

optimum-cli export onnx --model Helsinki-NLP/opus-mt-pt-ca \
  --task text2text-generation-with-past --no-post-process ./fp32

int8: onnxruntime.quantization.quantize_dynamic(weight_type=QUInt8) applied to each of the three graphs independently, written to int8/.

Parity

8 Portuguese sentences, PyTorch (MarianMTModel) vs ONNX (ORTModelForSeq2SeqLM), num_beams=4, max_new_tokens=64, exact string match after decoding:

  • fp32: 8/8 = 100%
  • int8: 7/8 = 87.5% (one sentence reordered but semantically equivalent: "El temps està bé avui." vs "Avui el temps està bé.")

Usage

from transformers import AutoTokenizer
from optimum.onnxruntime import ORTModelForSeq2SeqLM

tok = AutoTokenizer.from_pretrained("TigreGotico/opus-mt-pt-ca-onnx")
model = ORTModelForSeq2SeqLM.from_pretrained("TigreGotico/opus-mt-pt-ca-onnx")

text = "O tempo está bom hoje."
ids = model.generate(**tok(text, return_tensors="pt"), num_beams=4, max_new_tokens=64)
print(tok.decode(ids[0], skip_special_tokens=True))
# El temps està bé avui.

For int8, pass subfolder="int8" instead.

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

Model tree for TigreGotico/opus-mt-pt-ca-onnx

Quantized
(1)
this model