Downloads · 30 days
6
11% of all-time downloads
ilprl-docse/NepTam20k-transformer-49.07M
NepTam20k-transformer-49.07M is a translation model from ilprl-docse. Use it when you need text moved from one language to another. The card lists the license as cc-by-nc-4.0.
NepTam20K-Transformer is a vanilla Transformer model fine-tuned for Nepali ↔ Tamang neural machine translation.
Downloads · 30 days
6
11% of all-time downloads
All-time downloads
57
Public
Parameters
40.9M
164 MB on disk
Likes
0
Public
Click a slice to open those files.
.safetensors164 MB · 99%
From the Hugging Face model README
NepTam20K-Transformer is a vanilla Transformer model fine-tuned for Nepali ↔ Tamang neural machine translation.
Originally implemented in Fairseq, the model has been converted to HuggingFace MarianMT format for easier deployment and inference.
The model was developed by the Information and Language Processing Research Lab (ILPRL) at Kathmandu University, as part of low-resource MT research.
It uses Hindi (hi_IN) as a proxy for Tamang in tokenization, due to the absence of Tamang in standard tokenizers.
| Intended language | Tokenized as |
|---|---|
| Nepali | ne_NP |
| Tamang | hi_IN (proxy) |
Supported directions:
ilprl-docse/NepTam-A-Nepali-Tamang-Parallel-Corpus| Model | Param Size | Direction | BLEU | chrF | chrF++ | METEOR | COMET |
|---|---|---|---|---|---|---|---|
| NepTam_Transformer | 49.07M | ne→tam | 37.71 | 71.71 | 67.74 | 58.20 | 75.00 |
| tam→ne | 38.01 | 69.89 | 66.30 | 57.60 | 77.37 |
This model uses the MarianMT HuggingFace API. The following code shows how to load and translate with it:
import torch
from transformers import MarianMTModel, MarianTokenizer
device = "cuda" if torch.cuda.is_available() else "cpu"
# Load the model and tokenizer
model_path = "ilprl-docse/NepTam20k-transformer-49.07M"
tokenizer = MarianTokenizer.from_pretrained(model_path)
model = MarianMTModel.from_pretrained(model_path).to(device)
# Language map
LANG_MAP = {
"Nepali": "__ne__",
"Tamang": "__taj__"
}
def translate_with_transformer(text, src="Nepali", tgt="Tamang"):
src_lang = LANG_MAP[src]
tgt_lang = LANG_MAP[tgt]
# Prefix target language token (MarianMT-style)
input_text = f"{tgt_lang} {text}"
encoded = tokenizer(input_text, return_tensors="pt", padding=True).to(device)
with torch.no_grad():
generated_ids = model.generate(
**encoded,
max_length=512,
num_beams=5,
early_stopping=True
)
return tokenizer.decode(generated_ids[0], skip_special_tokens=True).strip()
# Example
text = "म आज धेरै खुसी छु।"
translation = translate_with_transformer(text, src="Nepali", tgt="Tamang")
print("Translation (Tamang):", translation)