--- license: mit language: - as - bn - brx - doi - gu - hi - kn - ks - kok - mai - ml - mni - mr - ne - or - pa - sa - sat - sd - ta - te - ur - en tags: - translation - onnx - indic - indictrans2 - browser - fp32 pipeline_tag: translation library_name: onnx base_model: ai4bharat/indictrans2-indic-en-1B --- # IndicTrans2 1B (indic→en) — ONNX bundle [FP32 (Full Precision)] > [!TIP] > This model is part of a suite of optimized/quantized ONNX versions of the base model. > Other variants in this direction: > - **FP32 (Full Precision / Base)**: [`hari31416/indictrans2-indic-en-1B-ONNX`](https://huggingface.co/hari31416/indictrans2-indic-en-1B-ONNX) *(Current)* > - **FP16 (Half Precision)**: [`hari31416/indictrans2-indic-en-1B-ONNX-fp16`](https://huggingface.co/hari31416/indictrans2-indic-en-1B-ONNX-fp16) > - **INT8 (Dynamic Quantization)**: [`hari31416/indictrans2-indic-en-1B-ONNX-int8`](https://huggingface.co/hari31416/indictrans2-indic-en-1B-ONNX-int8) > - **Q4F16 (4-bit Block Quantization)**: [`hari31416/indictrans2-indic-en-1B-ONNX-q4f16`](https://huggingface.co/hari31416/indictrans2-indic-en-1B-ONNX-q4f16) ONNX-exported and quantized version of [`ai4bharat/indictrans2-indic-en-1B`](https://huggingface.co/ai4bharat/indictrans2-indic-en-1B) for in-browser and local edge inference. - **Precision**: FP32 (Full Precision) - **Description**: Baseline full-precision ONNX export. - **Source Pipeline & Details**: For pipeline details, benchmarks, and usage instructions, see the [indictrans2-onnx-export GitHub repository](https://github.com/Hari31416/indictrans2-onnx-export). Built for use with [Transformers.js](https://github.com/huggingface/transformers.js) and [onnxruntime-web](https://onnxruntime.ai/docs/get-started/with-javascript.html) 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](./overall.png) ![Language-Level Parity](./languages.png) ![Category breakdown](./categories.png) ## 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 | 4.88 GB | 100.00% | 100.00% | 100.00 | 171.8 ms | 1.000x | | FP16 | 2.44 GB | 99.91% | 99.91% | 99.98 | 180.5 ms | 0.952x | | INT8 | 1.22 GB | 94.18% | 94.18% | 97.94 | 76.4 ms | 2.196x | | Q4F16 | 625.0 MB | 87.55% | 87.55% | 95.17 | 85.5 ms | 1.962x | ## Files - `encoder_model.onnx` (and optional `.onnx.data` weights sidecar) - `decoder_model.onnx` (and optional `.onnx.data` weights sidecar) - `decoder_with_past_model.onnx` (and optional `.onnx.data` weights sidecar) - `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) ```python # 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-1B-ONNX") print(model.translate("चुनाव कौन जीतेगा?", src_lang="hin_Deva", tgt_lang="eng_Latn")) ``` Required packages: ```bash pip install onnxruntime tokenizers huggingface-hub ``` ## License MIT (preserved from upstream AI4Bharat).