HomeAI & Machine LearningN-Gram Language Model: Live Perplexity & Text Generation

N-Gram Language Model: Live Perplexity & Text Generation

Interactive computational-linguistics simulator: train a real add-k smoothed bigram language model on two toy corpora, watch it generate text word by word in 3D, and see perplexity update live as you change smoothing and sampling temperature.

AI & Machine Learning3DModerate60 FPS
computational-linguistics ↗ Open standalone

Computational linguistics turns language into numbers so a machine can predict, generate and score text. This simulator builds a real bigram language model in your browser: it counts word-pair frequencies in a small training corpus, smooths them with the add-k (Laplace) method so unseen pairs still get a probability, and then walks a 3D graph of the vocabulary — each hop sampled from the model's own next-word distribution. Two live metrics track the model honestly: perplexity of the text it is currently generating, and held-out perplexity of a fixed test sentence the model never trained on. Switch corpus, smoothing and temperature to see, numerically, how each one reshapes what the model predicts.

⚙ Under the hood

Train a real add-k smoothed bigram language model on one of two toy corpora, watch it generate text word by word as a glowing walker hops across a 3D graph of the vocabulary, and see perplexity update live from the model's own probabilities.

Three.jscomputational linguisticslanguage modeln-gramperplexityNLP

3D · Three.js / WebGL renderer · 60 FPS target · runs fully client-side, no install

What did you find?

Add reproduction steps (optional)