CoolFace
Modelpublic

TigreGotico/aina-translator-zh-ca-onnx

sourceHugging Faceapache-2.0updated 2mo agoView on Hugging Face
0likes7downloads
Model Card

aina-translator-zh-ca-onnx

ONNX export of `projecte-aina/aina-translator-zh-ca`, Projecte Aina's (Barcelona Supercomputing Center, Language Technologies Unit) Chinese → Catalan machine translation model, fine-tuned from facebook/m2m100_1.2B. 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.

Licence

apache-2.0, verbatim as declared on the source model card (projecte-aina/aina-translator-zh-ca). 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, vocab.json, tokenizer_config.json, ...   tokenizer files (M2M100Tokenizer)

Export

Base architecture: M2M100ForConditionalGeneration (transformers model_type: m2m_100), fine-tuned by Projecte Aina from facebook/m2m100_1.2B.

bash
optimum-cli export onnx \
  --model projecte-aina/aina-translator-zh-ca \
  --task text2text-generation-with-past \
  --no-post-process \
  aina-translator-zh-ca-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

Despite the m2m_100 architecture (which normally supports many-to-many translation via a >>lang<</forced_bos_token_id mechanism), this checkpoint is a single-direction fine-tune: Chinese → Catalan only. The upstream model card's own usage example calls tokenizer(sentence, return_tensors="pt") + model.generate(...) with no src_lang, tgt_lang, or forced_bos_token_id set — the tokenizer's tokenizer_config.json ships src_lang: "en" (a leftover default, not meaningful) and tgt_lang: null, and generation_config.json has no forced_bos_token_id. The fine-tuning baked the zh→ca direction into the weights directly; do not set language codes or forced BOS tokens, just call tokenizer(text) → model.generate() exactly like the upstream example.

Parity

8 held-out Chinese sentences, num_beams=4, max_new_tokens=64, compared against the original PyTorch model (transformers.AutoModelForSeq2SeqLM) with identical decoding settings.

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

Sample translations observed (zh → ca):

ChineseCatalan (Aina / ONNX, identical)
欢迎来到 Aina 项目!Benvingut al projecte Aina!
你好,你今天怎么样?Hola, com estàs avui?
今天天气很好。Avui fa bon temps.
我想预定两个人的桌子。M'agradaria reservar una taula per a dos.
火车站在哪里?On és l'estació de tren?
这本书很有意思。Aquest llibre és interessant.
孩子们在公园里玩。Els nens juguen al parc.
我需要帮助解决我的电脑问题。Necessito ajuda per resoldre el meu problema informàtic.

Usage

python
from transformers import AutoTokenizer
from optimum.onnxruntime import ORTModelForSeq2SeqLM

model_id = "TigreGotico/aina-translator-zh-ca-onnx"

tokenizer = AutoTokenizer.from_pretrained(model_id)
model = ORTModelForSeq2SeqLM.from_pretrained(model_id)  # fp32
# int8: ORTModelForSeq2SeqLM.from_pretrained(model_id, subfolder="int8")

text = "欢迎来到 Aina 项目!"
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))
# Benvingut al projecte Aina!

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