A small decoder-only transformer language model for Nepali, trained from scratch on Nepali Wikipedia (snapshot 20231101). Part of telugu-nepali-lm.
| Model | Perplexity (per token) | Bits/char |
|---|---|---|
| Unigram baseline | 1979.66 | 3.0644 |
| Bigram baseline | 435.51 | 2.4531 |
| This GPT | 66.87 | 1.6967 |
Perplexity depends on the tokenizer, so it is not comparable across languages; use bits/char.
Training 8,000 steps instead of 5,000 did not improve it, so quality is limited by the small amount of Nepali data.
8 layers, 8 heads, width 384, context 256, vocabulary 8,000 (SentencePiece Unigram), pre-LayerNorm, learned positions, tied embeddings. Best validation checkpoint (iteration 5000).
import torch, sentencepiece as spm
from model import GPT, GPTConfig # model.py is included in this repo
ckpt = torch.load("model.pt", map_location="cpu")
model = GPT(GPTConfig(**ckpt["config"])).eval()
model.load_state_dict(ckpt["model"])
sp = spm.SentencePieceProcessor(model_file="tokenizer.model")
ids = torch.tensor([sp.encode("your prompt")])
out = model.generate(ids, max_new_tokens=60, temperature=0.8, top_k=40)
print(sp.decode(out[0].tolist()))
Trained on Wikipedia only (encyclopedic style) with about 8-9M tokens. It writes fluent text but invents facts, and is not suitable for any real-world use. Quality is limited by the small training set (about 8M tokens).