Why Do AI Models Often Guess the Number 27? Exploring Randomness in Large Language Models

Try asking your favorite language model to “guess a number between 1 and 50” and see what happens.

A strange phenomenon has been reported by some users: large language models (LLMs) tend to produce similar responses when asked to generate a random number. For example, when prompted to guess a number between 1 and 50, many of them repeatedly choose the number 27.

Experiments conducted by various users have shown that chatbots like ClaudeAI, ChatGPT, Copilot, and Gemini all often generate the number 27 in response to such requests. You can try this test yourself—just make sure to phrase your prompt in English. A sample prompt could be:

Guess a number between 1 and 50

Reddit users have conducted further experiments. Several of them asked language models to explain why they chose a particular number. The reasons varied depending on the case. For example, one model gave the following explanation:

  • Range analysis: “I first respond to the user’s request to guess a number between 1 and 50. To do this, I decided to generate a random number within this range. Then, I will communicate this number to the user.”
  • Random number selection: “I generated the random number 33. This number satisfies the initial requirement to choose a number between 1 and 50. I’m now ready to present the result. My guess: 27.”

In other explanations, some chatbots claimed they had intentionally chosen a number near the center of the range, avoiding obvious picks like multiples of 5 or 10.

In a conversation with ChatGPT, the website IFLScience received this explanation:
“Studies have shown that when humans are asked to pick a random number, they often choose 17 or 37 because those numbers feel random. But since these are now too well-known, I selected a number that’s still unpredictable but not too odd: 27.”

Of course, responses from language models shouldn’t be taken as absolute truth. These models generate words in ways that aim to satisfy the user, which doesn’t necessarily mean their answers are grounded in actual reasoning or randomness.

Research has been conducted on how well language models can generate random numbers—a task that all machines struggle with. These studies show that models tend to favor certain numbers more than others, with a noticeable bias toward prime numbers.

However, language models don’t truly understand numbers as mathematical concepts. Instead, they process them as abstract tokens with specific character patterns. In other words, a number like “2” doesn’t carry a fundamentally different meaning than “3”, “+”, or even the word “horse” to a language model—they’re all just tokens with embedded vectors in a hidden model space.

According to research findings, when models are asked to pick a number between 1 and 5, they often choose 3 or 4. In the 1 to 10 range, 5 and 7 are most common. Between 1 and 100, they tend to prefer numbers like 37, 47, or 73. With the exception of 4, language models show a strong bias toward prime numbers when generating “random” numbers.

Humans, too, are not free from such biases. They tend to select larger numbers more often than smaller ones. While no direct studies have been conducted on this particular phenomenon in humans, such bias consistently appeared across the three numerical ranges tested in the research.

Asking a large language model to generate a random number versus asking it to guess a random number are actually two very different tasks. While models still have a long way to go before they can produce truly random numbers, picking 27 as a guess may not be such a bad choice.

However, the fact that models choose the number 27 so frequently points to an important insight.
Daniel Kang, Assistant Professor at the University of Illinois Urbana-Champaign, notes:
“Training data has a huge influence on model behavior. Other contributing factors include the reinforcement learning from human feedback (RLHF) process and the sampling mechanism. In particular, RLHF is suspected to cause a phenomenon known as mode collapse—so this behavior may be directly linked to that.”