Availit World How AI really works, in your language

Lesson 3 of 4623 minFacts checked October 20, 2026

The AI stack: from chips to chat apps

Every AI product is a pile of layers, from a chip at the bottom to a chat window at the top. Learn the six layers once, and every new tool you hear about has a place to go.

In this lesson you will

  • Name the six layers of the AI stack, from the chip to the app
  • Know what is actually inside a model you download, file by file
  • Tell apart a model, the engine that runs it, the API it speaks and the harness that uses it
  • Understand why memory, more than raw speed, decides which models a computer can run
On this page
  1. One question, six layers
  2. The bottom: chips and memory
  3. The model: what is actually in the download
  4. Engines and APIs: making the model run
  5. The harness: what turns a model into a worker
  6. Open or closed, at home or in the cloud
  7. Remember
  8. Check yourself

One question, six layers

When you type a question into a chat app, it passes through several layers before an answer comes back. People in the field call this pile the stack. Here it is, top to bottom.

The AI stack
  1. Apps and agentsWhat you see and use: a chat app, a coding agent, a bot inside a messaging app
  2. HarnessThe code around the model: it adds instructions, offers tools, runs them, and manages the conversation
  3. API and serving engineTakes requests in an agreed format and runs the model for many people at once: llama.cpp, Ollama, vLLM, SGLang
  4. ModelFiles of weights, plus the tokenizer and the chat template
  5. KernelsSmall, tuned programs that do the maths on the chip: CUDA on Nvidia, Metal on Apple
  6. HardwareThe chips and their memory: GPUs, CPUs, phones, data centres

Each layer talks only to the ones next to it, so you can swap one without touching the rest. The same model file runs under llama.cpp on a laptop and under vLLM in a data centre. The same harness can drive DeepSeek one day and Claude the next. When a new tool appears in the news, the first useful question is: which layer is it?

The bottom: chips and memory

Almost all the work a model does is multiplying large tables of numbers, called matrices (you will meet them properly in part 2). The same simple sum is repeated billions of times, and most of those sums do not depend on each other, so they can all be done at the same moment.

CPU: a few strong workers

  • The main chip in every computer and phone, usually with 4 to 24 cores.
  • Each core is fast and clever, and good at long chains of different steps.
  • Can run small models, but slowly, because it does few sums at a time.

GPU: thousands of simple workers

  • Built to draw video games, which also means doing the same sum on many numbers at once.
  • A high-end gaming GPU has over ten thousand small cores; data-centre GPUs add special units just for matrices.
  • This is why the AI boom runs on GPUs, and why Nvidia became one of the world’s most valuable companies.

Here is the surprise: for writing text, the speed of the sums is usually not the limit. Memory is. To write each new token, the chip has to read every weight it uses from memory, once. A model of 5 GB means 5 GB read for every single token. So two numbers decide what a machine can do with a model:

  • How much memory it has. If the model does not fit, it cannot run, or it runs very slowly from slower memory.
  • How fast that memory is, called memory bandwidth and measured in gigabytes per second (GB/s). This sets the top speed at which it can write.
Some real machines
MemoryMemory speedWhat it can run
Nvidia RTX 3060 (gaming card)12 GB360 GB/sModels up to about 14B parameters, squeezed to 4 or 5 bits per weight
Nvidia RTX 4090 (gaming card)24 GBabout 1,008 GB/sModels up to about 30B, squeezed
Nvidia RTX 5090 (gaming card)32 GBabout 1,792 GB/sModels up to about 40B, squeezed, quickly
Apple M5 Max laptopup to 128 GB, shared with the CPUup to 614 GB/sLarge models, including mixtures of experts of over 100B, more slowly
Nvidia H100 SXM (data centre)80 GB3,350 GB/sServing big models to many users; several are linked for the largest

Bandwidth figures are the makers’ own. “Squeezed” means quantized, which has its own lesson in part 6.

The top speed of writing, roughly
tokens per second ≤ memory bandwidth ÷ bytes read per token

Every token needs the weights read once, so the memory speed sets a ceiling.

1,008 GB/s ÷ 4.9 GB ≈ 200 tokens per second

An 8B model squeezed to 4.9 GB, on an RTX 4090. Real programs stay below this ceiling, because there is other work to do as well.

Between the model and the chip sit kernels: small, heavily tuned programs that each do one job, such as multiplying two matrices or computing attention. Nvidia’s are written in CUDA, Apple’s in Metal; AMD uses ROCm, and Vulkan works on most graphics chips. A better kernel makes the same model on the same chip faster. In 2022, FlashAttention rearranged how attention reads and writes memory, and GPT-2 trained about 3 times faster with exactly the same maths.

Quick check

Why does a model run faster when its file is made smaller, even on the same chip?

Show the answer

Answer: Each token needs the weights read from memory, and fewer bytes take less time to read Writing text is limited by memory bandwidth. Halve the bytes that must be read for each token and you roughly double the top speed. llama.cpp measured Llama 3.1 8B going from 29 to 72 tokens per second when it was squeezed from 16 bits to about 5 bits per weight.

The model: what is actually in the download

Open models are shared on Hugging Face, a website that works like a library for models and datasets. Each model has a page with a list of files. Here is the real list for Qwen/Qwen3.8-27B, a 27.8-billion-parameter open model from Alibaba’s Qwen team, released in August 2026.

The main files of Qwen3.8-27B (original weights)
FileWhat it holds
config.jsonThe model’s shape: how many layers, how many attention heads, how long each vector is. A few kilobytes.
model-00001-of-00018.safetensors …The weights themselves, split into 18 files: 27.8 billion numbers at 16 bits each, 55.6 GB in all.
model.safetensors.index.jsonA map of which weight is in which of the 18 files.
tokenizer.json, vocab.json, merges.txtThe tokenizer: how text is cut into tokens and how each token gets its number.
chat_template.jinjaHow a conversation (instructions, your messages, the model’s replies, tool calls) is written out as one long text for the model to read.
generation_config.jsonSuggested settings for picking tokens, such as the temperature.

That is all a model is: a description of its shape, a huge pile of numbers, and the rules for turning text into numbers and back. No hidden database of facts, no list of answers. Everything it knows is spread across those 27.8 billion weights.

Where 55.6 GB comes from
size in bytes = parameters × bits per weight ÷ 8

There are 8 bits in a byte.

27.8 billion × 16 ÷ 8 = 55.6 billion bytes = 55.6 GB

The original weights use 16 bits (2 bytes) per number.

55.6 GB is too big for most computers. So the same model is also published in GGUF, the single-file format of llama.cpp, which packs the weights, the tokenizer and the chat template together. GGUF files are usually quantized: each weight is stored with fewer bits, losing a little accuracy to save a lot of memory.

One model, three sizes (the text part of Qwen3.8-27B as GGUF)
  • BF16, 16 bits per weight 53.8 GB
  • Q8_0, about 8.5 bits 28.6 GB
  • Q4_K_M, about 5.6 bits 19 GB

The vision part comes as a separate small file, mmproj (0.93 GB). The repository also has mtp and dflash files: small draft helpers that let it write faster by guessing several tokens ahead. All sizes from the Hugging Face file listings, 20 October 2026.

Quick check

A model has 8 billion parameters. Roughly how big is its file at 16 bits per weight?

Show the answer

Answer: About 16 GB 16 bits is 2 bytes, and 8 billion × 2 bytes = 16 billion bytes, about 16 GB. Squeezed to about 5 bits per weight it would be about 5 GB.

Engines and APIs: making the model run

A weight file does nothing by itself, just as a recipe book does not cook. A serving engine (also called an inference engine) loads the weights into memory, turns your text into tokens, runs the maths through the kernels, picks each next token and sends the answer back, often to many people at the same time. These are the main ones, all free and open source.

The engines you will hear about
EngineBest atRuns on
llama.cppRunning models on ordinary computers and phones, from GGUF files, squeezed to fitAlmost anything: Nvidia, AMD, Apple, Intel, plain CPUs
OllamaThe easiest start: one command downloads a model and opens a chat; it also serves an API on your machineWindows, Mac and Linux
vLLMServing many users at once in a data centre; it invented PagedAttention, a way to share GPU memory between requestsData-centre GPUs
SGLangFast serving, especially for agents that send the same long instructions again and againData-centre GPUs
mlx-lmRunning models on Macs with Apple chips, using Apple’s MLX libraryApple Macs

An engine usually waits at a web address and speaks an API (application programming interface): an agreed format for questions and answers, so that programs can talk to it. Most of the industry copied OpenAI’s format, at the address /v1/chat/completions. That means the same code can talk to DeepSeek’s servers, a vLLM server or llama.cpp on your own laptop, just by changing the address. Anthropic’s format, /v1/messages, is the other common one. DeepSeek’s API and llama.cpp’s server both speak both.

Two ways to run a model yourselfbash
$ ollama run gemma4

$ llama cli -hf ggml-org/gemma-4-E4B-it-GGUF:Q4_0

$ llama serve -hf ggml-org/gemma-4-E4B-it-GGUF:Q4_0

$ curl http://localhost:9931/v1/chat/completions \
    -H "Content-Type: application/json" \
    -d '{"messages": [{"role": "user", "content": "What is a GPU?"}]}'
  • ollama run gemma4 downloads Google’s Gemma 4 model and opens a chat in the terminal.
  • llama cli does the same with llama.cpp. -hf downloads from Hugging Face, and :Q4_0 picks the 4.6 GB squeezed file of the small Gemma 4 E4B model.
  • llama serve starts a server on your own computer instead, at port 9931, that speaks the OpenAI and Anthropic APIs.
  • curl sends it a question in the OpenAI format, the same way any app would. The lesson on local AI walks through all of this step by step.

The harness: what turns a model into a worker

A model only ever does one thing: it reads text and writes text. It cannot open a file, search the web, or remember yesterday. Everything else is done by the program around it. The documentation of Claude Code, a coding agent, calls that program the agentic harness: “the layer around the model that provides the tools and manages the context”.

Watch a harness at work. Press the button to step through one small request.

One request, through a harness
  1. You

    How much free space is left on my disk?

  2. Harness

    Sends the model three things: its standing instructions, a list of the tools it may use (here, one that runs a command), and your question.

  3. Model

    Asks for a tool instead of guessing:

    {"tool": "run_command", "command": "df -h /"}
  4. Harness

    Checks that this command is allowed, runs it on your computer, and adds the output to the conversation.

  5. Tool result

    Size  Used  Avail  Use%
    476G  301G  151G   67%
  6. Model

    You have about 151 GB free on your main drive, out of 476 GB. It is two thirds full.

That loop (the model asks for a tool, the harness runs it, the result goes back into the text the model reads) is what makes an agent. The harness also decides what the model sees: which instructions, which files, how much of the conversation, and what to drop when the text gets too long. Part 7 of the course is all about it.

The harness matters as much as the model. A study of coding agents published in September 2026 changed only the harness around the same models. With a small working memory of 32,000 tokens, one model solved 6.4 % of the tasks when the harness did nothing about old tool output, and 55.6 % when the harness trimmed and summarised it. That is why model makers now name the harness next to their agent scores.

Open or closed, at home or in the cloud

You now have the words for one of the biggest choices in AI: where the model layer and the layers below it live.

Three ways to use a model
Open model, on your own machineOpen model, in the cloudClosed model, through its maker
ExamplesGemma 4, Qwen3.8 or gpt-oss, through llama.cpp or OllamaDeepSeek, Kimi or GLM, on the maker’s API or a hosting companyGPT, Claude, Gemini, Grok
Your dataNever leaves your computerSent to the providerSent to the provider
CostThe computer you already have, and electricityPay for each token, often cheaplyPay for each token, or a monthly plan
Size limitYour memoryNone for you: the largest open models have over a trillion parametersNone for you; often the strongest models
ControlComplete: you can look inside, fine-tune it, and keep the exact version for everYou choose the model; the provider runs itThe maker can change or retire a model at any time

Many people mix them: a small local model for private notes or for working offline, and a large cloud model for the hardest jobs. Because almost everything speaks the same API, switching is often a one-line change.

Which layer of the stack does each one belong to?

0 of 8 sorted
  • An RTX 4090 graphics card

    Answer: Hardware

  • Qwen3.8-27B-Q4_K_M.gguf

    Answer: Model

  • llama.cpp

    Answer: Engine or API

  • Claude Code

    Answer: Harness or app

  • tokenizer.json and config.json

    Answer: Model

  • An Apple M5 Max chip

    Answer: Hardware

  • http://localhost:11434/api/chat, Ollama’s address on your machine

    Answer: Engine or API

  • A chat app that searches the web for you

    Answer: Harness or app

Remember

  • The AI stack has six layers: hardware, kernels, the model, the serving engine and its API, the harness, and the app.
  • GPUs do thousands of sums at once. For writing text, memory size decides what fits and memory bandwidth sets the top speed.
  • A downloaded model is a shape (config.json), the weights (safetensors or GGUF), a tokenizer and a chat template. Size ≈ parameters × bits per weight ÷ 8.
  • Serving engines (llama.cpp, Ollama, vLLM, SGLang, mlx-lm) run models. Most speak OpenAI’s API format, so programs can switch between them.
  • The harness gives the model tools and decides what it sees. The same model can do far better or worse depending on its harness.

Words to know

Stack
The layers that work together to make an AI product, from the chip to the app.
GPU
Graphics processing unit: a chip with thousands of simple cores that do the same sum on many numbers at once.
Memory bandwidth
How many gigabytes per second a chip can read from its memory. It sets the top speed for writing text.
Kernel
A small, tuned program that does one maths job on a chip, such as multiplying two matrices.
Hugging Face
The main website where open models and datasets are shared.
Safetensors
A file format that holds only named lists of numbers, so opening it cannot run hidden code.
GGUF
llama.cpp’s single-file model format: weights, tokenizer and chat template together, usually quantized.
Quantization
Storing each weight with fewer bits, to save memory and run faster, at a small cost in accuracy.
Serving engine
The program that loads a model and runs it: llama.cpp, Ollama, vLLM, SGLang.
API
An agreed format that lets programs send a model questions and get answers.
Harness
The program around a model that gives it tools, runs them and manages what the model sees.

Go to the source

This lesson is built on these papers and documents. Paper links open arxiv.org, a separate site.

Check yourself

6 questions. Tap the answer you think is right.

0 of 6 answered

Which layer of the stack is vLLM?

Show the answer

Answer: The serving engine vLLM is a program that loads models and runs them for many users. It is not a model itself, and it needs hardware underneath.

For writing text, what usually limits how fast a model runs on a computer?

Show the answer

Answer: How fast its memory can be read Each new token needs the model’s weights read from memory once, so memory bandwidth sets the ceiling.

What is in a model’s .safetensors files?

Show the answer

Answer: The model’s weights: billions of numbers Safetensors files hold the weights and nothing else. The engine that runs them is a separate program.

A 30-billion-parameter model is stored at 4 bits per weight. About how big is it?

Show the answer

Answer: About 15 GB 30 billion × 4 ÷ 8 = 15 billion bytes, about 15 GB. Real files are a little larger, because some parts are kept at higher precision.

Why can the same code talk to DeepSeek’s servers and to llama.cpp on a laptop?

Show the answer

Answer: Both speak the same API format, so only the address changes Most engines and providers copied OpenAI’s chat-completions format. Changing the web address is enough to switch.

What does a harness do?

Show the answer

Answer: Gives the model tools, runs them and manages what the model sees The model only reads and writes text. The harness turns its tool requests into real actions and decides what goes into its context.

Lesson complete

Answer every question above to complete this lesson.

Your progress is saved on this device only.

Next lessonVectors: lists of numbers that mean something
Previous lesson All lessons

Choose your language