๐Ÿ“– Language Models

Word Wizard

Train a real n-gram language model on nursery rhymes, news, or your own text โ€” then watch it predict the next word, just like autocomplete on your phone!

๐Ÿ“š Choose Corpus
๐Ÿ” Explore N-Grams
๐Ÿ”ฎ Predict Words
๐Ÿ†š Compare Styles
๐Ÿ† Badge

How Language Models Predict Words

๐Ÿ“–

The Corpus

A corpus is a collection of text the model learns from. Nursery rhymes give childlike language; news gives formal language.

๐Ÿ”ข

N-Grams

An n-gram is a sequence of N words. Bigrams = 2 words, trigrams = 3. "the cat sat" has the bigram "the cat" and "cat sat".

๐Ÿ“Š

Probability

After seeing "the cat", what comes next? Count how often each word follows "the cat" in the corpus to get probabilities.

๐Ÿ”ฎ

Prediction

Given the last N-1 words, the model picks the next word by its probability. High prob = common continuation.

๐Ÿ“–
Wizzy the AI Tutor
Welcome to the language model lab! ๐ŸŽ‰ A language model learns from text โ€” its corpus. Pick a corpus below and watch how the style of the text completely changes what words the model predicts. Try the nursery rhymes vs news headlines โ€” you'll be amazed!

Step 1 โ€” Choose Your Training Text

๐ŸŒธ
Nursery Rhymes
Classic children's rhymes with simple, rhythmic language
Loading...
๐Ÿ“ฐ
News Headlines
Formal news-style language with facts and events
Loading...
๐Ÿงš
Fairy Tales
Magical storytelling language with adventure and wonder
Loading...
๐Ÿ”ฌ
Science Facts
Educational scientific language with technical terms
Loading...
โœ๏ธ
Write Your Own!
Type or paste any text to train the model on it
Custom
๐Ÿ“–
Wizzy the AI Tutor
Explore the n-gram table! Each row shows a word sequence and the probability of what comes next. The wider the orange bar, the more likely that continuation. Change N โ€” bigger N means the model has more context but is less flexible!

Step 2 โ€” Explore the N-Gram Table

Top 30 most common n-grams (sorted by frequency)
Context (prefix)Next WordCountProbability

๐Ÿ“Š Model Stats

Total wordsโ€”
Unique wordsโ€”
N-gram size2
Unique contextsโ€”
Total n-gramsโ€”
Bigram (N=2): The model only looks at the last 1 word to predict the next. Simple but fast!
๐Ÿ“–
Wizzy the AI Tutor
Type a starting word or phrase and see what the model predicts next! Click any prediction bar to pick that word and keep building a sentence. The orange bars show probability โ€” taller = more likely. Can you generate a full sentence?

Step 3 โ€” Word Prediction Engine

Next word predictions
Start typing below to see predictions
How context works:
Add words to see how the model uses context to make predictions.

๐Ÿ”ข Prediction Stats

Words generated0
Top predictionโ€”
Confidenceโ€”
N-gram N used2
๐Ÿ“–
Wizzy the AI Tutor
This is the coolest part! Same starting words, two different corpora โ€” watch how the language style changes completely! This is exactly why GPT-4, trained on all of the internet, sounds different from a model trained only on medical texts. Language = data!

Style Comparison โ€” Same Seed, Different Corpus

๐ŸŒธ Nursery Rhymes model

Click "Generate Both" to see output

๐Ÿ“ฐ News Headlines model

Click "Generate Both" to see output

๐Ÿงš Fairy Tales model

Click "Generate Both" to see output

๐Ÿ”ฌ Science Facts model

Click "Generate Both" to see output
Generate text to see the analysis!
๐Ÿ“–
Wizzy the AI Tutor
๐ŸŽŠ You've just built and explored a real language model! You understand n-grams, probability distributions, corpus influence, and next-word prediction โ€” the core ideas behind ChatGPT, autocomplete, and every AI that works with text. You're a Language Model Scientist!
๐Ÿ“–

Language Model Badge!

You trained an n-gram model and explored how corpus choice shapes language style!

๐Ÿ“– WhizzStep AI Lab
This certifies that
Student Name
has mastered N-Gram Language Models & Word Prediction
Language Model Expert
N-Gram Master
Word Wizard
Trained on โ€” words ยท whizzstep.in

Key Concepts Mastered

Corpus

๐Ÿ“š Training Text

The text a language model learns from. The corpus completely determines what the model knows and how it "talks".

N-Gram

๐Ÿ”ข Word Sequences

A sequence of N consecutive words. Bigram = 2 words, trigram = 3. Used to capture context for prediction.

Probability

๐Ÿ“Š How Likely?

Given context words, what's the probability of each next word? Counted from how often it appears in the corpus.

Perplexity

๐Ÿ˜ต How Confused?

A measure of how "surprised" a language model is by new text. Lower perplexity = better model!

Context Window

๐ŸชŸ Memory Size

How many previous words the model looks at. N=2 uses 1 word context; GPT-4 uses thousands of tokens!

Smoothing

๐Ÿ”„ Handling Unknowns

What if a word combination never appeared in training? Smoothing gives a small probability to unseen n-grams.