A bidirectional Georgian ↔ English neural machine translation model, built by implementing the
"Attention Is All You Need" (Vaswani et al., 2017)
Transformer architecture
from first principles in PyTorch — no
torch.nn.TransformerEncoder,
no pretrained weights, no HuggingFace model classes.
Trained entirely from random initialization for educational purposes: a faithful reproduction of
the original 2017 Transformer, with two small, deliberate modern departures (GELU activation,
pre-LayerNorm) for training stability.
Scored with
COMET (
wmt22-comet-da) on a held-out test
split, greedy decoding:
Scores in this range reflect moderate translation quality — reliable on common, everyday
sentence structures, with an expected drop-off on rare vocabulary and specialized domains, given
the model was trained entirely from scratch with no pretraining.
1import torch
2from huggingface_hub import hf_hub_download
3from tokenizers import Tokenizer
4
5# 1. Import model architecture and configuration
6from Scripts.Transformer import TranslationModel
7from Scripts.ModelConfig import Config
8
9# 2. Download assets from Hugging Face Hub
10REPO_ID = "N1k0l0z/vanilla-transformer-georgian-english"
11
12model_path = hf_hub_download(repo_id=REPO_ID, filename="model.pt")
13tokenizer_path = hf_hub_download(repo_id=REPO_ID, filename="tokenizer.json")
14
15# 3. Load tokenizer and PyTorch checkpoint
16tokenizer = Tokenizer.from_file(tokenizer_path)
17checkpoint = torch.load(model_path, map_location="cpu", weights_only=False)
18
19# 4. Initialize model and load trained weights
20model = TranslationModel(checkpoint["config"])
21model.load_state_dict(checkpoint["model_state_dict"])
22model.eval()
23
24# 5. Translate!
25print(model.translate("ვინ ხარ?", tokenizer, direction="2en"))
26# Output: "Who are you?"
27
28print(model.translate("Where is your house?", tokenizer, direction="2ka"))
29# Output: "სად არის შენი სახლი?"