Downloads · 30 days
0
rajaykumar12959/nllb-en-kn-v1
nllb-en-kn-v1 is a translation model from rajaykumar12959. Use it when you need text moved from one language to another. It is set up for transformers. The card lists the license as mit.
This model is a fine-tuned version of facebook/nllb-200-distilled-600M focused on translating text from English to Kannada. It was trained using LoRA (Low-Rank Adaptation) to efficiently adapt the multilingual model t…
Downloads · 30 days
0
Access
Public
Updated Dec 30, 2025
Repo size
65.4 MB
Likes
1
Public
Click a slice to open those files.
.json32.3 MB · 49%
From the Hugging Face model README
This model is a fine-tuned version of facebook/nllb-200-distilled-600M focused on translating text from English to Kannada. It was trained using LoRA (Low-Rank Adaptation) to efficiently adapt the multilingual model to this specific language pair.
This model improves upon the baseline NLLB-200 capabilities for English-Kannada translation by fine-tuning on a specialized parallel corpus. It utilizes the PEFT library and LoRA to fine-tune the attention layers of the original model while keeping the base model weights frozen.
eng_Latn) → Kannada (kan_Knda)The model is intended for direct translation of short-to-medium length texts from English to Kannada. It performs well on general domain sentences.
The model inherits the biases present in the NLLB-200 base model and the Hemanth-thunder/english-to-kannada-mt training dataset. Translations should be verified for critical applications.
Users should double-check translations for accuracy, especially for nuanced or culturally specific content.
Use the code below to load the model and run inference. You must use the forced_bos_token_id parameter to ensure the output is in Kannada.
import torch
from peft import PeftModel, PeftConfig
from transformers import AutoModelForSeq2SeqLM, AutoTokenizer
# 1. Load Base Model and Tokenizer
base_model_id = "facebook/nllb-200-distilled-600M"
adapter_model_id = "rajaykumar12959/nllb-en-kn-v1" # Replace with your specific repo name
tokenizer = AutoTokenizer.from_pretrained(base_model_id, src_lang="eng_Latn", tgt_lang="kan_Knda")
base_model = AutoModelForSeq2SeqLM.from_pretrained(
base_model_id,
torch_dtype=torch.float16,
device_map="auto"
)
# 2. Load the Fine-tuned Adapter
model = PeftModel.from_pretrained(base_model, adapter_model_id)
model.eval()
# 3. Define Translation Function
def translate(text):
inputs = tokenizer(text, return_tensors="pt").to(model.device)
with torch.no_grad():
translated_tokens = model.generate(
**inputs,
forced_bos_token_id=tokenizer.convert_tokens_to_ids("kan_Knda"), # Vital for NLLB to target Kannada
max_length=128,
num_beams=5,
early_stopping=True
)
return tokenizer.batch_decode(translated_tokens, skip_special_tokens=True)[0]
# 4. Test
input_text = "Machine learning is the future of technology."
print(translate(input_text))
The model was trained on the Hemanth-thunder/english-to-kannada-mt dataset, containing approximately 382k sentence pairs.
The model was fine-tuned using the peft library with LoRA (Low-Rank Adaptation) and 4-bit quantization via bitsandbytes.
q_proj, v_proj, k_proj, o_projA 10% split of the original dataset was held out for validation/testing.
Loss was monitored during training. Subjective evaluation shows improved adherence to Kannada grammar compared to the base model's zero-shot performance.
The model uses the Transformer encoder-decoder architecture. The objective was Sequence-to-Sequence (Seq2Seq) language modeling (Translation).
transformerspeftbitsandbytesaccelerateBibTeX:
@misc{nllb200,
title={NLLB: No Language Left Behind},
author={Meta AI},
year={2022},
howpublished={\url{https://github.com/facebookresearch/fairseq/tree/nllb}}
}