Language models — AI Basics
AI BasicsHow chatbots work

Language models

"I'm hungry, so I'll make a …" and you think sandwich. A chatbot does the same: it finishes sentences. One word at a time, very fast, with a huge amount of practice.

Time 20 minutesChecked on 28-10-2026Read first What is AI?
1/10

First, what do you think?

When you ask a chatbot something, where does the answer come from? Make a guess.

2/10

What is a language model?

The whole story in three sentences. Behind every chatbot is a language model. It learned from a huge amount of text which word usually comes next. When you ask something, it predicts its answer one word at a time.

Try it. "I'm hungry, so I'll make a …" You probably thought sandwich. Nobody told you. You've seen and heard sentences like it thousands of times.

A language model does exactly that. You may also see it called an LLM, a large language model. It's the predictor behind every chatbot.

  • It learned from text. Lots of it. Google calls it "a phenomenal amount". From that text it learned patterns. Which words go together. How a question is usually answered. What a recipe or a letter looks like.
  • It predicts the next word. Google describes language models as autocomplete on a huge scale. Like your phone's word suggestions, but trained on far more text.
  • It does that again and again. It predicts one word, adds it, and predicts the next. Hundreds of times, in a few seconds. That's the answer you see appear.

Strictly speaking it predicts tokens, pieces of words. That's the next lesson. For now, word is close enough.

A first small step: next time a chatbot answers, watch the text appear. You're watching it predict.

3/10

What the predictor does

The rule: for every next word, the predictor works out how likely each word is. Then it picks one.

An example. "The cat sat on the …" Maybe mat gets 40% chance, sofa 25%, chair 15%. The predictor doesn't always pick the top one. There's a bit of chance in the pick. Makers call that setting the temperature. Low: almost the same answer each time. High: more variety.

That explains three things you may have noticed.

  • The same question gives a different answer. Each word is a pick with a bit of chance. Change one early word, and the rest of the answer follows a different path.
  • It sounds fluent. Fluent sentences are exactly what it learned. Every word fits the one before.
  • It can be wrong, and still sound right. It predicts what fits, not what is true. Most of the time those are the same. Not always.
Remember

A language model finishes sentences. It predicts each next word, and a bit of chance decides which.

4/10

Try it yourself

Be the predictor. Pick the next word, then see the chances.

Everything runs in your browser. Nothing you type is sent anywhere.

Try it with a real chatbot

Use the free version of any chatbot. Don't type anything personal.

Ask a chatbot the same thing twice, in two new chats:

Prompt
Write one sentence about a cat on a rainy day.

What to expect. Two different sentences. Both fluent, both fitting.

What to look for. Where do they start to differ? Often after the first few words. From there, each answer follows its own path.

5/10

In practice

Three people are surprised by a chatbot. The predictor explains it.

Case 1Two different answers

Situation

Iris (12) asks a chatbot for a title for her talk about bees. She likes it, closes the app, and asks again later. She gets a different title.

What most people do

Think the chatbot changed its mind, or that the first answer was wrong.

Why that doesn't work

It has no mind to change. Each answer is a new string of predictions. Every pick has a bit of chance in it.

What works better

Ask for five titles at once. Pick the one you like and save it.

Why that helps

You use the variety on purpose. A predictor is a good idea machine.

Case 2The confident wrong answer

Situation

Mark (36) asks a chatbot how long his dog may be alone at home. It gives a clear, friendly answer with a clear number of hours.

What most people do

Take the number as fact.

Why that doesn't work

The predictor makes text that fits the question. A clear number fits well. Whether that number is right for his dog, it doesn't check.

What works better

Use the answer to know what to ask. Then check it with a vet or a reliable animal website.

Why that helps

The chatbot gives you the right questions fast. A source gives you the right answer.

Case 3"It understood my email"

Situation

Ans (63) pastes an angry email from a neighbour into a chatbot. It writes a calm, polite reply. Ans is amazed: "It understood exactly how I felt."

What most people do

Send it as it is.

Why that doesn't work

The predictor made a reply that fits angry emails in general. It doesn't know her neighbour, or what happened.

What works better

Use the reply as a draft. Change what doesn't fit, add what only she knows, and then send it.

Why that helps

The predictor gives a good start. Ans makes it true to the situation.

6/10

By situation

A language model writes fluent text about almost anything. That doesn't make it a source. For homework, use it to understand or to plan. Get facts from your book or a reliable website.

7/10

Myths and mistakes

ClaimTrue?Why
A chatbot looks up the answerNoIt predicts the answer word by word. Some chatbots can search the web too, but they still predict the text.
A different answer means the first was wrongNoEach answer is a new set of predictions. Both can be fine, or both can be wrong.
Fluent means correctNoIt predicts what fits, not what's true.
It plans the whole answer firstNot how it worksIt predicts one word at a time, each time adding the last word to what it sees.
8/10

Related topics

Read first

Next

  • Tokensthe pieces the predictor really predicts.

Related

9/10

Sources

  • explainerGoogle for Developers. LLMs: What's a large language model?.A language model predicts the next token, like a very large autocomplete. A token can be a word, part of a word or one character. Training needs a huge amount of text. Predictions often contain mistakes.
  • documentationGoogle AI for Developers. Prompt design strategies.The model picks the next token with some chance, set by the 'temperature'. Low: more the same each time. High: more varied answers. Prompt advice: give clear and specific instructions, add context, include a few examples, say what format you want. Not the result you expected? Rephrase it; a good prompt often takes a few tries.

All sources of this course →

10/10

Test

You get 5 questions about the whole page. Get 4 right, and you've mastered the topic.

About the tools in this course. Every tool is described in the same way, in alphabetical order, without a recommendation. Names, prices and features change often: the maker's own site is always right. This site was built with the help of Claude, one of the tools described here.