This model is designed for lightweight, fast, and high-quality translation from English into major Indic languages while maintaining the conversational capabilities inherited from Gemma-3.
The dataset contains parallel English–Indic sentence pairs covering multiple domains and language families.
1Translate to {Target Language}:
2
3{English Sentence}
1Translate to Telugu:
2
3Artificial Intelligence is changing healthcare.
1import torch
2from transformers import AutoTokenizer, AutoModelForCausalLM
3
4MODEL_NAME = "ManiKumarAdapala/Gemma3-En2Indic-NMT-270M"
5
6tokenizer = AutoTokenizer.from_pretrained(MODEL_NAME)
7tokenizer.padding_side = "left"
8
9model = AutoModelForCausalLM.from_pretrained(
10 MODEL_NAME,
11 dtype=torch.bfloat16,
12 attn_implementation="flash_attention_2",
13 device_map={"": 0},
14)
15
16model.config.use_cache = True
17model.eval()
18
19EOT = tokenizer.convert_tokens_to_ids("<end_of_turn>")
20
21
22@torch.inference_mode()
23def translate(sentences, language):
24
25 if isinstance(sentences, str):
26 sentences = [sentences]
27
28 prompts = [
29 tokenizer.apply_chat_template(
30 [
31 {
32 "role": "user",
33 "content": f"Translate to {language}:\n\n{s}",
34 }
35 ],
36 tokenize=False,
37 add_generation_prompt=True,
38 )
39 for s in sentences
40 ]
41
42 inputs = tokenizer(
43 prompts,
44 return_tensors="pt",
45 padding=True,
46 add_special_tokens=False,
47 ).to(model.device)
48
49 outputs = model.generate(
50 **inputs,
51 max_new_tokens=256,
52 do_sample=False,
53 num_beams=5,
54 eos_token_id=[
55 tokenizer.eos_token_id,
56 EOT,
57 ],
58 pad_token_id=tokenizer.pad_token_id,
59 )
60
61 generated = outputs[:, inputs["input_ids"].shape[1]:]
62
63 return tokenizer.batch_decode(
64 generated,
65 skip_special_tokens=True,
66 )
67
68
69sentence = "Artificial Intelligence is transforming agriculture."
70
71translation = translate(sentence, "Hindi")
72
73print(translation[0])
1max_new_tokens = 256
2num_beams = 5
3do_sample = False
4use_cache = True
5padding_side = "left"
6dtype = torch.bfloat16
7attn_implementation = "flash_attention_2"
These settings are the same as those used in the provided inference notebook and are recommended for obtaining deterministic, high-quality translations.
The model was evaluated using sentence pairs from the BPCC dataset.
Like most compact multilingual translation models, this model has a few limitations.
1@misc{Gemma3-En2Indic-NMT-270M,
2 title = {Gemma3-En2Indic-NMT-270M: English to Indic Neural Machine Translation},
3 author = {Adapala, Mani Kumar},
4 year = {2026},
5 publisher = {Hugging Face},
6 url = {https://huggingface.co/ManiKumarAdapala/Gemma3-En2Indic-NMT-270M}
7}