Instructions to use TigreGotico/aina-translator-es-ast-onnx with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use TigreGotico/aina-translator-es-ast-onnx with Transformers:
# Use a pipeline as a high-level helper # Warning: Pipeline type "translation" is no longer supported in transformers v5. # You must load the model directly (see below) or downgrade to v4.x with: # 'pip install "transformers<5.0.0' from transformers import pipeline pipe = pipeline("translation", model="TigreGotico/aina-translator-es-ast-onnx")# Load model directly from transformers import AutoTokenizer, AutoModelForSeq2SeqLM tokenizer = AutoTokenizer.from_pretrained("TigreGotico/aina-translator-es-ast-onnx") model = AutoModelForSeq2SeqLM.from_pretrained("TigreGotico/aina-translator-es-ast-onnx", device_map="auto") - Notebooks
- Google Colab
- Kaggle
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.
| exact-match rate | |
|---|---|
| ONNX fp32 | 8/8 = 100.0% |
| ONNX int8 (dynamic) | 7/8 = 87.5% |
(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):
| Spanish | Asturian |
|---|---|
| Hola, ¿cómo estás? | Hola, ¿cuál ye'l to estáu? |
| El tiempo hoy es muy bueno. | El tiempu güei ye mui bonu. |
| Me gustaría reservar una mesa para dos personas. | Gustaríame reservar una mesa pa dos persones. |
| ¿Dónde está la estación de tren? | ¿Onde ta la estación de tren? |
| Este libro es muy interesante. | Esti llibru ye perinteresante. |
| Los niños juegan en el parque. | Los neños xueguen nel parque. |
| Necesito ayuda con mi ordenador. | Faime falta ayuda col mio ordenador. |
| La reunión comenzará a las diez de la mañana. | La xunta entamará a les diez de la mañana. |
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.
- Downloads last month
- 5
Model tree for TigreGotico/aina-translator-es-ast-onnx
Base model
facebook/nllb-200-distilled-600M