Downloads · 30 days
0
akki244/indictrans2-onnx-int8
indictrans2-onnx-int8 is a machine learning model from akki244. Use it for the machine learning task on the model card, and read the license before you ship it in a product.
Quantized version of AI4Bharat's IndicTrans2 for efficient on-device Indian language translation.
Downloads · 30 days
0
Access
Public
Updated Jan 2, 2026
Repo size
218 MB
Likes
0
Public
Click a slice to open those files.
.onnx218 MB · 100%
From the Hugging Face model README
Quantized version of AI4Bharat's IndicTrans2 for efficient on-device Indian language translation.
encoder_int8.onnx (116 MB) - Quantized encoder
decoder_int8.onnx (92 MB) - Quantized decoder with self-attention
vocab_src.json - Source vocabulary (Indian languages)vocab_tgt.json - Target vocabulary (English)special_tokens.json - Special tokens mapping| Model | Original (FP32) | Quantized (INT8) | Reduction |
|---|---|---|---|
| Encoder | ~464 MB | 116 MB | ~75% |
| Decoder | ~368 MB | 92 MB | ~75% |
| Total | ~832 MB | 208 MB | ~75% |
import onnxruntime as ort
import json
import numpy as np
# Load models
encoder_session = ort.InferenceSession("encoder_int8.onnx")
decoder_session = ort.InferenceSession("decoder_int8.onnx")
# Load vocabularies
with open("vocab_src.json") as f:
src_vocab = json.load(f)
with open("vocab_tgt.json") as f:
tgt_vocab = json.load(f)
# Tokenize input (add language tags)
text = "नमस्ते दुनिया" # Hello world in Hindi
tokens = tokenize(f"<2en> <hin> {text}", src_vocab)
input_ids = np.array([tokens], dtype=np.int64)
# Run encoder
encoder_output = encoder_session.run(
["hidden_states"],
{"input_ids": input_ids}
)[0]
# Autoregressive decoding
generated_ids = [2] # Start token
max_length = 50
for _ in range(max_length):
decoder_ids = np.array([generated_ids], dtype=np.int64)
logits = decoder_session.run(
["logits"],
{
"input_ids": decoder_ids,
"encoder_hidden_states": encoder_output
}
)[0]
next_token = np.argmax(logits[0, -1, :])
if next_token == 2: # EOS token
break
generated_ids.append(int(next_token))
# Decode output
translation = detokenize(generated_ids, tgt_vocab)
print(translation) # "Hello world"
Translation from any of these 22 languages to English:
Assamese, Bengali, Bodo, Dogri, Gujarati, Hindi, Kannada, Kashmiri, Konkani, Maithili, Malayalam, Manipuri, Marathi, Nepali, Odia, Punjabi, Sanskrit, Santali, Sindhi, Tamil, Telugu, Urdu
Input Text (+ lang tags)
↓
Tokenization
↓
Encoder (Transformer, 1B params)
↓ [hidden_states]
Decoder (Autoregressive)
↓
Output Tokens
↓
English Translation
Tested on Android (Pixel 7):
Use these tags for source language:
<2en> - Translate to English<hin> - Hindi<ben> - Bengali<tam> - Tamil<tel> - TeluguExample: <2en> <hin> यह एक परीक्षण है
@article{gala2023indictrans,
title={IndicTrans2: Towards High-Quality and Accessible Machine Translation Models for all 22 Scheduled Indian Languages},
author={Gala, Jay and others},
journal={Transactions on Machine Learning Research},
year={2023}
}
AI4Bharat - IIT Madras
Original model: https://huggingface.co/ai4bharat/indictrans2-indic-en-1B
MIT License (same as original model)
Quantized for mobile deployment | January 2026