JA EN
LearnModel Families
·★ MEMBER·9 min read

The Llama Family from Scratch — The Main Line of Open LLMs

How Meta's Llama became the main line of open LLMs. The contrarian bet behind Llama 1, the lineage running through Llama 3.x, the llama.cpp / GGUF / Ollama ecosystem that grew around it, and the licensing traps to read before you ship commercially — starting from no prior knowledge.

ModalitytextTaskmodel-guideModel familyllama

The restaurant that published its recipes

A closed LLM like ChatGPT is a fine restaurant. You get to eat the food — the answers — but the recipe, the model's insides, never leaves the kitchen. You cannot borrow the kitchen, and you cannot adjust the seasoning to your own taste.

An open LLM hands out the recipe instead — or more precisely, the weights: the billions of parameter values a neural network ends up holding once training is done. Get the weights and everything else opens up. You can run the model on your own laptop or server, keep training it on in-house data, or take it apart to study how it works.

Since 2023, the centre of that open world has been Meta's Llama family. Get this lineage straight once and news about the other open models — Mistral, Qwen, Gemma — starts reading easily too, because most of them take Llama's design as their starting point.

Llama 1 (February 2023) — the contrarian bet: build it small, train it long

The received wisdom at the time was that capability follows parameter count. GPT-3 had 175 billion parameters, and every lab was racing to build something bigger. Then DeepMind's Chinchilla work (2022) showed that for a fixed compute budget you come out ahead by shrinking the model and feeding it more training data.

Llama 1 took that one step further. The stance: accept some inefficiency in training cost in exchange for a smaller model that is cheap to run at inference time, and train it on as many tokens as you possibly can. Four sizes — 7B, 13B, 33B and 65B — trained on up to 1.4 trillion tokens. The paper reported that the 13B model beat GPT-3, more than ten times its size, on many benchmarks. That was the moment "bigger is not everything" stopped being an argument and became a result.

The license was research-only and gated behind an application, but the weight files leaked onto the internet not long after release. Ironically, it was that leak that moved history. Within weeks came derivatives — Stanford's Alpaca (Llama 7B trained further on instruction-response data), then Vicuna, then more. What formed there is the prototype of today's open-LLM culture: as long as somebody builds the foundation, seasoning it — fine-tuning — takes very little compute.

Before the lineage: an LLM is a machine that outputs the probability of the next word

There is one operating principle shared by every Llama that is worth pinning down first. An LLM is a machine that outputs a probability distribution over what the next token — a fragment of a word — will be as the text continues. And the dial that controls how sharply peaked that distribution is is the temperature TT.

pi=exp(zi/T)jexp(zj/T)p_i = \frac{\exp(z_i / T)}{\sum_j \exp(z_j / T)}
(1)

Read it in words: take the raw score ziz_i the model assigned to each candidate token ii — called the logit — divide it by the temperature TT, then convert it into a probability pip_i with a softmax, the normalisation that makes everything sum to 1. Turn TT down and probability piles onto the top candidate, so the output goes rigid and stable; turn it up and the gaps between candidates flatten out, so the output goes varied and random.

FIG 1Move the temperature T and the next-token distribution goes from spiky to flat. The --temp flag in llama.cpp, which shows up later in this article, is exactly this T

The --temp option in the local-inference tools coming up is handing you that TT directly.

A look inside: a conservatively improved Transformer

Llama's architecture is a decoder-only Transformerattention stacked many layers deep. There is almost nothing newly invented in it; what characterises it is that it soberly loads in every improvement already shown to work by that point. Three of them stand out.

The first is RMSNorm (pre-normalisation). Before a vector enters a layer, divide it by its own "typical magnitude" to put everything on a common scale.

Read it in words: take the -dimensional input , divide it by the root of the mean of its squared components — that root is the vector's typical magnitude — to equalise the length, then scale it back component by component with a learnable gain ( is a tiny constant that prevents division by zero, and is the element-wise

What's behind this

§

Members-only from here

371 walkthroughs, 26 textbook chapters, 48 student units and 6 close readings — all included for $4.99/mo, with three new explainers every day. Cancel any time; access runs to the end of the period.

Already a member? Sign in to keep reading

Comments

Sign in to comment