← Course Home
Phase 1 · Week 1
12 minutes
Lesson 1.2b
Lesson 1.2b

Inside the Machine: How LLMs Work and How to Host Them

Slide 1

What You Will Learn

Three things. What is actually happening inside an LLM — tokenisation, transformer architecture, and what 'parameters' really means. How to use a model via a cloud API. And how to run an open-source model on your own machine using Ollama — free, private, works completely offline.

Slide 2

Step 1: Tokenisation — Text Becomes Numbers

The first thing that happens when you send a message to an LLM is that your text is broken apart into tokens. A token is roughly a word or part of a word. The sentence 'The agent scheduled a meeting' does not arrive at the model as letters or words — it arrives as a sequence of number IDs.

Key Insight
LLMs don't read words — they read tokens. Every modern LLM has a context window — a maximum number of tokens it can process at once. GPT-4 holds ~128,000 tokens; Claude holds up to 200,000.
Slide 3
Watch: Visual introduction to transformers — 3Blue1Brown (30 min, essential)

Step 2: The Transformer — Three Stages

Every modern LLM — Claude, GPT, Llama, Gemini — uses the same underlying architecture: the transformer, introduced in 2017. The name GPT literally stands for Generative Pre-trained Transformer.

Stage 1 — Embedding

Each token ID is looked up in an embedding table and converted into a vector of hundreds of numbers. These numbers encode the meaning and context of each word.

Stage 2 — Transformer Blocks

A stack of transformer blocks processes the vectors. Each block runs Attention (which words matter most to each other?) and a feed-forward layer (pattern lookup from training). A large model may have 96 or more of these blocks stacked.

Stage 3 — Language Model Head

The final vector is mapped to a probability score for every token in the vocabulary. The model picks the most likely next token. This repeats until the answer is complete. This is why LLM responses are generated word by word.

Slide 4

What Does '70 Billion Parameters' Actually Mean?

Parameters are the numbers inside the model — the values learned during training. More parameters means more capacity, but also more compute required to run the model.

ModelSizeNotesHosting
Llama 3.2 3B3BSmall but capableRuns locally on most laptops
Qwen 2.5 7B7BStrong general modelRuns locally on 8GB RAM
Llama 3.3 70B70BNear-frontier qualityNeeds 16GB+ VRAM locally
Claude Sonnet 4.6~200B+Best qualityCloud-only. Pay per token via API
Slide 5
Watch: Transformer Explainer — Interactive Visual (10 min)

Two Ways to Run a Model

Online — Cloud API

You send text to a remote server. Their hardware runs the model and returns the response. Advantages: no hardware needed, access to the largest models. Disadvantages: costs money per token, your data leaves your machine.

Services: Anthropic API · OpenAI API · Hugging Face Inference API

Local — Run on Your Machine

You download the model weights to your own computer and run them using Ollama. Advantages: completely free after setup, data never leaves your machine, works offline. Disadvantages: smaller models with less capability, requires decent hardware.

Which Should You Use?
For most student projects: start with a cloud API. Switch to local if your project involves sensitive data, you need to work offline, or you want to avoid per-token costs for high-volume testing.
Slide 7
.
✏️ Student Reflection
Go to huggingface.co/models Browse the text generation models and pick one open-source model. Read its model card and answer: What was it trained on and how many parameters does it have? Is it a good fit for an agent project? Would you run it online or locally? Why?

📝 Your Lesson Submission

Share your reflection, ask a question, or leave a comment. Your mentor will respond.

🔐

You need to be logged in to submit your reflection.

← Previous1.2aFrom Prompts to Pipelines: The Anatomy of an AI Agent
Next →1.3Real Demos: Watching Agents in Action🔒 Submit reflection to unlock
🔐

Create a Free Account to Continue

Lesson 1.1 and beyond are available to enrolled members. Join the program for free to access all 21+ lessons, mentor sessions, and your completion certificate.

🎓 Join the Program — It's FreeAlready a member? Log in