aina-translator-es-an-onnx

ONNX export of projecte-aina/aina-translator-es-an, Projecte Aina's (Barcelona Supercomputing Center, Language Technologies Unit) Spanish → Aragonese machine translation model. All credit for training data, fine-tuning and evaluation goes to Projecte Aina — see the source model card for training details, BLEU/ChrF numbers, and paper reference.

Aragonese 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-an). 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                  dynamic-quantized (uint8) encoder
int8/decoder_model.onnx                  dynamic-quantized (uint8) decoder
int8/decoder_with_past_model.onnx        dynamic-quantized (uint8) decoder w/ cache
sentencepiece.bpe.model, tokenizer.json, tokenizer_config.json, ...  tokenizer files (NLLB-style SentencePiece)

Model files exceed the single-file size ONNX allows, so fp32 weights are stored as external data (*.onnx_data next to each *.onnx graph file). int8 files are small enough to be single-file.

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-an \
  --task text2text-generation-with-past \
  --no-post-process \
  aina-translator-es-an-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 (optimum.onnxruntime.ORTQuantizer, AVX2 config) was applied to each of the three graphs.

Target-language mechanism

This is a single-direction fine-tune: Spanish → Aragonese only, no target forcing needed at inference time. The base NLLB-200 tokenizer doesn't have a language tag for Aragonese, so Projecte Aina added a new special token, arg_Latn, and set tokenizer_config.json to src_lang: spa_Latn, tgt_lang: arg_Latn. There is no forced_bos_token_id in generation_config.json — the tokenizer's baked-in tgt_lang plus the model's decoder_start_token_id (2) are sufficient; a plain tokenizer(text) + model.generate() call already yields Aragonese output. Do not pass forced_bos_token_id explicitly; arg_Latn is a model-specific token repurposed for this fine-tune, per the source model card.

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.

exact-match rate
ONNX fp32 8/8 = 100.0%
ONNX int8 (dynamic) not separately re-verified against reference; same graphs, expect near-parity

Sample translations observed (es → an/Aragonese):

Spanish Aragonese (Aina / ONNX, identical)
Hola, ¿cómo estás? Ola, cómo yes?
El tiempo hoy es muy bueno. Lo tiempo hue ye muit bueno.
Me gustaría reservar una mesa para dos personas. Me faría goyo reservar una mesa pa dos personas.
¿Dónde está la estación de tren? An ye la estación de tren?
Este libro es muy interesante. Iste libro ye muit interesant.
Los niños juegan en el parque. Los ninos chugan en o parque.
Necesito ayuda con mi ordenador. Amenisto aduya con lo mío ordinador.
La reunión comenzará a las diez de la mañana. La reunión prencipiará a las diez d'o maitín.

Usage

from transformers import AutoTokenizer
from optimum.onnxruntime import ORTModelForSeq2SeqLM

model_id = "TigreGotico/aina-translator-es-an-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))
# Ola, cómo yes?

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-an. Contact for the original model: langtech@bsc.es.

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

Model tree for TigreGotico/aina-translator-es-an-onnx

Quantized
(1)
this model