Guided pathThis is part of Understand Transformers & BERTBack to the path

Numbers & Computer Representations

P2.math-foundations.01 · Audience: guest, it-ml, language-pro

A computer can only do one thing: process numbers. There is no such thing as a letter, a word, or a sentence inside a CPU — everything is first turned into a stream of numbers. For language, that means each word (or word-piece) becomes a whole number called a token ID, which is then looked up to retrieve a list of decimal numbers called an embedding vector. Every computation in a Transformer — attention, matrix multiplication, softmax — runs on these numbers.

Step 1 / 4The two kinds of number

Two kinds of number appear everywhere in this tutorial. An integer is a whole number with no decimal point (0, 1, 42, −5) — Python type int. Token IDs are integers. A float (floating-point) can have a decimal point (3.14, −0.87, 0.0) — Python type float. Embedding values are floats.

🗣️ From a linguist's perspective: Text as numerical encoding — a linguist's entry point
Every writing system is an encoding: letters represent sounds, and the choice of code is arbitrary — 'a' could just as well be 1. Computers take this to its logical conclusion: every symbol must become a number for the hardware to process it. Nothing is lost in principle — the linguistic content is preserved in the structure of the numbers, not erased. A Transformer reconstructs linguistic regularities from patterns in those numbers, just as a linguist reconstructs grammar from patterns in text.
TypeWhat it isRole in TransformersExample
Integer (int)Whole number, no decimal pointToken ID, vocabulary size, sequence length4231
Float (float)Number with a decimal point — may be tiny or hugeEmbedding values, attention weights, loss0.1245
Ask the mentor about this module

Ask a question about this content. The mentor explains and grounds its answer in what you are studying; asking is recorded as a learning signal, not a grade.

Ctrl/Cmd + Enter to send

Try it yourself

A scratch console for this page's ideas — ungraded, nothing you run here is recorded.

Scratch console

A scratch console with the scientific stack (pandas, numpy, scikit-learn). Runs on the server — no network, resource-limited and measured.

Output appears here.