m2m100_418M_ewe_fr_rel_news_ft-onnx
ONNX export of masakhane/m2m100_418M_ewe_fr_rel_news_ft.
Translation direction: Ewe (ewe) -> French (fr).
Attribution
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.
Export
optimum-cli export onnx --model masakhane/m2m100_418M_ewe_fr_rel_news_ft \
--task text2text-generation-with-past --no-post-process <outdir>
The int8 folder was made with onnxruntime.quantization.quantize_dynamic
(QuantType.QInt8, EnableSubgraph=True).
Files
| Path | Precision | Size |
|---|---|---|
*.onnx (root) |
fp32 | 4525 MB |
int8/*.onnx |
int8 dynamic | 1156 MB |
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-ewe test split (source: masakhane-io/lafand-mt,
data/json_files/fr-ewe/test.json), PyTorch original vs ONNX, exact string match:
- fp32,
num_beams=1(greedy): 100% (8/8) - fp32,
num_beams=4: 100% (8/8) - int8,
num_beams=1(greedy): 25% (2/8, reported, not gated) - int8,
num_beams=4: 50% (4/8, reported, not gated)
int8 divergences are topically coherent paraphrases, not garbage output (see the export script's parity log); the fp32 graph is the one this repository gates on.
Selecting the language
This is a single-direction model. The target language is already fixed in
generation_config.json via forced_bos_token_id (__fr__, real French), so you
do not set it yourself. You must set the source language on the tokenizer:
tokenizer.src_lang = "sw"
Masakhane reused the existing M2M100 __sw__ (Swahili) token as a stand-in for Ewe,
which M2M100 does not cover - the same stand-in the reverse-direction
fr-ewe model
uses for its Ewe target. Using a different value silently degrades output.
Usage
from transformers import AutoTokenizer
from optimum.onnxruntime import ORTModelForSeq2SeqLM
tok = AutoTokenizer.from_pretrained("TigreGotico/m2m100_418M_ewe_fr_rel_news_ft-onnx")
tok.src_lang = "sw"
model = ORTModelForSeq2SeqLM.from_pretrained("TigreGotico/m2m100_418M_ewe_fr_rel_news_ft-onnx")
enc = tok("Le Côte d'Ivoire: Ahmed si nye atiglinyi ahanola la ga dze kpɔ, eye wòle nu gblem le yiyim.", return_tensors="pt")
out = model.generate(**enc, num_beams=4, max_new_tokens=64)
print(tok.batch_decode(out, skip_special_tokens=True)[0])
# -> Côte d'Ivoire : Ahmed, l'homme alcoolique d'un éléphant, a déjà fait ses preuves et il est en train de se détériorer
For the int8 build, pass subfolder="int8".
- Downloads last month
- 3
Model tree for TigreGotico/m2m100_418M_ewe_fr_rel_news_ft-onnx
Base model
masakhane/m2m100_418M_ewe_fr_rel_news_ft