Skip to content
Last Dictionary

big O notation

nounAlso: Big O, O-notation, asymptotic notation, Landau notation, time complexity, computational complexity, Big Theta, Big Omega

In plain wordsShorthand for how the cost of a computation grows as the problem gets bigger. Saying attention costs 'O(n²)' means doubling the length of the text roughly quadruples the work.

  1. A notation describing how a function grows asymptotically, ignoring constant factors: f(n) = O(g(n)) means f(n) is at most a constant multiple of g(n) for all sufficiently large n. Companion symbols give lower bounds (Ω), tight bounds (Θ) and strictly slower growth (little o). Its everyday use is stating the cost of algorithms as a function of input size n — sorting in O(n log n), naive matrix multiplicationmatrix multiplication, n.: The rule for combining two grids of numbers into a new grid by repeatedly multiplying rows by columns. It is the single calculation AI chips spend most of their time doing. of n × n matrices in O(n³) — and in AI it is the standard shorthand for architectural costs: standard self-attentionself-attention, n.: Attention in which a passage looks at itself: every word checks every other word in the same text to work out its meaning in context, such as which noun 'it' refers to. takes O(n²) time and memory in sequence length n, motivating linear attentionlinear attention, n.: A family of faster substitutes for attention whose cost grows in step with the length of the text rather than with its square, by keeping a running summary instead of comparing every pair of words., sparse attentionsparse attention, n.: Attention in which each word looks at only a selected subset of the other words instead of all of them, so very long texts can be processed at a fraction of the cost., sliding window attentionsliding window attention, n.: Attention in which each word looks only at a fixed number of nearby earlier words rather than the whole text, keeping the cost of very long inputs under control. and state space modelsstate space model, n.: A type of sequence model that reads text like a running tally, updating a fixed-size internal summary at each step, so its memory and cost do not balloon as texts get longer. with O(n) cost; the KV cacheKV cache, n.: A memory store where a chatbot keeps its working notes on everything already read and written, so each new word does not require re-reading the whole conversation from scratch. grows as O(n); and the fast Fourier transformFourier transform, n.: A way of breaking a signal — a sound, an image, any pattern over time or space — into the simple waves of different frequencies that add up to it, much as a prism splits white light into colors. runs in O(n log n). Big O hides constants and lower-order terms that often decide real speed on GPUsGPU, abbr.: A computer chip first designed to draw video-game graphics that turned out to be ideal for AI, because it can do thousands of simple calculations at the same time., so asymptotic and measured efficiency can disagree.

    Attention is O(n²) in context length, so going from 8k to 128k tokens multiplies that cost by 256.

f(n)=O(g(n))  ⟺  ∃ C>0, n0:  ∣f(n)∣≤C ∣g(n)∣    ∀ n≥n0f(n) = O(g(n)) \iff \exists\, C > 0,\, n_0 : \; |f(n)| \le C\,|g(n)| \;\; \forall\, n \ge n_0

Origin

Introduced by the German number theorist Paul Bachmann in Analytische Zahlentheorie (1894) and popularized by Edmund Landau, who added little-o, in 1909 — hence 'Landau symbols'. Donald Knuth's 1976 note 'Big Omicron and Big Omega and Big Theta' standardized the related notations for computer science.

Related

See also
  • matrix multiplicationmatrix multiplication, n.: The rule for combining two grids of numbers into a new grid by repeatedly multiplying rows by columns. It is the single calculation AI chips spend most of their time doing.
  • self-attentionself-attention, n.: Attention in which a passage looks at itself: every word checks every other word in the same text to work out its meaning in context, such as which noun 'it' refers to.
  • linear attentionlinear attention, n.: A family of faster substitutes for attention whose cost grows in step with the length of the text rather than with its square, by keeping a running summary instead of comparing every pair of words.
  • KV cacheKV cache, n.: A memory store where a chatbot keeps its working notes on everything already read and written, so each new word does not require re-reading the whole conversation from scratch.
  • Fourier transformFourier transform, n.: A way of breaking a signal — a sound, an image, any pattern over time or space — into the simple waves of different frequencies that add up to it, much as a prism splits white light into colors.
  • Turing machineTuring machine, n.: An imaginary, extremely simple computer — a read-write head moving along an endless tape — that Alan Turing used in 1936 to define exactly what can be computed at all.

Sources

  1. Knuth, D. E. (1976). Big Omicron and Big Omega and Big Theta. ACM SIGACT News, 8(2).

Mentioned in

Turing machineTuring machine, n.: An imaginary, extremely simple computer — a read-write head moving along an endless tape — that Alan Turing used in 1936 to define exactly what can be computed at all., Kolmogorov complexityKolmogorov complexity, n.: How briefly something can be described by a computer program that recreates it exactly: a million zeros needs only a tiny program, while a truly random string needs one about as long as itself.