IndicTrans2 200M (indic→en) — ONNX bundle [Q4F16 (4-bit Block Quantization, Lossy)]

This model is part of a suite of optimized/quantized ONNX versions of the base model. Other variants in this direction:

ONNX-exported and quantized version of ai4bharat/indictrans2-indic-en-dist-200M for in-browser and local edge inference.

  • Precision: Q4F16 (4-bit Block Quantization, Lossy)
  • Description: 4-bit quantization with float16 scale factors and block size of 32. Reduces model size significantly.
  • Source Pipeline & Details: For pipeline details, benchmarks, and usage instructions, see the indictrans2-onnx-export GitHub repository.

Built for use with Transformers.js and onnxruntime-web in the browser, with fast BPE tokenizer.json files that don't require the SentencePiece WASM runtime.

Performance Visualizations

These charts show overall tradeoffs, language-level parity, and category breakdown.

Overall Tradeoffs Language-Level Parity Category breakdown

Performance Tradeoffs & Size Comparison

Compared against the FP32 ONNX oracle on the golden evaluation fixtures.

Format Model Size Exact Match (Token) Exact Match (Text) SacreBLEU (Raw) Latency (Mean) Speedup vs. FP32
FP32 1.19 GB 100.00% 100.00% 100.00 12.2 ms 1.000x
FP16 627.2 MB 99.91% 99.91% 99.96 14.3 ms 0.849x
INT8 319.7 MB 85.64% 85.64% 94.34 10.1 ms 1.171x
Q4F16 358.6 MB 73.36% 73.36% 88.31 15.8 ms 0.742x

Language-Level Parity (Q4F16)

Exact match rates and translation quality (SacreBLEU / chrF) per language pair under this precision:

Language Code Total Fixtures Token Match Rate Text Match Rate SacreBLEU SacreBLEU (chrF)
eng_Latn 1100 73.4% 73.4% 88.31 93.92

Category-Level Parity (Q4F16)

Exact match rates and translation quality grouped by category types:

Category Total Fixtures Token Match Rate Text Match Rate SacreBLEU SacreBLEU (chrF)
Generic 286 67.1% 67.1% 83.93 91.80
Lexicon 264 65.9% 65.9% 86.83 92.67
Numerals 264 79.9% 79.9% 92.22 96.31
Politics 286 80.4% 80.4% 90.23 94.93

Translation Mismatch Examples

Here is a sample of up to 5 translation mismatches compared to the FP32 oracle. Many mismatches represent minor synonym differences or spacing variations.

Mismatch #1 (Category: Lexicon)

  • Source (asm_Beng → eng_Latn): মই দিল্লীলৈ বিমানৰ টিকট এখন বুক কৰিব বিচাৰো।
  • Expected (FP32): I want to book a flight ticket to Delhi.
  • Actual (Q4F16): I would like to book a flight ticket to Delhi.

Mismatch #2 (Category: Lexicon)

  • Source (asm_Beng → eng_Latn): পেট্ৰ "লৰ মূল্য পাঁচ টকা বৃদ্ধি পাইছে।
  • Expected (FP32): The price of petrol has been increased by five rupees.
  • Actual (Q4F16): The price of petrol has been hiked by Rs.

Mismatch #3 (Category: Numerals)

  • Source (asm_Beng → eng_Latn): বিশ্ববিদ্যালয়খনত এখন নতুন পুথিভঁৰাল উদ্বোধন কৰা হয়।
  • Expected (FP32): A new library was opened at the university.
  • Actual (Q4F16): A new library was inaugurated at the university.

Mismatch #4 (Category: Lexicon)

  • Source (asm_Beng → eng_Latn): স্থানীয় চৰকাৰে পথবোৰ মেৰামতি কৰি আছে।
  • Expected (FP32): The roads are being repaired by the local government.
  • Actual (Q4F16): The local government is repairing the roads.

Mismatch #5 (Category: Generic)

  • Source (asm_Beng → eng_Latn): কৃত্ৰিম বুদ্ধিমত্তাই শিক্ষাৰ ক্ষেত্ৰত পৰিৱৰ্তন কঢ়িয়াই আহিছে।
  • Expected (FP32): Artificial intelligence is changing education.
  • Actual (Q4F16): Artificial intelligence is transforming education.

Files

  • encoder_model.onnx (and optional .onnx.data weights sidecar)
  • decoder_model.onnx and decoder_with_past_model.onnx (share decoder_shared.onnx.data when present)
  • translate.py — self-contained Python inference helper (see Usage below)
  • Fast tokenizer config files (tokenizer_src.json, tokenizer_tgt.json, tokenizer_meta.json)
  • Model configuration configs (config.json, generation_config.json)

Usage Example (Python, onnxruntime)

# translate.py is included in this repo alongside the ONNX bundle.
# You can also find it (and read the full source) at:
#   https://github.com/Hari31416/indictrans2-onnx-export/blob/main/src/translate.py

from translate import IndicTransONNX

# Pass a HF repo ID for automatic download, or a local bundle directory path
model = IndicTransONNX("hari31416/indictrans2-indic-en-dist-200M-ONNX-q4f16")
print(model.translate("चुनाव कौन जीतेगा?", src_lang="hin_Deva", tgt_lang="eng_Latn"))

Required packages:

pip install onnxruntime tokenizers huggingface-hub

License

MIT (preserved from upstream AI4Bharat).

Downloads last month
5
Inference Providers NEW
This model isn't deployed by any Inference Provider. 🙋 Ask for provider support

Model tree for hari31416/indictrans2-indic-en-dist-200M-ONNX-q4f16

Quantized
(5)
this model

Collection including hari31416/indictrans2-indic-en-dist-200M-ONNX-q4f16