What an LLM Can and Cannot Do: One Prediction Loop, Its Strengths and Its Gaps
A large language model predicts the next token, over and over. That one loop makes it strong at drafting, summarising and classifying, and weak at fresh facts, exact maths, memory and guaranteed truth. See why with a three-line tiktoken script, and learn the fix for each gap.
What you will learn
- Explain the next-token loop that every LLM strength and weakness comes from
- List the language tasks a model does well and the four things it cannot do alone
- See with tiktoken why a model guesses when it counts letters
- Match each limitation to the engineering fix: RAG, tools, history, evals or validation
Before you start
- Basic Python
Before you build anything on top of a large language model (LLM), you need an honest line around it: where it is strong, and where it will let you down. Both sides come from one simple idea. Once you have that idea, you can decide in a minute whether a task fits a model, or needs help from your code.
Three messages, three kinds of work
A support team wants an AI to answer customer messages. Here are three that came in:
- Please reply politely to this angry email.
- What is my order balance today?
- What is 17% of 4,862?
All three look like simple questions, but they are very different kinds of work. The first is pure language. The second needs a fact the model has never seen. The third needs an exact sum.
A good picture to hold on to: the model is a brilliant intern who read the whole library last year. Fast, fluent, and sometimes confidently wrong.
The one idea behind everything
An LLM reads text, predicts the next piece, adds it, and predicts again. That's the whole loop.
A token is a chunk of text, often a word or part of a word. The model picks the piece that best fits the patterns it learned, then guesses again. Keep this loop in your head, because every strength and every weakness below comes from it.
What it does well
Every strength is a language task, working with words and patterns:
- Draft: write a polite reply to a customer email.
- Summarise: shrink a long ticket into three lines.
- Extract: pull the order number and the date out of a message.
- Classify: label a message as billing, delivery or complaint.
- Translate: turn an English answer into Spanish.
- Write code: a small function from a plain description.
That's the intern's home ground.
What it cannot do alone
The intern can't check your bank balance unless you hand over the statement. Four gaps:
- Fresh facts. A model has a training cut-off date. It knows nothing after it, like last week's news, or your order balance today.
- Exact maths. It can slip on big sums, and on counting letters.
- Memory. Each call starts blank, unless you send the earlier messages again.
- Hallucination. It can state a wrong answer in a very confident voice. This is the dangerous one, because it sounds right.
None of these is a bug. They all follow from predicting the next token.
Why it slips: it sees tokens, not letters
Here's a tiny script that shows how text is cut up before the model reads it. It uses tiktoken, which runs offline with no API key. For each text it encodes the token ids, decodes each id back into its piece, and prints them.
import tiktoken
encoder = tiktoken.get_encoding("cl100k_base")
for text in ["strawberry", "123456789", "How many r in strawberry?"]:
token_ids = encoder.encode(text)
pieces = [encoder.decode([token_id]) for token_id in token_ids]
print(f"{text!r} -> {len(token_ids)} tokens: {pieces}")
'strawberry' -> 3 tokens: ['str', 'aw', 'berry']
'123456789' -> 3 tokens: ['123', '456', '789']
'How many r in strawberry?' -> 6 tokens: ['How', ' many', ' r', ' in', ' strawberry', '?']
Look at the first line. The model never sees the letters s, t, r, a, w, b, e, r, r, y. It sees three pieces: str, aw and berry. So when you ask how many r's are in strawberry, the answer is a guess, not a count. The same goes for the number: it arrives as three chunks of three digits, not as nine digits, which is one reason big sums slip.
Notice the leading spaces too: ' many' and ' strawberry' are pieces with the space built in. For how tokens turn into a context window and a bill, see LLM Tokens, Context Windows and Cost.
The engineer's fix table
We don't replace the intern. We give the intern the right tools. Each gap has a standard fix that lives in your code:
| Limitation | Fix | What the fix does |
|---|---|---|
| Old knowledge | RAG | Fetch fresh documents and put them in the prompt |
| Exact maths | Tools | Let the model call a calculator or run code |
| No memory | Conversation history | Send the earlier messages with each call |
| Wrong answers | Evals and checks | Measure how often answers are right, and check what the model says |
| Messy output | Validation | Force a shape and reject anything else |
The model supplies the language. Your code supplies the facts, the sums, the memory and the checks. Each row has its own article: the RAG pipeline, tool use, validating output with Pydantic and evals.
A three-question checklist
Before you build on a model, ask:
- Is it a language task? Drafting, summarising, extracting and classifying are a good fit.
- Can a wrong answer be caught? By a rule, a test, or a second source.
- Who checks it? A person or a check in code, before the answer matters.
Run the three support messages through it. The angry email is a language task, and a person can read the draft before it goes out: a good fit. The order balance is a fact the model doesn't have: it needs your database, through RAG or a tool. The 17% question is exact maths: hand it to a calculator tool.
Common mistakes
- Trusting a fluent answer because it sounds sure. Confidence is part of the output style, not a sign of truth.
- Asking the model for live data (balances, stock, today's prices) with nothing in the prompt. It can only guess.
- Letting it do arithmetic or counting that matters. Use a tool.
- Expecting it to remember the last call. Send the history yourself.
- Shipping without a check. If nobody can catch a wrong answer, the task isn't ready for a model.
Quick recap
| Idea | In one line |
|---|---|
| The loop | Read text, predict the next token, add it, repeat |
| Strong at | Drafting, summarising, extracting, classifying, translating, code |
| Weak at | Fresh facts, exact maths, memory, guaranteed truth |
| Why letters slip | "strawberry" is 3 tokens: str, aw, berry |
| The fixes | RAG, tools, history, evals, validation |
Try it yourself
- Edit the list in the script with your own text (your name, a long number, a product code) and run it. Which ones split in surprising places?
- Write five tasks from your own job and mark each one: language task or not?
- For each risky task, pick a row from the fix table.
Related course on Udemy
Machine Learning Engineer: From First Model to ML Engineer
Learn machine learning in Python, then ship it: data analysis, regression, classification, tuning, deployment and MLOps.View on Udemy ↗: Machine Learning Engineer: From First Model to ML Engineer (paid course, opens in a new tab)Related posts
LLM Tokens, Context Windows and Cost: What One Question Really Costs
Follow one four-word help desk question that becomes 911 input tokens. Learn what fills the context window, why chat memory grows every turn, how max_tokens cuts a reply, and how to price a call.
Structured LLM Output with Pydantic: Describe the Shape Once, Check Every Reply
An LLM replies with a string. Pydantic turns that string into a typed object or a clear error. Validate a User, generate its JSON Schema, then follow one customer e-mail through a Ticket model where the first reply says refund, fails the check, and the retry fits.