Views
No views yet
dsfsi/nllb_200_distilled_600m-eng-yor.facebook/nllb-200-distilled-600M on the afriscience-mt
dataset. Licence: Apache-2.0, as declared by the original repository.
This repository only converts the weights to ONNX. All credit for the
model belongs to DSFSI.optimum-cli export onnx --model dsfsi/nllb_200_distilled_600m-eng-yor \
--task text2text-generation-with-past --no-post-process <outdir>.onnx.data -> .onnx_data rename and
proto location rewrite (encoder, decoder and decoder-with-past, plus one
Constant node tensor attribute per file). Verified with a real load from
a cache cleared beforehand.| Path | Precision | Size |
|---|---|---|
*.onnx + *.onnx_data (root) | fp32 | ~7 GB |
int8/*.onnx + int8/*.onnx_data | int8 dynamic | ~5.5 GB |
AutoModelForSeq2SeqLM.generate().1parity:
2 sample_size: 10
3 metric: exact_match
4 fp32_greedy: 1.00 # 10/10
5 fp32_beam4: 1.00 # 10/10
6 int8_greedy: 0.90 # 9/10
7 int8_beam4: 0.80 # 8/10| Decoding | fp32 (n=10) | int8 (n=10) |
|---|---|---|
| greedy | 100% (10/10) | 90% (9/10) |
| beam=4 | 100% (10/10) | 80% (8/10) |
forced_bos_token_id in generation_config.json - you must
pass it explicitly at generate time using NLLB's flores_code language
tags (eng_Latn, yor_Latn, not plain ISO 639-1 codes):1tokenizer.src_lang = "eng_Latn"
2forced_bos_token_id = tokenizer.convert_tokens_to_ids("yor_Latn")
3model.generate(**inputs, forced_bos_token_id=forced_bos_token_id, ...)1from transformers import AutoTokenizer
2from optimum.onnxruntime import ORTModelForSeq2SeqLM
3
4repo = "TigreGotico/nllb_200_distilled_600m-eng-yor-onnx"
5tok = AutoTokenizer.from_pretrained(repo)
6tok.src_lang = "eng_Latn"
7model = ORTModelForSeq2SeqLM.from_pretrained(repo, use_cache=True, use_merged=False)
8
9enc = tok("The weather is very nice today.", return_tensors="pt")
10tgt_id = tok.convert_tokens_to_ids("yor_Latn")
11out = model.generate(**enc, forced_bos_token_id=tgt_id, num_beams=4, max_new_tokens=64)
12print(tok.batch_decode(out, skip_special_tokens=True)[0])
13# -> Ojú-ọjọ́ dára gan-an lọ́jọ́ òní.subfolder="int8".