--- license: apache-2.0 language: - en - hi - bn - gu - kn - ml - mr - or - pa - ta - te - as - ur - ks - sa library_name: transformers pipeline_tag: translation base_model: google/gemma-3-270m-it tags: - translation - machine-translation - english-to-indic - indic - multilingual - gemma-3 - gemma3 - bpcc - ai4bharat - flash-attention - bfloat16 - transformers --- # Gemma-3-270M English → Indic Translator A fine-tuned version of **Gemma-3-270m-it** for multilingual machine translation from **English to 14 Indic languages**. 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. # Model Details | Property | Value | |----------|-------| | **Base Model** | google/gemma-3-270m-it | | **Architecture** | Gemma 3 | | **Parameters** | 270 Million | | **Task** | English → Indic Machine Translation | | **Framework** | Hugging Face Transformers | | **Precision** | bfloat16 | | **Attention** | Flash Attention 2 | | **Generation** | Beam Search | | **Beam Size** | 5 | | **Sampling** | Disabled (`do_sample=False`) | | **Padding Side** | Left | | **Cache** | Enabled (`use_cache=True`) | # Supported Languages | Language | Language Code | |------------|---------------| | Assamese | asm_Beng | | Bengali | ben_Beng | | Gujarati | guj_Gujr | | Hindi | hin_Deva | | Kannada | kan_Knda | | Kashmiri | kas_Arab | | Malayalam | mal_Mlym | | Marathi | mar_Deva | | Odia | ory_Orya | | Punjabi | pan_Guru | | Sanskrit | san_Deva | | Tamil | tam_Taml | | Telugu | tel_Telu | | Urdu | urd_Arab | Input language is always **English**. # Dataset The model was fine-tuned using the **AI4Bharat BPCC (bpcc-seed-v2)** multilingual parallel corpus. The dataset contains parallel English–Indic sentence pairs covering multiple domains and language families. # Prompt Format The model expects prompts in the following format: ```text Translate to {Target Language}: {English Sentence} ``` Example: ```text Translate to Telugu: Artificial Intelligence is changing healthcare. ``` # Usage ```python import torch from transformers import AutoTokenizer, AutoModelForCausalLM MODEL_NAME = "ManiKumarAdapala/Gemma3-En2Indic-NMT-270M" tokenizer = AutoTokenizer.from_pretrained(MODEL_NAME) tokenizer.padding_side = "left" model = AutoModelForCausalLM.from_pretrained( MODEL_NAME, dtype=torch.bfloat16, attn_implementation="flash_attention_2", device_map={"": 0}, ) model.config.use_cache = True model.eval() EOT = tokenizer.convert_tokens_to_ids("") @torch.inference_mode() def translate(sentences, language): if isinstance(sentences, str): sentences = [sentences] prompts = [ tokenizer.apply_chat_template( [ { "role": "user", "content": f"Translate to {language}:\n\n{s}", } ], tokenize=False, add_generation_prompt=True, ) for s in sentences ] inputs = tokenizer( prompts, return_tensors="pt", padding=True, add_special_tokens=False, ).to(model.device) outputs = model.generate( **inputs, max_new_tokens=256, do_sample=False, num_beams=5, eos_token_id=[ tokenizer.eos_token_id, EOT, ], pad_token_id=tokenizer.pad_token_id, ) generated = outputs[:, inputs["input_ids"].shape[1]:] return tokenizer.batch_decode( generated, skip_special_tokens=True, ) sentence = "Artificial Intelligence is transforming agriculture." translation = translate(sentence, "Hindi") print(translation[0]) ``` # Recommended Generation Settings ```python max_new_tokens = 256 num_beams = 5 do_sample = False use_cache = True padding_side = "left" dtype = torch.bfloat16 attn_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. # Evaluation The model was evaluated using sentence pairs from the BPCC dataset. Metrics used: - BLEU - chrF2 Average benchmark results: | Language Code | Language | BLEU ↑ | chrF2 ↑ | |:--------------|:---------|-------:|--------:| | asm_Beng | Assamese | **44.1** | **48.2** | | ben_Beng | Bengali | **55.3** | **54.3** | | guj_Gujr | Gujarati | **54.1** | **53.5** | | hin_Deva | Hindi | **61.9** | **59.5** | | kan_Knda | Kannada | **41.0** | **46.6** | | kas_Arab | Kashmiri | **8.4** | **31.6** | | mal_Mlym | Malayalam | **45.3** | **46.7** | | mar_Deva | Marathi | **50.7** | **50.6** | | ory_Orya | Odia | **40.6** | **44.3** | | pan_Guru | Punjabi | **48.7** | **49.2** | | san_Deva | Sanskrit | **38.4** | **41.2** | | tam_Taml | Tamil | **48.9** | **49.2** | | tel_Telu | Telugu | **49.8** | **49.7** | | urd_Arab | Urdu | **33.7** | **55.2** | | **Average** | **14 Languages** | **44.4** | **48.6** | # Known Limitations Like most compact multilingual translation models, this model has a few limitations. - Numerical values may occasionally change during translation. - Rarely, Latin characters may appear within Indic script outputs. - Translation quality varies across languages, with lower-resource languages generally being more challenging. - Not intended for legal, medical, or other safety-critical translation tasks without human verification. # Citation ```bibtex @misc{Gemma3-En2Indic-NMT-270M, title = {Gemma3-En2Indic-NMT-270M: English to Indic Neural Machine Translation}, author = {Adapala, Mani Kumar}, year = {2026}, publisher = {Hugging Face}, url = {https://huggingface.co/ManiKumarAdapala/Gemma3-En2Indic-NMT-270M} } ``` # Acknowledgements This work builds upon: - **Google** for the Gemma-3 model. - **AI4Bharat** for the BPCC multilingual parallel corpus. - **Hugging Face** for the Transformers ecosystem. - The open-source community for tools and libraries that enabled this work.