Gradient

Courses

∇\nabla∇The maths behind AI0/72
π\piπMaths0/84
⋆\star⋆AI for everyone0/10
Γ\GammaΓGame theory0/49
py\texttt{py}pyPython for AI0/15
y^\hat{y}y^​Build your own AI0/15
All courses

Tuition

My tuitionOlympiad trackCompetitions

Practice

ProjectsAsk a questionTrain on a GPUExplorationsMaths StoriesUnsolved problemsPlaygroundScience labsMock testsOlympiad

Reference

GlossaryBlogDiscoveries
Glossary › Bigram model

What is bigram model?

A language model that predicts each token from only the one before it, using a table of counts.

Where it is taught

A language model from counting. Build a complete language model with nothing but a table of counts. It is weak, but it has every part of the real thing.

What the lesson leaves you with

  • A bigram model is a table of P(next∣current)P(\text{next} \mid \text{current})P(next∣current) made by counting pairs.
  • It generates text with the same sampling loop as a GPT.
  • Its one-letter memory is its limit, and its loss is the baseline for the transformer to beat.
Open the lesson

Questions

What is bigram model?
A language model that predicts each token from only the one before it, using a table of counts.
Where is bigram model used in AI?
Build a complete language model with nothing but a table of counts. It is weak, but it has every part of the real thing.
What is the key idea to remember about bigram model?
A bigram model is a table of <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>P</mi><mo stretchy="false">(</mo><mtext>next</mtext><mo>∣</mo><mtext>current</mtext><mo stretchy="false">)</mo></mrow><annotation encoding="application/x-tex">P(text{next} mid text{current})</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="katex-base"><span class="katex-strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord mathnormal" style="margin-right:0.1389em;">P</span><span class="mopen">(</span><span class="mord text"><span class="mord">next</span></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">∣</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="katex-base"><span class="katex-strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord text"><span class="mord">current</span></span><span class="mclose">)</span></span></span></span> made by counting pairs.
Where can I learn bigram model step by step?
In the lesson “A language model from counting” in Gradient’s course on the maths behind AI, with interactive diagrams and questions.

See it in 3D on the blog

  • How does ChatGPT work? The maths for Class 108 min
  • What are word embeddings? Words as points4 min
  • What is conditional probability? A visual guide3 min

Related terms

  • Early stopping