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 › Context length

What is context length?

The number of tokens a model can look back over when predicting the next one.

Where it is taught

Tokens and positions. The path from a sentence to the matrix a transformer works on. Split into tokens, look up embeddings, and add information about order.

What the lesson leaves you with

  • Text is split into tokens, and tokens become ids, then embedding vectors.
  • Position embeddings are added so the model knows the order of the tokens.
  • The model predicts the next token at every position: the targets are the inputs shifted by one.
Open the lesson

Questions

What is context length?
The number of tokens a model can look back over when predicting the next one.
Where is context length used in AI?
The path from a sentence to the matrix a transformer works on. Split into tokens, look up embeddings, and add information about order.
What is the key idea to remember about context length?
Text is split into tokens, and tokens become ids, then embedding vectors.
Where can I learn context length step by step?
In the lesson “Tokens and positions” in Gradient’s course on the maths behind AI, with interactive diagrams and questions.

Related terms

  • Attention
  • Attention head
  • Autoregressive
  • Byte-pair encoding
  • Causal mask
  • Layer normalisation