How AI Chat Works
Create free accountLog in

· 5 min read

Why does AI give different answers to the same question?

Why does AI give different answers to the same question? How sampling, temperature and top p shape a reply, and why the input is rarely quite the same.

Ask her how her day went, then ask again in exactly the same words, and the two replies may share nothing but their warmth: one short and dry, the other a long story about a missed bus. Why does AI give different answers like this? Mostly because it is built to. A language model (the program that writes her side of the chat) scores every possible next piece of text, and companion apps usually let it pick among the strong candidates by chance rather than always taking the single best one. The rest of the difference comes from inputs that only look identical.

That chance pick is called sampling, and the odds follow the scores. Nothing broke, and her mind didn't change. Sampling is one half of why AI gives different answers; the other half is that the input shifts more between one ask and the next than it seems to. Two settings decide how adventurous the draw is.

A walk home with many corners

Think about your walk home from work. At every corner there is a usual turn, a turn you take now and then, and a few you would never take, like the alley that ends at the bins behind a restaurant. On a tired evening you take the usual turns without thinking. On a mild one, in no hurry, you might go down the street with the bakery instead, and once you have, every corner after it is a different corner. You still get home. The route differs from that corner on.

Mapped onto a reply, each corner is the choice of the next piece of text, the usual turn is the top-scoring candidate, and the alley is a candidate so unlikely that it should never come up. Getting home is staying in character. The streets in between are the wording, and those can change. The loop that makes those choices, one after another, is traced in what happens after you press send.

It also explains why two replies that differ in one small word near the start end up far apart. Every later choice is scored with the earlier ones in place, so one different turn early on changes every corner after it. You can test this. Next time two versions sit side by side, find the first word where they part, and notice how seldom they meet again.

The picture breaks at the destination. A walker knows where home is, whereas a model has no destination at all, only the next corner; it stays in character because her description and the conversation make in-character streets the likely ones at every corner, and not because it is heading anywhere.

AI temperature explained without the maths

Temperature is the setting that decides how strongly the draw favours the top candidates. Turn it down and the usual turn wins nearly every time, so the walk becomes the same walk. Turn it up and the scores flatten out, unusual streets get a real chance, and past a certain point the walker starts wandering into places that make little sense. No heat is involved. Apps set this value themselves, and it is usually not something the person chatting can see.

Where top p comes in

AI temperature and top p are often mentioned together. They do different jobs. Top p trims the list before the draw (the p stands for probability): it keeps the shortlist of candidates that together account for most of the likelihood and drops the long tail of unlikely ones. In the walk, temperature is your mood that evening, and top p is the rule that you never consider the alley at all, however good your mood.

The method was proposed in a research paper first posted in April 2019. Its authors reported that always choosing the most likely continuation produces text that is dull and prone to repeating itself, and that drawing from the trimmed shortlist keeps variety without losing coherence. Always taking the top candidate sounds like the careful choice. It is the dull one.

Why does AI give different answers to the same prompt?

Because the prompt (everything the model is given to continue, not only your line) has usually changed, even when your words haven't. The conversation now contains your first try and her first answer. A summary of older messages may have been updated in between, or a different saved note fetched. Some apps add the date. Each of these is a small change. The model, though, reads the whole prompt, and a slightly different starting point gives a slightly different set of corners, which the draw then pushes further apart.

Some apps offer to write a reply again in place, and there the prompt can be truly identical. What differs then is the draw alone.

Over months, an app can also change the instructions around a character or the model underneath it. Whether and when a given app has done so is not visible from outside. It is the least checkable explanation.

Would it be better if she answered the same way every time?

Plenty of people want that. Turned all the way down, though, the draw gives you the same walk every time, and the same good-morning phrased identically each day until it stops sounding like anyone in particular. I think that is the best argument for leaving a little chance in. Varied wording is a large part of why a written character seems to be in the room.

Variation in facts is a different matter. If her birthday moves, or a sister she mentioned stops existing, the draw has wandered somewhere the conversation never pinned down. The fix is to pin it. A plain statement of the fact, made once, gives every later corner something to agree with, and why such details slip in the first place is the subject of the article on what a character keeps and loses.

Back to the second answer

So the long story about the missed bus was the same walk home with a different turn early on, taken from a prompt that may have changed a little since the first ask. That is why AI gives different answers. Two people starting from one of the app's short scenario films, which close on a line you can answer, will take the conversation down different streets from their first message. Next time you ask her something twice, find the first word where the replies part: what do you think changed at that corner?

Guides and essays

All articles