Learn / Lessons

Model sizes and quantization

Why does one model run on your machine, and another one won't even load? Today we're looking at the model itself.

Chapters

  1. 0:00Introduction
  2. 0:06Where this fits: The AI stack
  3. 0:09Size words: GB and 7B
  4. 0:21Size: Count the numbers
  5. 0:31The sum: Fewer bits, less space
  6. 0:43Quantization: The trade-off
  7. 0:52Decoding names: AWQ, GPTQ, GGUF
  8. 1:04Mixture of experts: Many experts, few at work
  9. 1:13Wrap up
Read the transcript

Introduction

Why does one model run on your machine, and another one won't even load?

Where this fits: The AI stack

Today we're looking at the model itself.

Size words: GB and 7B

A gigabyte, written GB, is about a billion bytes. Files and memory are measured in it. In a model's name, 7B means seven billion numbers, not bytes.

Size: Count the numbers

Models are sized by their parameters: how many numbers they hold. Seven billion is common. Seventy billion is ten times as many to store.

The sum: Fewer bits, less space

At 16 bits each, seven billion numbers need about 14 gigabytes. At 8 bits, about 7. At 4 bits, about 3 and a half. Running it needs extra room on top.

Quantization: The trade-off

Shrinking the numbers like this is called quantization. You save memory and may gain speed, but quality can slip.

Decoding names: AWQ, GPTQ, GGUF

You'll spot AWQ and GPTQ: two careful ways to shrink weights after training. And GGUF is a file format used by llama.cpp and other tools.

Mixture of experts: Many experts, few at work

Some models are a mixture of experts. A router picks a few for each token. They all still need to be in memory, though.

Wrap up

Do the sum, then test the exact version you'll run.

Sources

More lessons