The Mathematics Inside a Chatbot
A language model does one thing: given some text, it gives a probability for every possible next word. Everything else it appears to do comes from doing this very well, billions of times. The mathematics underneath is vectors, matrices, probability and derivatives.
Words become vectors
A computer cannot multiply words. So each word, or piece of a word, is replaced by a list of numbers, a vector with hundreds or thousands of components. Words used in similar ways get vectors that point in similar directions. The closeness of two vectors is measured by the dot product, , which you know from vector algebra.
Layers of matrices
The vectors pass through many layers. In each layer a vector is multiplied by a matrix and a simple curve is applied to the result. A matrix times a vector is exactly the operation of your matrices chapter, repeated at enormous scale.
The design used since 2017 is called the transformer. Its key step is attention: for each word, the model computes dot products with all the other words in the text to decide which of them matter for it. In the sentence about a bank, attention to the word river or the word money settles which bank is meant.
At the end the model produces one number for every word in its vocabulary. These are turned into probabilities that add up to 1, and one word is picked.
Learning is finding a minimum
At the start all the numbers in the matrices are random and the output is nonsense. The model is shown real text and asked to predict each next word. Its error is measured by a single number, the loss. Training means changing the billions of numbers to make the loss small.
This is the minimum problem of your application of derivatives chapter, with billions of variables in place of one. The derivative of the loss with respect to each number tells which way to change it. Each number is moved a small step downhill, , and this is repeated a very large number of times. The method is called gradient descent.
What these systems have done
The same kind of network, trained on protein data, predicted the shapes of about 200 million proteins, work that shared the Nobel Prize in Chemistry in 2024. In 2024 an AI system solved four of the six problems at the International Mathematical Olympiad, the level of a silver medal. In 2025 AI systems reached 35 points of 42, the level of a gold medal.
What is still open
A language model gives the likely next word, not a checked fact. It can state false things fluently, and it cannot say how it reached an answer. Why such large networks work as well as they do is not understood mathematically. Their use of electricity and their effect on work and learning are open questions for society.
Quick answers
How does ChatGPT work in simple terms?
It is a language model. Given the text so far, it computes a probability for each possible next word, picks one, and repeats.
How does AI work step by step?
Data is turned into numbers. A network of adjustable numbers makes a prediction. The error is measured. The numbers are changed slightly to reduce the error. This is repeated on a very large amount of data.
Does AI use water?
The data centres that run large models use electricity, and many use water for cooling. How much depends on the centre.
Where this meets your syllabus
The ideas on this page start in chapters you study for JEE and NEET. Each link opens the chapter with its previous year questions.
Sources
Facts and figures are taken from the laboratories and the published results:
- Vaswani and others, 2017: attention is all you need
- Jumper and others, Nature 2021: highly accurate protein structure prediction with AlphaFold
- Nobel Prize in Physics 2024: neural networks
The explanation and the figures are made for students by MolSynapse. If you find an error, report it.