Skip to content
aiqbenchAI & Quantum Intelligence
NewsInsightsBenchmarksSkillsAsk AILearnAbout
...Loading your session
NewsInsightsBenchmarksSkillsAsk AILearnAbout
  1. Future Jobs
  2. ›
  3. AI-Fluent Professional
  4. ›
  5. Lesson 3 of 8

How Language Models Work

Beginner¶ Read · 4 min⚑ Mission · 23 min◆ Test · 5 questions✓ Checked Nov 30, 2026

You'll be able to:

You can explain next-token prediction, tokens, sampling and the context window, and estimate whether a document fits in a model and what it costs to send.

Ask a chatbot the same question twice and you may get two different answers. Ask it to count the letter "r" in a long word and it may miscount. Talk to it for an hour and it may lose track of something you said at the start. None of these is a bug in the usual sense. All three follow from how a language model works, and once you know the mechanism you can predict them.

One job: predict the next token

A language model does one thing. Given a piece of text, it gives a probability for every possible next piece. The product picks one, adds it to the text, and asks again. A whole answer is that loop run a few hundred times.

The model learned to do this by reading an enormous amount of text and repeatedly guessing what came next. To guess well it had to pick up grammar, facts, styles and patterns of reasoning, because all of them help prediction. Nobody programmed those in.

Tokens

The pieces are called tokens. A token is a common word or a fragment of one. In English a token is about four characters, or roughly three-quarters of a word, so 100 tokens is about 75 words. Other languages and unusual words usually take more tokens for the same meaning.

The model receives token numbers, not letters. That is why counting letters, reversing a word or doing exact arithmetic on long numbers is unreliable unless the model works step by step or calls a tool such as a calculator.

Choosing a token: why answers vary

The model's output is a list of probabilities. The product then draws one token by weighted chance, which is called sampling. A setting named temperature controls how adventurous the draw is. At a low temperature the most likely token nearly always wins. At a higher one, less likely tokens get a chance.

This is why the same prompt gives different answers, and why "regenerate" is a legitimate tool when you want another idea. It also means one good answer does not prove the next will be good.

The context window

Everything the model can use while answering sits in its context window:

  • hidden instructions from the company that made the product
  • the conversation so far
  • any files you attached, and the results of any search or tool
  • the answer it is writing

The window is measured in tokens. Depending on the model it holds from tens of thousands to a million or more. The model has no other memory. When a conversation outgrows the window, the product drops or summarises the oldest part. Even inside the window, material in a very long input is used less reliably than the same material in a short one.

Worked example: will the book fit?

You want to ask questions about a 300-page report.

  1. 300 pages × about 300 words = 90,000 words.
  2. 90,000 ÷ 0.75 = 120,000 tokens.
  3. A model with a 200,000-token window can take it and still has 80,000 tokens for your questions and its answers.

Models are priced per million tokens. At an illustrative price of $3 per million input tokens, sending the report once costs 0.12 × $3 = $0.36. In a chat the whole conversation is sent again with every new message. Ten questions can therefore mean ten readings of the report, unless the provider stores it between messages at a discount.

Try it now (5 minutes)

Open a tokenizer tool and paste one sentence in English. Note the token count. Paste the same sentence translated into another language you know and compare. Then try a long invented word and watch it split into fragments.

On aiqbench

Which model is worth it? sets each model's capability against its price per token, and every model's own page shows its context size. Repeat the book calculation with a real price and a real window.

What to remember

  • A language model predicts the next token, again and again. An answer is a chain of those predictions.
  • A token is about three-quarters of an English word. The model sees tokens, not letters.
  • The next token is drawn by weighted chance, so answers vary.
  • The context window is the model's only memory. What is outside it does not exist for the model.

Curated Materials

1.4h

The deep work happens here — the lesson is your briefing.

  • 3Blue1Brown: Large Language Models explained brieflyVideo· 8 min
  • Andrej Karpathy: Intro to Large Language ModelsVideo· 60 min
  • Financial Times: Generative AI exists because of the transformerTutorial· 15 min

Live on aiqbench

This lesson's subject on the rest of the site, today.

In the news, last 30 days

  • Build a PDF Chatbot for Your Website with Gradio and Hugging Face ZeroGPUTowards Data Science · Dec 4
  • From chatbots to AI agents: Banco Guayaquil’s next chapter in bankingSiliconANGLE · Dec 4
  • When Does Fine-Tuning Overtake Prompting? An Accuracy and Cost Analysis of Small Language Models on Narrow TasksarXiv · Dec 4
More news on this subject →

Go further

  • Model leaderboardWhich model leads today, across eight publishers.
  • Ask AI about this lessonOpens Ask AI with a question about this lesson, answered from the news archive with sources.

Test your knowledge

5 questions in 100 seconds, on a page of its own. Read everything above first.

Test your knowledge →

Module Mission

20–25 min

Take a real document from your work. Estimate its tokens from the word count. Check your estimate by pasting a 300-word sample into a tokenizer, once in English and once in another language. Work out whether the whole document fits in one model's window, and what one reading costs at that model's current price.

Good looks like

  • The document's word count, your token estimate, and a measured 300-word sample, with the difference between estimate and measurement.
  • The sample measured in English and in one other language.
  • A yes or no on whether the whole document fits one named model's window, with the numbers.
  • The cost of one reading, with the price you used and where you found it.

Loading your work…

← Previous lesson2. How Models Learn, and What "95% Accurate" MeansNext lesson →4. Why Models Get Things Wrong
aiqbench
AI & Quantum Intelligence© aiqbench. All rights reserved.

Feeds:RSS·JSON Feed

LanguageEnglish·Românăbeta
NewsAI & TechQuantumInsights
ExploreBenchmarksLearn
CompanyAboutTrustLegal noticeTerms of ServicePrivacy PolicyCopyright noticesData erasureReport content

The aiqbench take, the insights, the daily digest and Ask answers are written by AI models from the sources shown, without editorial review before publication. They may contain errors — check the source. How the model is used →

  • News
  • Insights
  • Ask AI
  • Benchmarks
  • Account