TigreGotico/aina-translator-es-ast-onnx
aina-translator-es-ast-onnx
ONNX export of `projecte-aina/aina-translator-es-ast`, Projecte Aina's (Barcelona Supercomputing Center, Language Technologies Unit) Spanish → Asturian machine translation model. All credit for training data, fine-tuning and evaluation goes to Projecte Aina — see the source model card for training details and evaluation numbers.
Asturian has almost no other machine-translation coverage, which is why this export exists: to make the model runnable with onnxruntime (CPU, no PyTorch/CUDA dependency) via optimum.
Licence
cc-by-nc-4.0, verbatim as declared on the source model card (projecte-aina/aina-translator-es-ast). Same licence applies to this derived ONNX export.
Files
encoder_model.onnx(_data) fp32 encoder
decoder_model.onnx(_data) fp32 decoder (no cache)
decoder_with_past_model.onnx(_data) fp32 decoder (with KV cache)
int8/encoder_model.onnx(_data) dynamic-quantized (uint8) encoder
int8/decoder_model.onnx(_data) dynamic-quantized (uint8) decoder
int8/decoder_with_past_model.onnx(_data) dynamic-quantized (uint8) decoder w/ cache
sentencepiece.bpe.model, tokenizer.json, tokenizer_config.json, ... tokenizer files (NLLB-style SentencePiece)fp32 total: ~6.9 GB. int8 total: ~1.8 GB.
Weights are stored as external data (*.onnx_data next to each *.onnx graph file — note the underscore, not a dot, which is what transformers/optimum expect when loading from the Hub).
Export
Base architecture: M2M100ForConditionalGeneration (transformers model_type: m2m_100), fine-tuned by Projecte Aina from facebook/nllb-200-distilled-600M.
optimum-cli export onnx \
--model projecte-aina/aina-translator-es-ast \
--task text2text-generation-with-past \
--no-post-process \
aina-translator-es-ast-onnx--no-post-process is required: optimum's decoder-merge step OOMs on this model size on constrained hardware. As a result the ONNX export ships an un-merged decoder_model.onnx (no cache) and decoder_with_past_model.onnx (with cache) instead of a single decoder_model_merged.onnx.
int8 dynamic quantization (onnxruntime.quantization.quantize_dynamic, QUInt8 weights) was applied to each of the three graphs.
Target-language mechanism
Single-direction fine-tune: Spanish → Asturian only, no target forcing needed at inference time. The tokenizer's tokenizer_config.json fixes src_lang: spa_Latn, tgt_lang: ast_Latn — this is the real NLLB-200 Asturian tag (unlike the Aranese/Occitan sibling model, which needed a new custom tag). There is no forced_bos_token_id in generation_config.json; a plain tokenizer(text) + model.generate() call already yields Asturian output — the fixed tgt_lang plus decoder_start_token_id (2) are sufficient.
Parity
8 held-out Spanish sentences, num_beams=4, max_new_tokens=64, compared against the original PyTorch model (transformers.AutoModelForSeq2SeqLM) with identical decoding settings.
(The one int8 divergence was a fluent paraphrase, not a wrong-language or garbled output: "¿Cómo ta?" vs "¿Cuál ye'l to estáu?" for "¿cómo estás?".)
Sample translations observed (es → ast):
Usage
from transformers import AutoTokenizer
from optimum.onnxruntime import ORTModelForSeq2SeqLM
model_id = "TigreGotico/aina-translator-es-ast-onnx"
tokenizer = AutoTokenizer.from_pretrained(model_id)
model = ORTModelForSeq2SeqLM.from_pretrained(model_id) # fp32
# int8: ORTModelForSeq2SeqLM.from_pretrained(model_id, subfolder="int8")
text = "Hola, ¿cómo estás?"
ids = tokenizer(text, return_tensors="pt").input_ids
out = model.generate(ids, num_beams=4, max_new_tokens=64)
print(tokenizer.decode(out[0], skip_special_tokens=True))
# Hola, ¿cuál ye'l to estáu?Attribution
All modeling and training work is by Projecte Aina (Language Technologies Unit, Barcelona Supercomputing Center) — this repository only republishes an ONNX conversion of their weights for offline/CPU inference. Source model: projecte-aina/aina-translator-es-ast. Contact for the original model: langtech@bsc.es.
