AI Hallucination: Why AI Makes Things Up and How to Reduce It
What is an AI hallucination? Learn why language models invent facts, how to spot it, and practical ways to reduce hallucinations in chats and AI agents.
What are embeddings? A plain guide to how AI turns words into numbers that capture meaning, and how embeddings power semantic search, RAG and AI agents.
Embeddings are lists of numbers that represent the meaning of a piece of text, so that texts with similar meanings get similar numbers. They let a computer measure how close two ideas are, even when they share no words. Embeddings are what power semantic search, document retrieval for chatbots, recommendations, and much of how AI tools find the right information.
This guide explains embeddings without math: what they are, how they capture meaning, and where you meet them in everyday AI tools and agents.
An embedding is a vector, which simply means a long, ordered list of numbers. An embedding model reads a word, sentence, paragraph, or document and outputs one of these vectors.
The important part is how the numbers are arranged. The model is trained so that:
So an embedding is like a coordinate for meaning. Every piece of text gets a location, and nearby locations mean related ideas.
The easiest way to picture embeddings is a map.
Imagine placing every word on a big map, where similar words sit near each other. “Cat,” “kitten,” and “dog” cluster in one neighborhood. “Car,” “truck,” and “bus” sit in another. “Happy” and “joyful” are neighbors, while “sad” is a short trip away in a related emotional area.
Real embeddings use hundreds or thousands of dimensions instead of two, which lets them capture many kinds of similarity at once: topic, tone, language, formality, and more. Nobody chooses what each dimension means. The model learns a useful arrangement during training, and individual numbers usually do not map to a single human-readable concept.
Treat the map as an analogy. It explains the idea well, even though the real space is far too large to draw.
Embedding models learn from huge amounts of text. A common approach trains the model to place pairs of related texts, like a question and its answer, close together, and unrelated texts further apart. Over many examples, the model learns which texts tend to mean similar things.
The result is that embeddings reflect meaning more than spelling:
| Text A | Text B | Shared words | Similar meaning? |
|---|---|---|---|
| “The movie was fantastic” | “I loved the film” | None | Yes, close together |
| “Apple released a new phone” | “I ate an apple” | “apple” | No, further apart |
| “Cancel my subscription” | “How do I stop being billed?” | None | Yes, close together |
This is the big advantage over keyword search, which only matches exact words.
To compare two embeddings, systems compute a similarity score. A popular choice is cosine similarity, which roughly checks whether two vectors point in the same direction. A high score means similar meaning. You do not need the formula. Just know that “closer” is something a computer can measure quickly, even across millions of texts.
Embeddings and large language models are related but different tools.
Inside an LLM, tokens are also turned into internal vectors as a first step, which is part of how it builds an understanding of context. You can read more about that in how LLMs work. Dedicated embedding models are usually smaller, faster, and cheaper, and they are designed specifically to produce vectors that are good for comparison.
Once text has a location in meaning space, a lot of useful things become possible.
Instead of matching keywords, you embed the search query and find the documents whose embeddings are closest. Searching “laptop won’t turn on” can surface an article titled “Troubleshooting power issues,” even with no words in common.
Retrieval-augmented generation, or RAG, is one of the most common uses. The process looks like this:
This gives the model relevant facts to work from, which helps reduce AI hallucinations and lets it use information it was never trained on.
AI agents often need to find the right information before they act. Embeddings are one way to do that. An agent might use semantic search to find the most relevant documentation, past notes, or files for the current step, rather than loading everything into its limited context.
Not every agent relies on embeddings. Coding agents, for example, often search a project with ordinary text search tools and by reading files directly, which works well for code. But embeddings remain a common building block for agents that work over large document collections or long-term memory. Many of these retrieval tools are connected to agents through standards like the Model Context Protocol (MCP).
Embeddings are powerful, but they have blind spots:
Good retrieval systems often combine embeddings with keyword search and a final check by the LLM.
Embeddings are numbers that describe the meaning of text. An embedding model turns a word, sentence, or document into a list of numbers so that texts with similar meanings end up close together, which lets computers compare ideas instead of exact words.
Tokens are the small chunks of text a model reads, like pieces of words. Embeddings are vectors that represent meaning, either for individual tokens inside a model or for whole sentences and documents produced by an embedding model.
RAG needs to find the parts of your documents that relate to a question. Embeddings make that possible by matching the meaning of the question with the meaning of each document chunk, so the most relevant text can be passed to the LLM.
Not always. For a small number of documents, you can store embeddings in memory or a simple file and compare them directly. A vector database becomes useful when you have many documents and need fast, scalable similarity search.
What is an AI hallucination? Learn why language models invent facts, how to spot it, and practical ways to reduce hallucinations in chats and AI agents.
How do LLMs work? A plain explanation of tokens, training, attention and next-token prediction, with no math, plus what it means for using AI tools well.
Open source LLM or closed model? Learn what open-weight really means, why licenses vary, and the trade-offs in privacy, cost, quality and control.