A small decoder-only transformer language model for Telugu, trained from scratch on Telugu Wikipedia (snapshot 20231101). Part of telugu-nepali-lm.
| Model | Perplexity (per token) | Bits/char |
|---|---|---|
| Unigram baseline | 643.18 | 2.001 |
| Bigram baseline | 30.48 | 1.0574 |
| This GPT | 5.55 | 0.5301 |
Perplexity depends on the tokenizer, so it is not comparable across languages; use bits/char.
Telugu Wikipedia is very regular (many templated articles), so this perplexity reflects an easy domain, not an unusually strong model.
8 layers, 8 heads, width 384, context 256, vocabulary 8,000 (SentencePiece Unigram), pre-LayerNorm, learned positions, tied embeddings. Best validation checkpoint (iteration 4500).
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. The low perplexity is partly due to very regular source text.