Instructions to use TigreGotico/opus-mt-itc-itc-onnx with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers.js
How to use TigreGotico/opus-mt-itc-itc-onnx with Transformers.js:
// npm i @huggingface/transformers import { pipeline } from '@huggingface/transformers'; // Allocate pipeline const pipe = await pipeline('translation', 'TigreGotico/opus-mt-itc-itc-onnx');
opus-mt-itc-itc-onnx
ONNX export of Helsinki-NLP/opus-mt-itc-itc, a MarianMT multilingual translation model covering Italic languages (Italian, Catalan, Romansh, Spanish, Romanian, Galician, Sardinian, Corsican, Walloon, Portuguese, Occitan, Aragonese, Indonesian, French, Haitian Creole, and more) translating between each other.
Exported for use with optimum.onnxruntime.ORTModelForSeq2SeqLM /
onnxruntime, e.g. in phoonnx / OVOS translation routing.
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, itc-itc,
opus-2020-07-07). This repository only republishes an ONNX conversion of their weights; no model changes were
made.
Why this model
This model unblocks direct Portuguese → Spanish translation (opus-mt-pt-es / opus-mt-es-pt are both
gone from the Helsinki-NLP org), avoiding a pivot through English for pt→eu style routing.
CRITICAL: target-language token required
This is a multilingual, many-to-many model. The target language is selected by a >>xxx<< token
prepended to the input text — transformers/optimum does not add this automatically. Omitting it does
not raise an error: the model silently produces fluent text in an unpredictable language.
Example: >>spa<< O tempo está bom hoje. → El tiempo es bueno hoy. (Portuguese → Spanish)
Full list of valid target tokens
>>arg<< >>ast<< >>bjn<< >>cat<< >>cos<< >>egl<< >>fra<< >>frm_Latn<< >>gcf_Latn<< >>glg<< >>hat<< >>ind<<
>>ita<< >>lad<< >>lad_Latn<< >>lat_Grek<< >>lat_Latn<< >>lij<< >>lld_Latn<< >>lmo<< >>mwl<< >>oci<< >>pap<<
>>pcd<< >>pms<< >>por<< >>roh<< >>ron<< >>scn<< >>spa<< >>srd<< >>vec<< >>wln<< >>zsm_Latn<<
(source: upstream model card language(s) list — arg ast bjn cat cos egl fra frm_Latn gcf_Latn glg hat ind ita lad lad_Latn lat_Grek lat_Latn lij lld_Latn lmo mwl oci pap pcd pms por roh ron scn spa srd vec wln zsm_Latn)
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-itc-itc \
--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 fp32/int8/.
Parity
8 sentences covering pt→es, es→pt, ca→es, pt→ca, each with the correct >>xxx<< token, PyTorch (MarianMTModel)
vs ONNX (ORTModelForSeq2SeqLM), num_beams=4, max_new_tokens=64, exact string match after decoding:
- fp32: 8/8 = 100%
- int8: 8/8 = 100%
Usage
from transformers import AutoTokenizer
from optimum.onnxruntime import ORTModelForSeq2SeqLM
tok = AutoTokenizer.from_pretrained("TigreGotico/opus-mt-itc-itc-onnx")
model = ORTModelForSeq2SeqLM.from_pretrained("TigreGotico/opus-mt-itc-itc-onnx")
text = ">>spa<< 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 tiempo es bueno hoy.
For int8, pass subfolder="int8" instead.
- Downloads last month
- 13
Model tree for TigreGotico/opus-mt-itc-itc-onnx
Base model
Helsinki-NLP/opus-mt-itc-itc