How a cost grows with size, ignoring constants: O(n²) means at most proportional to n² for large n.
In ML papers
O(f(n)) describes how fast something grows as n gets large, up to a constant factor. Saying self-attention costs O(n2d) for n tokens of width d means: double the sequence length and the cost roughly quadruples. Constants and smaller terms are dropped, so 3n2+100n is O(n2). Plain O and calligraphic O mean the same.
Relatives: Ω(f) is a lower bound (grows at least like f), Θ(f) both at once (grows exactly like f, up to constants), and little o(f) means "grows strictly slower than f", so o(1) is something that shrinks to zero.
How to type it
LaTeX
Shows
O(n^2)
O(n2)
\mathcal{O}(n \log n)calligraphic
O(nlogn)
A worked example
n=1000→2000:n2=106→4×106
An O(n2) step takes about four times as long; an O(n) step about twice.
Common confusions
Big-O hides constants: an O(n) method can still be slower than an O(n2) one at the sizes you actually use.
O here is not a set or a loss, despite the calligraphic letter (Calligraphic letters).