The original model was trained by Masakhane
(masakhane-io/lafand-mt) as part of MAFAND-MT
(Adelani et al., NAACL 2022, "A Few Thousand Translations Go a Long Way!").
It is a fine-tune of facebook/m2m100_418M on JW300 plus the MAFAND news corpus.
Licence: AFL-3.0, as declared by the original repository. This repository only converts
the weights to ONNX. All credit for the model belongs to Masakhane.
Encoder, decoder and decoder-with-past are separate graphs (--no-post-process);
the merged decoder is not produced because merging exhausts memory on this model.
Parity
8 sentences from the MAFAND-MT fr-fon test split,
PyTorch original vs ONNX, num_beams=4, max_new_tokens=64, exact string match:
fp32: 100%
int8: 62% (reported, not gated)
Selecting the language
This is a single-direction model. The target language is already fixed in
config.json via forced_bos_token_id, so you do not set it yourself.
You must set the source language on the tokenizer:
tokenizer.src_lang = "sw"
Masakhane reused existing M2M100 language tokens as stand-ins for languages M2M100
does not cover, so src_lang is "sw" here, which is not the ISO code of
Fon. Using a different value silently degrades output.
Usage
python
1from transformers import AutoTokenizer
2from optimum.onnxruntime import ORTModelForSeq2SeqLM
34tok = AutoTokenizer.from_pretrained("TigreGotico/m2m100_418M_fon_fr_rel_news_ft-onnx")5tok.src_lang ="sw"6model = ORTModelForSeq2SeqLM.from_pretrained("TigreGotico/m2m100_418M_fon_fr_rel_news_ft-onnx")78enc = tok("Tò ye sɔ́ dó w‘azɔ̌ ná lɛ́ɛ mɛ ɔ́ 56 ɖo 100 jí jɛ́n ɖó sɛ́n kpódó titomɛ kpíkpé kpán ɖo kpɔ́nínɔ súnnu kpó nyɔ̌nu tɔ́n kpán kɔ́li.", return_tensors="pt")9out = model.generate(**enc, num_beams=4, max_new_tokens=64)10print(tok.batch_decode(out, skip_special_tokens=True)[0])11# -> Au nombre de ces pays affectés, 56 sont sur 100 parce qu’il s’agit d’un respect de la législation et d’un respect de la législation.