AI Glossary / AI and machine learning / Beginner
Bigram
Definition
A bigram is a pair of neighboring items in a sequence, usually two adjacent words such as New York or not good, counted or predicted together so a little local word order is preserved.
What it means
Bag-of-words models count single words and lose all order. Bigrams recover a slice of it: not good as a pair means something very different from not and good counted separately.
Bigrams belong to the n-gram family. A unigram is one item, a bigram two, a trigram three. The bigger the n, the more order you keep and the rarer each pattern becomes.
They appear in two places. As features, bigram counts feed classifiers for spam, sentiment and topic tagging. As probabilities, they form simple language models: given the last word, what word is likely next.
The weakness is sparsity. Most possible pairs never occur even in large collections, so counts get thin quickly as n grows, which is one reason modern systems use learned embeddings instead.
For a business, bigrams are a cheap upgrade to any word-counting analysis, especially where negation, names and common phrases carry the meaning.
Common phrases dominate real text. A large share of ordinary writing is made of recurring pairs and short chunks, which is why capturing them pays off even in simple systems.
In speech recognition, pair probabilities help the system choose between sound-alikes: ice cream versus I scream. The pair that fits the surrounding words wins.
How it works
Tokenize the text into words, then slide a window two words wide across each document, recording every pair: my parcel, parcel arrived, arrived late.
For features, count how often each pair appears in each document and feed the counts to a model, exactly as with single words but with a much larger vocabulary.
For prediction, count pairs across a collection and turn them into probabilities: after thank you, the word for appears, say, a third of the time.
Variants handle the sparsity: rare pairs are dropped, and smoothing techniques borrow strength from single-word counts when a pair has few observations.
A quick count shows the sparsity problem: a 50,000-word vocabulary has about 2.5 billion possible pairs, and even a large document collection observes only a small fraction of them.
Three practical examples
- Autocomplete suggesting your next word from the previous one, the original idea behind phone keyboards.
- Review analysis that finds cold coffee and highly recommend, phrases invisible to single-word counts.
- Spam filters that treat free money or click here as one signal rather than two unrelated words.
Think of it this way
Think of reading a page through a cardboard frame that shows exactly two words at a time. You lose the story, but you catch fixed phrases that a one-word frame would split apart.
The limit: widen the frame to three or four words and you see more of the story, but every view becomes rare, so you have less evidence for each.
Worked example
finding the complaint single words hid
Suppose a cafe owner counts words in 2,000 reviews. The word cold appears often but seems harmless, mixed across soups and weather talk.
She switches to bigrams. Cold coffee jumps out as one of the most frequent pairs in one-star reviews, along with waited ages. The counts are illustrative.
The fix is operational, a coffee machine temperature check, and the next quarter's reviews show the bigram fading.
The lesson: the pair carried the meaning. Either word alone pointed nowhere useful.
Illustrative case study
A fictional online retailer sorts customer emails with a bag-of-words model and keeps misrouting ones containing not happy, not working and not received.
Adding bigram features fixes most of these, because the negation now travels with the word it negates. The retailer keeps the simple model, since the upgrade cost almost nothing.
The invented lesson: before buying an expensive language system, exhaust the cheap tricks. A bigram feature often closes half the gap.
The same retailer later tests character bigrams for matching misspelled product names in search queries and finds them surprisingly tolerant of typos.
Common misconceptions and mistakes
- A bigram must be a meaningful two-word phrase. It is any adjacent pair, meaningful or not.
- Bigger n is always better. Trigrams keep more order but their counts get so sparse that quality often drops.
- Bigrams are only about words. The same idea works on characters, sounds and code tokens.
Business use
Add bigrams to any word-counting text analysis where phrases or negation matter; it costs little and often sharpens results.
Treat bigrams as the baseline that fancier language models must beat, not as the final answer.
When mining reviews or tickets yourself, list the top bigrams before drawing conclusions from word clouds. The pairs often tell a different, more actionable story.
People also ask
What is an n-gram?
A run of n neighboring items. Unigram, bigram and trigram mean one, two and three.
Is a bigram the same as a collocation?
No. A collocation is a habitual phrase; a bigram is any adjacent pair, habitual or not.
Are bigrams still used with modern models?
Yes, as cheap features, quick baselines and inside some retrieval systems.
How do I see bigrams in my own data?
Count adjacent word pairs with any text tool; even a list of the top hundred pairs in your reviews is revealing.
Check your understanding
Why does the bigram not good help a sentiment model more than counting not and good separately?
Answer: Separately, good looks positive and not is ignored; as a pair, the negation is captured as a single negative signal.
Related terms
Learn next
Be Productive Using AI shows how to get more out of everyday text analysis and AI writing tools: https://aiforbusinessandlife.com/academy/be-productive-using-ai. [C1]
More in AI and machine learning
- Behavioral clustering - Behavioral clustering groups entities according to similarities in observed behavior.
- Behavioral simulation
- Bidirectional - In AI, bidirectional describes a model that reads a sequence in both directions at once, from start to end and from end to start, so each word or item is...
- Binary classification - Binary classification is the task of sorting items into exactly two categories, such as spam or not spam, churn or stay, approve or decline.
- Binary condition - A binary condition is a yes-or-no test, such as order value above 100 or country is France, used at each node of a decision tree or rule set to send every...
- Boosting - Boosting is an ensemble method that trains models one after another, each new model concentrating on the mistakes the earlier ones made, and combines them...
Sources
[S2] Google, Machine Learning Glossary; [S8] Jurafsky and Martin, Speech and Language Processing (3rd ed. draft). Full URLs are in the source ledger. Verified 11 October 2026.
Previous: Big M method Next: Bilabial