Technology & Digital Life

How AI Chatbots Like ChatGPT Actually Work

AI chatbots can write essays, answer questions and hold conversations, yet they sometimes state complete nonsense with total confidence. Here’s what’s going on inside them, explained without jargon.

Daily Life Buzz Editorial 4 min readExplainer

In this article6 sections
  1. The short answer
  2. Step 1: learning from text
  3. Step 2: paying attention to context
  4. Step 3: learning to be helpful
  5. Why chatbots sometimes make things up
  6. Using chatbots well and safely

Ask an AI chatbot to explain the monsoon to a ten-year-old, write a leave application or plan a week of vegetarian dinners, and it replies in seconds, in fluent, natural language. It can feel as if someone is thinking on the other side of the screen.

What’s really happening is both simpler and stranger. Understanding it helps you use these tools well, and know when not to trust them.

The short answer

Most chatbots today, including ChatGPT, Google’s Gemini and Anthropic’s Claude, are built on a large language model (LLM). An LLM is a computer program that has learned, from huge amounts of text, which words tend to follow which other words.

When you ask a question, the model predicts a likely next word, adds it to the answer, then predicts the next one, and so on, very quickly. A full reply is built up piece by piece from these predictions.

Step 1: learning from text

To build an LLM, engineers feed it an enormous collection of text, such as books, websites, articles and code. The model’s job during this training is to guess the next word in a passage, again and again, billions of times.

Each time it guesses wrong, its internal settings, called parameters, are adjusted slightly. Modern models have billions of these settings. Over time, they capture patterns: grammar, facts that appear often, styles of writing, and how ideas connect.

Strictly speaking, models work with tokens rather than whole words. A token might be a word, part of a word or a punctuation mark.

A full reply is built up one small prediction at a time.

Step 2: paying attention to context

A key breakthrough came in 2017, when researchers at Google described a design called the transformer. Its central idea, “attention”, lets the model weigh how much each word in a passage matters to every other word.

That’s how a chatbot can tell that in “The bank raised its interest rate”, bank means a financial institution, while in “We sat on the river bank” it doesn’t. The surrounding words change the prediction.

Step 3: learning to be helpful

A model trained only to predict text is good at continuing sentences, but not at following instructions or holding a conversation. So developers train it further:

  • With examples of good questions and answers written by people.
  • With human feedback: people compare different answers and rate which is better, and the model is adjusted to prefer the kinds of answers people rated highly. This approach is often called reinforcement learning from human feedback.

This stage is also where developers try to make models refuse harmful requests and admit uncertainty.

Why chatbots sometimes make things up

Because a chatbot is predicting likely words, it can produce a sentence that sounds right without it being true. If the pattern of a confident, detailed answer is likely, the model may produce one even when it doesn’t have the facts. This is called hallucination.

It can show up as:

  • an invented statistic, date or quote;
  • a source, book or court case that doesn’t exist;
  • a wrong calculation presented with confidence.

Some chatbots can now search the web or read documents you give them, which helps, but doesn’t remove the problem completely. That’s why it’s worth checking anything important against an original source.

Using chatbots well and safely

  • Good uses: explaining a topic in simple words, drafting emails and letters, summarising long text, brainstorming ideas, practising a language.
  • Check before you rely on it: facts, figures, laws, medical or financial information, and anything you will publish or submit.
  • Keep private things private: never type in passwords, OTPs, bank details, Aadhaar numbers or confidential work documents. Depending on the service and your settings, what you type may be stored or used to improve the model.
  • Be specific: clear instructions such as “Explain in five bullet points for a beginner” usually give better answers.

Frequently asked questions

Does a chatbot understand what it’s saying?

That’s debated. Chatbots clearly capture a great deal of how language and ideas relate, but they don’t have experiences or beliefs the way people do. What they do is better described as very sophisticated pattern prediction than human understanding.

Why does the same question give different answers?

Chatbots usually add a little randomness when choosing each next word, so answers vary. This makes replies sound more natural, but it also means you shouldn’t treat one answer as the final word.

Is it safe to use AI chatbots at work?

It depends on your employer’s rules and the service you use. Many companies restrict what can be shared with public AI tools. Check your workplace policy before pasting in any work documents.

Sources

  1. Vaswani, A., Shazeer, N., Parmar, N. et al. (2017). Attention is all you need. Advances in Neural Information Processing Systems, 30.
  2. Ouyang, L., Wu, J., Jiang, X. et al. (2022). Training language models to follow instructions with human feedback. Advances in Neural Information Processing Systems, 35.
  3. OpenAI: GPT-4 technical report (2023)

Fact-checked against the sources listed above. Spotted an error? Tell us. Read our editorial policy.