Downloads · 30 days
0
QuarkML/TNMT-en-hi-experiment
TNMT-en-hi-experiment is a translation model from QuarkML. Use it when you need text moved from one language to another. It is set up for pytorch. The card lists the license as mit.
This repository contains a Transformer Encoder-Decoder model implemented from scratch in PyTorch for English-to-Hindi neural machine translation. The model and all training, preprocessing, and inference scripts are cu…
Downloads · 30 days
0
Access
Public
Updated Jun 26, 2025
Repo size
330 MB
Likes
1
Public
Click a slice to open those files.
.pt330 MB · 100%
From the Hugging Face model README
This repository contains a Transformer Encoder-Decoder model implemented from scratch in PyTorch for English-to-Hindi neural machine translation. The model and all training, preprocessing, and inference scripts are custom and do not use Hugging Face Transformers, but follow the original "Attention is All You Need" architecture.
tokenizers)models/ and Data/bi_tokenizers_32k/ directories.Below is a simple inference script to translate English text to Hindi using the trained model and tokenizer:
import torch
from tokenizer import BilingualTokenizer as Tokenizer
from model import Transformer, TransformerConfig
from translator import TranslationInference
# 1. Load config and checkpoint
config = TransformerConfig(shared_embeddings=True)
checkpoint = torch.load('models/TNMT_v1_Beta_single.pt', map_location='cpu')
# 2. Build model and load weights
model = Transformer(config)
model.load_state_dict(checkpoint['model_state_dict'])
model = model.to('cpu')
# 3. Load tokenizer
tokenizer = Tokenizer(vocab_size=32000)
tokenizer_loaded = tokenizer.load_tokenizers('bi_tokenizers_32k')
# 4. Create inference helper
translator = TranslationInference(
model=model,
tokenizer=tokenizer_loaded,
device='cpu'
)
# 5. Translate
source_text = "This is a test sentence."
translated_text = translator.translate_text(source_text)
print("Translated text:", translated_text)
If you use this code or model, please cite:
Vaswani et al., "Attention is All You Need", NeurIPS 2017.
Author: QuarkML License: MIT