mosaddik.dev
All posts

AI hallucinations: why AI makes things up, and how to reduce it

Mosaddik Billah 4 min read

AI

A person's reflection upside down in a puddle on the ground
Photo by Randy Jacob on Unsplash
On this page
  1. Why it happens
  2. Where it matters
  3. How to reduce it
  4. Can hallucinations be removed completely?

Ask an AI model for a source and it may give you a convincing article title that doesn’t exist. Ask a website chatbot about a discount and it may invent one. These confident, wrong answers are called hallucinations. They are the main reason businesses hesitate to put AI in front of customers, and the good news is that most of them can be prevented with how the feature is built.

Why it happens#

A large language model writes by predicting a likely next piece of text, over and over. It learned from a huge amount of writing which words tend to follow which, and that gives it a remarkable amount of knowledge. But it doesn’t look facts up unless you give it a way to, and it has no built-in sense of which of its “memories” are reliable.

So when it doesn’t know something, the most likely-sounding text is often an answer anyway. A plausible return policy sounds like a return policy. A plausible citation looks like a citation.

Hallucinations are more likely when:

  • the question is about your business, which the model has never seen
  • the topic is recent, after the model’s training data ends
  • the question asks for exact details: numbers, dates, names, quotes, URLs
  • the prompt pushes for an answer and doesn’t allow “I don’t know”

Where it matters#

For brainstorming or a first draft, an occasional wrong detail is easy to catch. It matters when the answer is acted on without checking:

  • a support assistant quoting the wrong price, delivery time or refund rule
  • product descriptions with specifications that aren’t true
  • legal, medical or financial statements
  • an AI agent taking action based on a wrong assumption

How to reduce it#

1. Give it the facts#

The most effective fix. Instead of hoping the model knows your policies, put them in the prompt. For a small set of FAQs, include them all; for larger content, use RAG to find the relevant parts for each question. The model is then summarising your information rather than recalling the internet’s.

2. Allow “I don’t know”#

Say it explicitly:

Answer only from the information below.
If it doesn't contain the answer, say you don't know and offer to connect the customer with our team.

Without permission to admit not knowing, models lean towards giving an answer. More habits like this are in how to write prompts that get better AI answers.

3. Ask for sources#

Have the model say which document or article each answer came from, and show that link to the reader. It makes answers checkable, and answers that must point to a source are harder to invent.

4. Let it look things up#

For facts that change, such as stock levels, order status and prices, give the model a tool that fetches the real value from your system, instead of including a copy in the prompt that will go out of date.

5. Check important output in code#

If the model must return a price, a date or a product ID, compare it with your data before showing it. If the output must be JSON with certain fields, validate it. Code is better than prompts at rules that must never be broken.

6. Keep a person in the loop where it counts#

For anything with legal, financial or safety impact, the AI drafts and a person approves. Saving most of the time while keeping the final check is usually the best trade.

7. Test with tricky questions#

Before launch, ask what customers really ask, plus questions it shouldn’t be able to answer: products you don’t sell, policies you don’t have. The right answer to those is “I don’t know”. Once live, review real conversations regularly.

Can hallucinations be removed completely?#

Not entirely. Newer models hallucinate less, and the techniques above remove most of the risk for a focused feature like a support assistant. But any system that writes free text can occasionally be wrong, so design for it: show sources, make it easy to reach a person, and keep critical decisions checked.

If you want an AI feature that answers from your own content and stays within it, I do AI integration.

Comments