How language models work, from tokens to reasoning
What happens inside ChatGPT style models: tokens, context windows, training runs, reasoning modes, model size, RAG versus fine tuning and open weights.
A language model does not look answers up in a database. It chops your message into tokens, predicts which token should come next, adds it and repeats, thousands of times, until the reply looks finished. Nearly everything that puzzles people about these assistants falls out of that one loop: the fluent wrong answers, the forgetting halfway through a long chat, the pricing by the word fragment, the sudden competence at one task and blankness at another.
Take the prediction loop itself first, then what a token is and why it decides your bill, since tokens are the unit everything else gets measured in. The context window explains why a long conversation starts losing its own beginning, and what a reasoning model does when it thinks before answering covers the slower, pricier mode most assistants now offer you.
If you are putting a model to work on your own documents rather than just chatting with one, the choice usually comes down to retrieval against fine tuning, and it is much cheaper to get that right at the start than to rebuild it later.
Articles in this hub
- How a language model actually works: tokens and probabilityWhat happens between your question and the answer: tokens, attention, probability over next words, and why a chatbot sounds certain about things it never checked.
- What tokens are and why they decide your AI billTokens explained: how text is chopped into pieces, roughly how many tokens a page holds, and why they set both the price you pay and the limits you hit.
- Context windows: why an AI forgets the start of a long chatWhat a context window is, what happens when a conversation or document overflows it, and practical ways to keep a long session accurate instead of drifting.
- How an AI model is trained, from raw text to chatbotThe three stages behind every chatbot: pretraining on huge text collections, supervised fine tuning on example answers, and reinforcement from human feedback.
- Reasoning models: what thinking before answering meansHow reasoning modes differ from a normal chatbot reply, what the visible thinking steps really are, when the extra time and cost pay off, and when they do not.
- Model size explained: do more parameters mean better answers?What parameters and model sizes actually mean, why a smaller newer model often beats a bigger older one, and how to read the numbers in model names.
- Temperature, top-p and the settings that change AI answersWhat temperature, top-p, max tokens and system settings actually do to an AI answer, when changing them helps, and why a lower setting does not mean more truthful.
- AI agents explained: when a chatbot starts taking actionsWhat an AI agent is beyond the marketing: tool use, loops, memory and permissions, plus the failure modes that appear as soon as a model can act rather than answer.
- RAG or fine tuning: which one does your use case need?The difference between retrieval augmented generation and fine tuning, what each one fixes, what they cost, and how to pick the right approach for your own data.
- Open weight AI models: what open really means hereOpen weights versus open source versus closed models, what the licenses permit, and the practical trade offs if you run a downloadable model yourself.