LLMs Explained: How AI Language Models Work
Jun 2025 · AI & TechIf you know what happens between typing a prompt and getting a response, you make better calls about when to trust what AI tells you, when to double-check it, and how to build with it. This post goes with the video above and covers tokens, context windows, RAG, hallucinations and bias.
Generative AI vs. Analytical AI
Traditional AI analyzes data, for example sorting things into groups or making predictions. Generative AI creates new content such as text, images, code, audio and video. Large language models (LLMs) are the generative AI systems behind ChatGPT, Claude, Gemini and most AI writing assistants.
An LLM writes its response one token at a time, predicting what comes next from patterns it learned in huge amounts of text. It isn't fetching a stored answer the way a search engine fetches a page.
What a Token Is
LLMs turn text into tokens, which are roughly pieces of words. The word "understanding" might be three tokens. The model works on tokens as numbers, and everything (your input, its output, the rest of the conversation) is stored as numbers.
Tokens matter in practice because of limits. A model with a 128,000-token "context window" can work with that much text at once, counting your input, the conversation so far and any documents you've given it. Go past the limit and the earliest parts start dropping off, which is usually why the AI "forgot" what you told it earlier.
How RAG Works
By default, a model can only answer from its training data. If a fact isn't in that data, or changed after training ended, the model either doesn't know it or gets it wrong.
RAG (Retrieval-Augmented Generation) fixes part of that. When you ask a question, the system pulls relevant documents from an outside source (your company's internal knowledge base, a product catalog, live web data) and gives them to the model along with the question. The model then answers from those documents as well as from what it learned in training.
This is how AI tools use private data without training a new model. It's also why I find AI at companies interesting. Anyone can rent the same models, so a company's edge comes from how good and how well organized its own data is, and how well RAG can find it.
Where LLMs Get Used
These are the main ways I see LLMs used:
- Summarizing long documents and pulling the key points out of several sources.
- First drafts, editing, and rewriting for a different tone or audience.
- Writing boilerplate code, debugging, and translating code from one language to another.
- Answering questions from internal documentation, once it's connected with RAG.
- Automation, like sorting incoming items, routing tasks, and turning unstructured text into structured output.
At big companies, where I spend most of my time, the most valuable uses are usually that last one: taking messy, unstructured data (customer feedback, emails, support tickets, call transcripts) and turning it into clean, structured data that feeds reports, pipelines and decisions.
Hallucinations: What They Are and How Serious They Are
A hallucination is confident-sounding text from an LLM that's wrong. How often depends on the model and the task. Vectara's hallucination leaderboard tests how often a model adds things that aren't in a short document it's summarizing, and in October 2026 the rates ran from 1.8% to 24.2% across models. It happens because the model predicts likely next tokens and has no step where it checks a fact. Wrong predictions sound just as sure as right ones, and the model won't tell you it's unsure unless you ask it to.
So plan for it. For high-stakes work (medical, legal, financial decisions), ask for sources and check them. Use RAG to ground responses in documents rather than asking open-ended factual questions. Have a person review the output wherever it has to be right.
Data Bias: High Awareness, Low Action
Most organizations deploying AI say data bias is a concern. Far fewer have a plan for it.
Bias in AI output usually comes from bias in the training data. If the data reflects past patterns you don't want to repeat (in hiring, lending or medical diagnosis), the model learns those patterns. Fixing it takes careful choices about the data, regular audits and sometimes technical fixes.
What This Means for How You Use AI
In practice, that means a few habits:
- Treat AI output as a first draft you still need to check.
- For factual questions, ask for sources and check them.
- For high-stakes decisions, use RAG or tool-grounded AI rather than relying on training knowledge.
- Give it more context. Vague prompts get vague answers.
If you want to go further and run LLMs on your own hardware as well as using online tools, the AI Community Discord is where I've been documenting that infrastructure work.
Related reading: NotebookLM Video Overviews: Google's AI Video Explainer · AI App Builders Compared: From Prompt to Product in 2025
Tools worth your time
The tools and workflows I use, tested on my own projects.
No spam, unsubscribe anytime · Privacy
You're in. Check your inbox for a welcome note.