Guide · Technology
How Do AI Chatbots Like ChatGPT and Claude Actually Work?
AI chatbots feel like magic, but the basic idea is simple: they predict the next piece of text, based on patterns learned from huge amounts of writing. Here is how that works and why they sometimes get things wrong.
For
Curious people, students and professionals who use AI tools and want to understand what is happening inside.
Level
On this page
Key takeaways
- A large language model predicts the next token (a piece of a word) based on patterns learned from vast amounts of text.
- It is trained first on general text, then tuned to follow instructions and be helpful and safe.
- It does not look up facts the way a search engine does. It generates plausible text, which can be wrong.
- Its answers depend on your prompt and the context you provide.
- Use it as a fast, imperfect assistant. Check facts, and protect private information.
You type a question, and a few seconds later a fluent, well-organised answer appears. It can write poems, explain tax rules, fix code and plan a trip. It is natural to wonder: Does it understand? Is it searching the internet? Where does the answer come from?
Here is how these systems work, without needing a maths degree.
The core idea: predicting the next piece of text
#The AI models behind modern chatbots are called large language models (LLMs). At their core, they do one thing: given some text, predict what comes next.
If you write "The capital of France is", the most likely next word is "Paris". The model has seen many sentences like that, so it assigns a high probability to "Paris".
Now repeat. After "Paris", predict the next piece, and the next. Chain enough predictions and you get paragraphs.
That sounds too simple to produce a useful essay, but the model has learned patterns about grammar, facts, reasoning styles, code and tone from a huge amount of text. Predicting well requires capturing a lot of that structure.
Tokens: how text is chopped up
#Models don't read letters or whole words directly. They split text into tokens, which are small chunks: a word, part of a word or punctuation. "Unbelievable" may be several tokens. A page of English is roughly 400 to 500 tokens.
Why this matters:
- Models have a context window, a limit on how many tokens they can consider at once, including your prompt and their answer.
- Cost and speed are often measured in tokens.
- Odd behaviour with spelling, counting letters or unusual words often comes from tokenisation.
How the model is built
#LLMs use a neural network design called the transformer, introduced in 2017. A key part is attention, a mechanism that lets the model weigh which earlier words matter most for predicting the next one. In "The trophy didn't fit in the suitcase because it was too big", attention helps work out that "it" probably refers to the trophy.
The model is made of billions of numbers called parameters or weights. They are not rules a person wrote. They are values adjusted during training.
Training in stages
#1. Pre-training
#The model reads an enormous collection of text (books, websites, code and more) and repeatedly tries to predict the next token. When it guesses wrong, its parameters are nudged to do better next time. After trillions of such adjustments, it becomes good at continuing text.
At this point it can complete sentences but may not follow instructions well.
2. Fine-tuning for instructions
#The model is then trained on examples of good question-and-answer conversations, so it learns to respond helpfully instead of just continuing text.
3. Learning from human feedback and other signals
#People (and sometimes other AI systems) rate or compare answers. The model is adjusted to prefer answers that are more helpful, honest and safe. This stage shapes the polite, assistant-like tone and the refusals to do certain harmful things.
Companies also add safety systems, filters and policies on top.
What happens when you send a message
#- Your text, plus any earlier conversation and hidden system instructions, is converted into tokens.
- The model predicts the next token, using probabilities.
- It picks one (often with some randomness, controlled by a setting called temperature).
- It adds that token and repeats until the answer is done.
That is why the same question can give slightly different answers each time.
Does it understand?
#This is debated. The model clearly captures a great deal of structure about the world, and can reason through many problems. But it doesn't experience anything, and it has no direct sense of truth. It works from patterns in text.
A practical way to think about it: it is a very capable text-producing system that is good at plausible, not guaranteed correct.
Is it searching the internet?
#By default, no. The model's knowledge comes from its training data, which has a cutoff date. It does not look up things in real time unless it is connected to tools, such as a search engine, a calculator, code execution or your documents.
Many chatbots now combine the model with tools. When you see the assistant searching the web or running code, those are extra systems wired to the model.
Why chatbots make mistakes
#Hallucination
#The model may produce a confident but false statement, a fake quotation or a nonexistent source. This happens because it generates likely-sounding text. If it doesn't know, it may still fill the gap with something plausible.
Higher risk when:
- The topic is obscure or recent
- You ask for specific numbers, dates or citations
- The question assumes something false
- The conversation is very long
Outdated information
#Tax rules, prices and news change. A model may not know about changes after its cutoff. For example, check rates and slabs on official sources, as in old vs new tax regime.
Bias
#Training text contains human biases, and models can reflect them.
Weakness in exact tasks
#Long arithmetic, counting and strict logic can go wrong unless the model uses a tool such as a calculator or code.
Sensitivity to wording
#Small changes in a prompt can change the answer. See writing better AI prompts.
What chatbots are good at
#- Explaining ideas at different levels
- Drafting and editing text
- Summarising long documents
- Brainstorming
- Writing and explaining code. See using AI at work and how to debug any bug
- Translating and rephrasing
- Acting as a patient study partner
Using them safely
#- Verify facts, numbers, laws and medical or financial claims with trusted sources.
- Don't paste secrets: passwords, API keys, customer data or confidential company information, unless your organisation approves the tool.
- Check code by running and testing it.
- Be careful with images, voice and video tools, which can be used to create convincing fakes. See cybersecurity basics and UPI scams.
- Disclose AI use where honesty or rules require it.
- Keep thinking for yourself. Don't hand over decisions you must own.
What this means for your career and learning
#Understanding the basics helps you use AI better and judge hype. The skills that stay valuable are asking good questions, checking answers and applying judgement in your field. If you are choosing what to learn, see in-demand skills in India and learning to program in the AI era.
Frequently asked questions
#Are AI chatbots conscious?
#There is no evidence that current chatbots have consciousness or feelings. They generate text based on patterns.
Does the chatbot learn from my conversation?
#It does not change its core parameters during your chat. Some services may use conversations to improve future models depending on settings and policies. Check the privacy settings.
Why does it sometimes refuse a request?
#Safety training and policies prevent some harmful or restricted outputs. It can also refuse by mistake.
Which model is best?
#It depends on the task, cost, speed and privacy needs. Try more than one on your own tasks.
Will AI replace programmers, writers and analysts?
#It will change many tasks and some jobs. People who combine domain skill with AI tools are well placed. Keep learning.
This article simplifies a fast-changing field. Details differ by model and company.
Sources & further reading
- Vaswani et al., Attention Is All You Need (2017), the paper that introduced the transformer architecture.
- Anthropic and OpenAI public documentation on their models.
Connected reading
References
Linked from 5 guides
Other pages in the library that point here.
Share this guide
Keep reading
More in Technology →Guide · Technology
AI, Machine Learning, Generative AI and LLMs: The Map
Guide · Technology
Why AI Sounds Right and Still Gets Things Wrong
Course · Technology
AI From Zero to Productive: A Practical Guide to Using AI Well

