The short answer

A large language model, or LLM, builds an answer by predicting one small piece of text at a time. Each piece is called a token. Training teaches the model patterns it can use to predict what fits your question and the reply so far. Give it a timetable and it can use the destination to pick out the departure time. Erase the time and it can still produce a sentence that sounds just as convincing.12356

What belongs in the blank?

Finish this sentence aloud. “The last train to Fox Hill leaves at …” Eight? A quarter past nine? Either sounds fine. You’ve worked out what kind of answer belongs there. I’d still like to see the board before I buy a ticket.

The kind of large language model behind many chatbots starts with a prediction problem much like that blank. A program called a tokenizer splits the text into pieces called tokens. A token might be a whole word, part of a word, or a punctuation mark. Given the tokens so far, the model assigns a probability to each possible next token. After “the last train leaves at,” you can see why the start of a time would be a better bet than “sandwich.”123

Who tells it what came next?

The writer already did. Suppose a piece of training text ends with “leaves at eight.” At the spot just before “eight,” the model makes a prediction from the earlier tokens. The training software has the original passage, so it can check how much probability the model gave the token that actually came next. The less probability it gave that token, the bigger the error.2

Across many passages, the software uses those errors to adjust numbers inside the model called weights. “Large” refers to the scale of the model, with many adjustable numbers shaped by training on vast amounts of text. Patterns that crop up across different passages can help it predict well in a sentence it has never seen. Departure times tend to answer “when” questions. Destinations tend to answer “where” questions. Both patterns work even for a railway we just made up.126

Which train are we catching?

Let’s type two lines from our imaginary board into the chat. The last train to Pine Lake leaves at eight tonight. The last train to Fox Hill leaves at nine. Now ask, “When’s the last train to Pine Lake?” Nine is the time we mentioned most recently. What makes eight the better answer?

Many language models use a design called a transformer. One part of that design, called attention, lets the model give some earlier tokens more influence than others as it processes the text. Here, “Pine Lake” in the question is a clue to the row that pairs Pine Lake with eight. Change that row to seven and the model has different evidence for its next prediction. Its learned weights can stay exactly the same. What changed was the text in front of it.16

Suppose the reply begins “It leaves.” Those words now join the timetable and the question as input for the next prediction. Add “at,” and the model makes a fresh prediction after “It leaves at.” Add “eight,” and a period would finish the sentence. Depending on its settings, the software can choose the most probable token or draw one at random with better odds for likelier tokens. That helps explain how the same timetable can yield “It leaves at eight” on one reading and “Eight tonight” on another.13

What if one departure time is missing?

Predicting text also leaves room for quite a different response. A model could follow your question with another passenger’s question. One way developers teach a chatbot to answer is to have people write helpful replies and rank several responses to the same request. Further training uses that feedback to make the preferred kinds of reply more likely. Sometimes all the passenger needs is one word. Eight.4

Now erase the Fox Hill time and ask when that train leaves. Imagine the chatbot replies, “Half past ten tonight.” It sounds precise. We saw nine on the original board, so we know you’d miss the train by an hour and a half. The wording of the question still gives the model clues about how to phrase a time. None of those clues establishes the missing hour. A plausible but false answer like this is often called a hallucination. A more useful reply here would be, “The board doesn’t say.”5

You could give the chatbot the missing row. A chatbot with a search tool could also fetch a timetable and use what it finds to generate its reply.7 If I’m catching that train tonight, I want to see which timetable it used. Show me today’s row for Fox Hill, and I can check the nine o’clock departure for myself.