Skip to main content

Beginner-Friendly Topic

Take your time - it's perfectly normal to re-read this topic 2-3 times. Try the interactive code editor below to run code yourself. Use the Q&A section to check your understanding before moving on.You've got this!

Lesson 1 of 12

How Computers Represent Text

Computers can only work with numbers. Before an LLM can process any text, every character, word, or piece of text must be converted into numbers. Understanding this conversion is the foundation of understanding how LLMs work.

8 minBy Priygop Editorial TeamUpdated 2026Peer Reviewed & Verified

Text to Numbers

Computers cannot read letters or words directly. Everything in a computer — text, images, sound — is stored as numbers (specifically as binary: 0s and 1s).

For standard text, computers have long used systems like ASCII and Unicode to assign a number to each character. For example:
- 'A' → 65
- 'B' → 66
- 'a' → 97
- 'space' → 32

But this character-by-character approach is not efficient for language models. Reading one character at a time would make it very hard to learn meaningful patterns about language. LLMs need a smarter way to convert text to numbers — this is where tokens come in.

Diagram
Loading diagram…

How Computers Represent Text Diagram

The Character Encoding Concept

The Character Encoding Concept
# How computers traditionally represent text
# (simplified — real encoding uses binary)

# Each character maps to a number
character_encoding = {
    'H': 72,
    'e': 101,
    'l': 108,
    'l': 108,
    'o': 111,
    ' ': 32,
    'W': 87,
    'o': 111,
    'r': 114,
    'l': 108,
    'd': 100,
}

text = "Hello World"
encoded = [ord(char) for char in text]

print("Text:", text)
print("Character encoding (Unicode code points):", encoded)
# Output: [72, 101, 108, 108, 111, 32, 87, 111, 114, 108, 100]

# This works for storage, but for LLMs we need something smarter:
# We want to encode MEANING, not just characters.
# That is what tokenization does.

Quick Q&A

Finished this lesson?

0 of 12 in Module 2
Sign in to save progress
PreviousStart of module
Next lessonWhat is a Token?

Topics in This Module

0/12 done