How to measure log-perplexity yourself (and what OpenAI's 0.76 means)
Short answer
Log-perplexity is the average cross-entropy loss a model gets when it predicts the next token of text it has never seen. Lower is better. To measure it yourself, take a held-out text file, run an open base model over it with a sliding window, add up the negative log-probability of every real next token and divide by the number of tokens. That's about 25 lines of Python with Hugging Face Transformers, and it runs on a laptop CPU. When we did it on 27 KB of our own Python code, Qwen2.5-1.5B scored 1.548 nats per token and GPT-2 scored 2.700. Those numbers can't be compared with OpenAI's ~0.76 for GPT-6.2 Astra, because OpenAI measures on a private snapshot of its own codebase with its own tokenizer.
On Sunday, November 22, OpenAI chief scientist Jakub Pachocki published "Perplexity and Intelligence", and with it a chart OpenAI had never shown before: the base-model log-perplexity of every major GPT since GPT-3.5. His post on X had 7,110,740 views, 11,230 likes and 5,557 bookmarks when we checked the X API at about 10:27 Dubai time on November 23. Sam Altman quoted it as "the most important thing OpenAI has published in awhile" (1,267,581 views).
Most write-ups explain what perplexity is and stop there. This one does the practical part: what the numbers on OpenAI's chart actually say, how to measure the same metric on your own text, and what we learned when we ran it on our own code this morning.
What is log-perplexity?
Every time a language model reads a token, it gives a probability to each possible next token. Take the probability it gave to the token that really came next, take the negative natural log, and average that over the whole text. That average is the cross-entropy loss, and it's the same thing as log-perplexity. Pachocki's essay says so in footnote 2: "In practice, we generally track the log of perplexity, also called cross-entropy loss."
Perplexity itself is just exp(log-perplexity). The Hugging Face perplexity guide defines it as "the exponentiated average negative log-likelihood of a sequence." A perplexity of 2 means the model is, on average, as unsure as if it were choosing between two equally likely tokens.
One quick conversion makes the numbers feel real. If the log is natural (the PyTorch default, and the usual meaning of "cross-entropy loss"), then exp(-log-perplexity) is the model's average probability on the correct next token, as a geometric mean. At 0.99 that's about 37%. At 0.76 it's about 47%.
What do OpenAI's log-perplexity numbers mean?
Pachocki's essay gives these figures in the text, and the chart adds the in-between models. All of them are measured on "held-out datasets ... sourced from our internal codebase" (footnote 3), for a fixed snapshot:
| Model or milestone | Log-perplexity | Perplexity (if natural log) | What OpenAI ties it to |
|---|---|---|---|
| GPT-3.5 | ~0.99 | 2.69 | Fluent conversation, the original ChatGPT |
| GPT-4 | ~0.91 | 2.48 | Productive chain-of-thought reasoning |
| Below 0.8 | < 0.8 | < 2.23 | "Transformative capabilities in fields like cybersecurity and mathematics" |
| GPT-6.2 Astra (chart) | ~0.76 | 2.14 | Chart line: "Solved a Millennium Prize math problem" |
| Unreleased internal model (chart) | ~0.73 | 2.08 | Plotted below GPT-6.2 Astra, no label |
| Next window | ~0.68 to 0.7 | 1.97 to 2.01 | "Further transformative capabilities", unknown which |
The GPT-6.2 Astra and internal-model values are read off the chart; the text itself says that once OpenAI "upgraded to a model of log-perplexity ~0.76, it started producing groundbreaking results" on open math problems. The perplexity column is our own arithmetic, and it assumes natural log, which the essay doesn't state outright.
Two details are easy to miss. First, the whole drop from GPT-3.5 to GPT-6.2 Astra is only about 0.23 nats per token, yet it spans the jump from chat to Millennium Prize math. Pachocki warns that as loss approaches the unknown floor of the data, "smaller gains on perplexity will correspond to larger leaps in model intelligence." Second, the metric only covers pretraining: "chain-of-thought reasoning does not reduce perplexity achieved by the model, even though it leads to a drastic increase in capabilities."
How do you measure log-perplexity yourself?
You need Python, an open base model (not a chat-tuned one) and a text the model hasn't seen. The steps, following the sliding-window method in the Hugging Face guide:
- Pick held-out text. Anything written after the model's training cutoff works. OpenAI uses its own code; we used our own Python scripts from October and November 2026.
- Install the tools.
pip install torch transformers(we used the CPU build of PyTorch 2.15.0 and Transformers 5.24.0). - Tokenize the whole file with the model's own tokenizer.
- Slide a window of 1,024 tokens forward 512 tokens at a time, and only score the tokens that are new in each window, so every token is scored once with at least 512 tokens of context.
- Sum the negative log-likelihoods and divide by the number of scored tokens. That's log-perplexity.
exp()of it is perplexity. Divide the sum byln 2 × bytesto get bits per byte.
Here is the script, trimmed for reading. Saved as logppl.py, it gives the same numbers as our full run (GPT-2 on our code: 2.700, 14.89, 1.701):
import math, sys, torch
from transformers import AutoModelForCausalLM, AutoTokenizer
def score(model_id, path, window=1024, stride=512):
tok = AutoTokenizer.from_pretrained(model_id)
model = AutoModelForCausalLM.from_pretrained(model_id).eval()
text = open(path, encoding="utf-8").read()
ids = tok(text, return_tensors="pt").input_ids
n = ids.size(1); nll, scored, prev_end = 0.0, 0, 0
for begin in range(0, n, stride):
end = min(begin + window, n); new = end - prev_end
x = ids[:, begin:end]; y = x.clone(); y[:, :-new] = -100
with torch.no_grad():
logits = model(x).logits[:, :-1]
labels = y[:, 1:]
nll += torch.nn.functional.cross_entropy(
logits.reshape(-1, logits.size(-1)), labels.reshape(-1),
ignore_index=-100, reduction="sum").item()
scored += (labels != -100).sum().item(); prev_end = end
if end == n: break
lp = nll / scored
bpb = nll / (math.log(2) * len(text.encode("utf-8")))
return lp, math.exp(lp), bpb
for m in sys.argv[2:]:
print(m, "log-ppl %.3f ppl %.2f bits/byte %.3f" % score(m, sys.argv[1]))
Run it like this: python logppl.py my_code.py gpt2 Qwen/Qwen2.5-0.5B Qwen/Qwen2.5-1.5B. If you already use llama.cpp, its perplexity tool does the same job on GGUF files, though its README warns its numbers "are not directly comparable to those of other projects."
Get the AI tools worth your time
Era of Minds by Salman Ahmed: one short email with the AI tools and news that actually matter. Free.
You're in. Check your inbox.
Confirm your email and your 50 AI prompts are on their way.
Free. Unsubscribe anytime.
What did we get when we measured log-perplexity on our own code?
We ran the script on the box we use for this blog: 8 CPU cores, 15 GB of RAM, no GPU. Two held-out files: 27,089 bytes of our own Python (the cover builder, page generator and X-scan parser behind this site, written in October and November 2026) and 12,785 bytes of English from our November 22 Riemann post. All four models came out before any of that text existed. All four runs on the code file took about 4 minutes in total.
| Model | Tokens (code) | Log-ppl, code | Bits/byte, code | Log-ppl, English | Bits/byte, English |
|---|---|---|---|---|---|
| GPT-2 (124M, 2019) | 11,828 | 2.700 | 1.701 | 4.075 | 1.460 |
| Qwen2.5-0.5B | 9,089 | 1.819 | 0.880 | 3.397 | 1.248 |
| Qwen2.5-Coder-0.5B | 9,089 | 1.705 | 0.825 | 3.385 | 1.244 |
| Qwen2.5-1.5B | 9,089 | 1.548 | 0.749 | 3.051 | 1.121 |
Four things stand out:
- The dataset matters more than the model. The same Qwen2.5-0.5B scores 1.819 on our code and 3.397 on our English. Code is repetitive and predictable; blog prose isn't.
- The tokenizer changes the denominator. GPT-2 needs 11,828 tokens for the same file Qwen covers in 9,089. Per-token numbers across tokenizers aren't apples to apples, which is why bits per byte exists. Karpathy's nanochat reports bits per byte for exactly this reason, calling it "a tokenization vocab size-independent metric."
- Scale shows up clearly. Going from Qwen2.5-0.5B to 1.5B, same family and tokenizer, cut code loss from 1.819 to 1.548. That's the kind of within-one-setup comparison Pachocki's chart makes.
- Specialists win at home. Qwen2.5-Coder-0.5B beats the general 0.5B model on code (1.705 vs 1.819) but is basically tied on English (3.385 vs 3.397).
Why can't you compare your log-perplexity with OpenAI's 0.76?
Because three things that drive the number are different. OpenAI's eval set is a private snapshot of its internal codebase. Its tokenizer is different from GPT-2's or Qwen's. And the window and stride settings change results too: the Hugging Face guide shows GPT-2 large on WikiText-2 dropping from a perplexity of 19.44 with no overlap (stride 1,024) to 16.44 with a stride of 512, with the same model and same text.
Pachocki lists this himself as the first challenge: "Different developers use different evaluation datasets and train on different data mixtures." His footnote 4 adds that how well GPT-2 and GPT-3 predict code "is a poor proxy for their general capabilities." So a low number on your code says your model predicts your code well. It doesn't place your model on OpenAI's chart.
What you can do with it: compare models on your text under one fixed setup. That is genuinely useful for picking a local model for a codebase, checking whether a quantized model lost quality against its full-precision version (the main use in llama.cpp), or tracking a fine-tune.
Log-perplexity vs perplexity vs bits per byte: which should you report?
- Log-perplexity (nats per token): what training loops print and what OpenAI's chart uses. Good inside one tokenizer.
- Perplexity:
expof the above. Easier to say out loud, but it hides how small the late gains are (2.69 to 2.14 for GPT-3.5 to GPT-6.2 Astra). - Bits per byte: total loss in bits divided by UTF-8 bytes. Use this when comparing models with different tokenizers, like GPT-2 against Qwen in our table.
Whichever you pick, write down the dataset, tokenizer, window and stride next to it. Without those, the number means very little.
What is OpenAI proposing with perplexity limits?
Pachocki wants frontier labs to share comparable perplexity numbers and agree on "common limits, based on perplexity and other measurements, that developers are committed to not crossing until our ability to understand and monitor AI behavior achieves a certain concrete milestone (such as the development of a successor to CoT monitors)." He writes that "as soon as 2027" AI could set off "a similar avalanche of fundamental pretraining advancements" to what OpenAI saw in math. Altman wrote that common limits "would be very wise and help ensure safety and control."
He's open about the weak spots: perplexity is hard to compare across labs, it doesn't map to a task anyone cares about, it ignores gains from reasoning, and nobody knows the floor. Our small test shows the first problem in miniature. If OpenAI wants a shared bar, labs would first need a shared eval set and a tokenizer-neutral unit like bits per byte.
For the other big AI-and-math story of the week, see how to verify the Riemann Hypothesis Lean proof yourself. If you want to try bigger local models than the ones above, our Edge0-145B laptop requirements post covers RAM and hardware limits, and Qwen4-Max in Claude Code covers the newest Qwen model.
Get the AI tools worth your time
Era of Minds by Salman Ahmed: one short email with the AI tools and news that actually matter. Free.
You're in. Check your inbox.
Confirm your email and your 50 AI prompts are on their way.
Free. Unsubscribe anytime.
FAQ: log-perplexity
What is log-perplexity?
Log-perplexity is the average negative log-probability a language model gives to the real next token across a held-out text. It is the same number as cross-entropy loss. Lower means the model predicts the text better. Perplexity is exp(log-perplexity).
How do I measure log-perplexity of a model myself?
Load an open base model and its tokenizer with Hugging Face Transformers, tokenize a text the model hasn't seen, slide a 1,024-token window forward 512 tokens at a time, sum the cross-entropy of the newly covered tokens and divide by the number of tokens scored. Our 25-line script did this for GPT-2 and three Qwen2.5 models on an 8-core CPU in about 4 minutes for a 27 KB code file.
What does OpenAI's log-perplexity of 0.76 mean?
It is the base-model cross-entropy loss OpenAI's chart shows for GPT-6.2 Astra on a fixed snapshot of OpenAI's internal codebase. Jakub Pachocki writes that once OpenAI had a model at about 0.76 it started producing groundbreaking math results. If the log is natural, 0.76 equals a perplexity of about 2.14, or an average probability of about 47% on the correct next token.
Can I compare my log-perplexity with OpenAI's numbers?
No. OpenAI measures on its private codebase snapshot with its own tokenizer. In our test the same Qwen2.5-0.5B model scored 1.819 on our code and 3.397 on our English text, and GPT-2 needed 11,828 tokens for a file Qwen covered in 9,089. Compare models only on the same text with the same settings.
What is the difference between perplexity, log-perplexity and bits per byte?
Log-perplexity is loss in nats per token. Perplexity is exp of that. Bits per byte divides the total loss in bits by the number of UTF-8 bytes in the text, so it stays comparable across models with different tokenizers. In our test GPT-2 scored 1.701 bits per byte on our code and Qwen2.5-1.5B scored 0.749.
Why does a lower log-perplexity matter?
Pachocki argues that lower pretraining loss is where surprising new capabilities come from: GPT-3.5 at about 0.99 handled fluent conversation, GPT-4 at about 0.91 made chain-of-thought useful, and below 0.8 OpenAI saw big jumps in cybersecurity and math. He expects more new capabilities in the 0.68 to 0.7 range.
Does chain-of-thought reasoning lower log-perplexity?
No. Pachocki writes that chain-of-thought reasoning does not reduce the perplexity a model achieves, even though it greatly increases capability. Log-perplexity measures the pretrained base model, not reasoning or post-training gains.
What are OpenAI's proposed perplexity limits?
Pachocki proposes common limits, based on perplexity and other measurements, that AI developers would commit not to cross until the ability to understand and monitor AI behavior reaches a concrete milestone, such as a successor to chain-of-thought monitors. Sam Altman called the essay the most important thing OpenAI has published in a while.
Sources
- OpenAI: "Perplexity and Intelligence" by Jakub Pachocki (November 22, 2026; essay, chart and footnotes)
- Hugging Face Transformers: Perplexity of fixed-length models (definition, sliding-window method, stride example)
- llama.cpp perplexity tool README
- karpathy/nanochat loss_eval.py (bits per byte)
- On X: @merettm (Jakub Pachocki) and @sama (metrics via X API, November 23, 2026, about 10:27 Dubai time)
- Our own run:
logppl.pyabove, PyTorch 2.15.0 CPU, Transformers 5.24.0, window 1,024, stride 512, November 23, 2026
Get AI news decoded weekly.
Decoded is a free weekly email from Era of Minds. The AI stories that actually matter, in plain English. Five minutes, no hype.
You're in. Check your inbox.
Confirm your email and your 50 AI prompts are on their way.
Free. Unsubscribe anytime. Free gift: 50 AI prompts that actually work, sent the moment you join. More about Decoded