惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

量子位
Vercel News
Vercel News
Microsoft Azure Blog
Microsoft Azure Blog
爱范儿
爱范儿
N
Netflix TechBlog - Medium
Google DeepMind News
Google DeepMind News
H
Help Net Security
罗磊的独立博客
The Cloudflare Blog
J
Java Code Geeks
博客园 - 叶小钗
I
InfoQ
B
Blog
Blog — PlanetScale
Blog — PlanetScale
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
腾讯CDC
月光博客
月光博客
博客园_首页
雷峰网
雷峰网
M
MIT News - Artificial intelligence
博客园 - 【当耐特】
美团技术团队
T
The Blog of Author Tim Ferriss
博客园 - 司徒正美

DEV Community

Authentication Security Deep Dive: From Brute Force to Salted Hashing (With Java Examples) Why AI Systems Don’t Fail — They Drift Spilling beans for how i learn for exam😁"Reinforcement Learning Cheat Sheet" I Replaced Chrome with Safari for AI Browser Automation. Here's What Broke (and What Finally Worked) How Python Borrows Other People's Work The $40 Architecture: Processing 1 Billion API Requests with 99.99% Uptime Vibe Coding: A Workflow Guide (From Zero to SaaS) Most webhook security guides protect the wrong side. The scary part is delivery. Headless CMS for TanStack Start: Build a Blog with Cosmic EU Age Verification App "Hacked in 2 Minutes" — What Actually Happened Comfy Cloud’s delete function does not actually remove files Running AI Models on GPU Cloud Servers: A Beginner Guide Event-driven media intelligence with AWS Step Functions and Bedrock I scored 500 AI prompts across 8 quality dimensions — here's what broke How to Call Google Gemini API from Next.js (Free Tier, No Backend Needed) The Portal Protocol: Reclaiming Human Connection in the Age of AI How to Fix Your Team's Scattered Knowledge Problem With a Self-Hosted Forum Intro to tc Cloud Functors: A Graph-First Mental Model for the Modern Cloud Designing Multi-Tenant Backends With Both Ownership and Team Access I Built a Neumorphic CSS Library with 77+ Components — Here's What I Learned PostgreSQL Performance Optimization: Why Connection Pooling Is Critical at Scale Cómo construí un SaaS multi-rubro para gestionar expensas en Argentina con FastAPI + Vue 3 🚀 I Built an Ethical Hacking Scanner Tool – Open Source Project I Replaced /usage and /context in Claude Code With a Single Statusline A Pythonic Way to Handle Emails (IMAP/SMTP) with Auto-Discovery and AI-Ready Design I Collected 8.9 Million Polymarket Price Points — Here's What I Found About How Markets Really Move EcoTrack AI — Carbon Footprint Tracker & Dashboard Everyone's Using AI. No One Agrees How. 5 self-hosted ebook managers worth trying in 2026 Building Your First AI Agent with LangChain: From Chatbot to Autonomous Assistant
What an LLM Actually Does: Predicting the Next Word, Expl...
Devanshu Biswas · 2026-06-17 · via DEV Community

Devanshu Biswas

"How does ChatGPT think?" It doesn't. The entire mechanism behind every chatbot is almost anticlimactic: it predicts one next word, adds it, and repeats. I built a tiny interactive predictor so you can be the model — and it explains both the magic and the flaws.

🔮 Be the model: https://dev48v.infy.uk/ai/days/day6-next-token.html

This is Day 6 of AIFromZero — AI literacy, one concept a day, no code to follow.

1. It only predicts the NEXT word

Given everything so far, the model outputs a probability for every possible next word, picks one, appends it, and runs again with the longer text. Paragraphs, code, poems — all of it is this one step on repeat.

"the cat sat on the ___" → P(mat) high, P(bird) low

2. It's a probability over the WHOLE vocabulary

The output isn't one word — it's a number for every word it knows (100,000+ for a real model). Most are near zero; a handful are plausible. The bars in the demo are that distribution, over a tiny vocabulary.

3. Autoregression: feed the output back in

After picking a word, it becomes part of the input for the next prediction. Predict → append → predict again. Because each new word conditions on all the previous ones, short local choices add up to coherent long text.

4. Temperature = the creativity dial

Once you have probabilities, how do you choose? Temperature reshapes them before sampling:

  • Near 0: the top word always wins — safe, repetitive.
  • High: the odds flatten, so rarer words get a real chance — creative, error-prone.
p = p ** (1 / temperature);   // then renormalise and sample

Drag the slider in the demo and watch the bars sharpen or even out. That one knob is what an API calls "creativity."

5. Where do the probabilities come from?

In my toy, from counting which word followed which in a few sentences (a "bigram" with 1-word memory). A real LLM replaces the counting with a giant neural network trained on much of the internet, and its memory spans thousands of words. The mechanism is identical — only the quality of the guess changes.

6. Why this explains so much

"Just predicting the next word" explains the fluency (it has seen how language flows) AND the hallucinations: a plausible-sounding next word isn't always a true one. It optimises for likely, not correct. That gap is where made-up facts live — and it's tomorrow's topic.

The takeaway

Predict next word → append → repeat; temperature tunes the daring. Understand this loop and "the AI thinks…" stops being mysterious and starts being mechanical. Try being the model — click words and watch a sentence build.