Skip to content

How Computers Learned to Read: From Words to Numbers

It is a pleasant morning. You open your apartment food-order app and type:

"Please bring one hot cup of tea with a little extra milk."

To the kitchen staff, the request is clear. They know what you want, prepare the order, and send it to your home.

Now consider a computer.

A computer has no eyes, no ears, and no real-world intuition. At its core, it is still a very fast calculator that understands only numbers—specifically \(0\)s and \(1\)s.

How does a system take a normal sentence like "Please bring one hot cup of tea with a little extra milk" and understand what it means?

It breaks down the problem into three simple steps:
A clean and modern graphic illustrating the three steps of how computers process text: 1. Tokenization (breaking text into words/subwords), 2. Numerical Conversion (converting tokens into numerical IDs and vector embeddings), and 3. Contextual Processing (processing through a neural network contextually).

Step 1: Text to Tokens

A computer cannot swallow an entire sentence in one go. First, it passes your order through a digital shredder called a Tokenizer.

The tokenizer chops the sentence into small building blocks called tokens. A token can be a full word, a syllable, or even punctuation:

A clear, modern illustrative graphic showing the tokenization of the sentence "Bhaiya, give one hot cup of tea with a little extra milk." It displays the full sentence at the top, passing through a Tokenizer process, and breaking down visually into distinct labeled token blocks: 'Bhai', 'ya', ',', 'give', 'one', 'hot', 'cup', 'of', 'tea', 'with', 'a', 'little', 'extra', 'milk', '.'.

Why chop words into small pieces?

  • If you say "cup" or "cups", the core idea remains identical.
  • Breaking words into sub-word tokens allows the computer to easily recognise spelling mistakes, local slang, and fresh terms without maintaining an unending dictionary.

Step 2: Tokens to Token IDs

Even after chopping, the machine still cannot interpret letters like “t-e-a”.

To solve this, the model refers to a master catalogue (the model's vocabulary list). Think of it like giving a roll number to every unique token.

A clean, technical graphic displaying a vocabulary lookup table with a slate blue header and soft gray alternating rows. The table maps tokens to numerical IDs: 'give' -> 1042, 'hot' -> 3120, 'cup' -> 5280, 'tea' -> 7415, and 'milk' -> 9182, matching the exact color scheme and modern visual style of the previous document images.

Now, your order is converted into a neat sequence of numbers:

A clean, modern technical graphic matching the slate blue and soft white visual style of the previous illustrations, showing a neat sequence of token ID numbers: [1204, 381, 15, 1042, 45, 3120, 5280, 210, 7415, 305, 12, 1892, 4012, 9182, 13] arranged cleanly in styled sequential blocks.

At this stage, the computer can store your sentence in memory. However, to the system, tea (7415) and milk (9182) are still just arbitrary numbers without any clear connection.

Step 3: Embeddings

To understand that tea is a hot morning drink and not a motor scooter or a laptop, the computer plots the tokens onto a coordinate graph. In AI, these coordinates are called Embeddings.
A clean, minimalist technical diagram in the same slate blue, dark teal, and soft white style, illustrating Vector Embeddings. It depicts a 3D semantic vector space showing relationship vectors between words like 'tea', 'beverage', 'milk', and 'cup' plotted as points/vectors in space with numerical coordinate lists next to them.

Note: While this diagram uses two axes for simplicity, real-world language models map tokens across hundreds or thousands of abstract numerical dimensions to capture complex semantic relationships.

Step 4: Context Alters the Position

What happens if you modify the order slightly?

"Bhaiya, give one iced cup of tea..."

The model's internal attention mechanism spots the qualifier "iced" sitting right next to "tea". In real-world language models, embeddings consist of hundreds of dimensions, where individual coordinates capture specific semantic attributes such as temperature. Thus, when "iced" is added, the coordinate value corresponding to temperature flips from positive (hot) to negative (cold)—shifting the vector representation from [0.9, 0.2, -0.45, ...] towards [-0.8, 0.2, -0.45, ...] to reflect the updated context, bridging the 2D conceptual diagram with multi-dimensional vector math.

A clean, minimalist technical graphic matching the slate blue, dark teal, and soft white style of the previous embedding illustrations, depicting a vector shift in semantic space. It shows the word vector shifting along the temperature axis from hot [0.9, 0.2, -0.45, ...] ('tea') to cold [-0.8, 0.2, -0.45, ...] ('iced tea') when the modifier 'iced' is added, complete with labeled vector points, directional arrows, and coordinate arrays.

This enables the system to adapt its understanding based on surrounding context.

Step 5: How the AI Formulates a Reply

Once the context-adjusted vector (such as the updated coordinates for "iced tea" from Step 4) is finalized, it serves as the exact starting input for the model's autoregressive response generation:

  1. It checks the collective position of your prompt.
  2. It reviews its training patterns to find what logically follows this context.
  3. It generates the response token by token:

A clean, modern technical diagram in a minimalist slate blue, dark teal, and soft white style, matching the previous illustrations in the document. It illustrates Step 5: How the AI Formulates a Reply. On the left, a coordinate grid showing the prompt vector position and training pattern paths. In the center, an autoregressive generation box processes the context vector. On the right, it shows the response being generated token by token in sequential blocks: 'Sure' -> ',' -> 'one' -> 'tea' -> 'coming' -> 'up' -> '!', with directional arrows and probability percentages accompanying each generated token.

What's Next?

In our next post, we will explore What is an LLM and its core fundamentals.