Coderhouse goes global

🌍

Read more

What Are AI Hallucinations and Why LLMs Make Things Up

AI Engineering

Build and ship real applications with LLMs, agents and automation.

8 weeks · Live online · View course →

Data Analytics

Go from zero to job-ready analyst with SQL, Python and BI tools.

10 weeks · Live online · View course →

Dan Patiño

AI Strategy & Innovation at Coderhouse

Artificial Intelligence

What Are AI Hallucinations and Why LLMs Make Things Up

AI hallucinations are outputs from a large language model (LLM) that sound confident and fluent but are false, unsupported, or made up: a citation to a paper that does not exist, a wrong number in a summary, a product feature the vendor never shipped. The U.S. National Institute of Standards and Technology uses the more precise term confabulation, defined as “the production of confidently stated but erroneous or false content” (NIST AI 600-1: Generative AI Profile).

Why it matters now: LLMs have moved from chat windows into customer support, internal search, coding assistants, and AI agents that take actions. A wrong answer in a demo is a curiosity. A wrong answer that updates a CRM record, quotes a refund policy, or drafts a legal clause is a business risk. Understanding why models hallucinate is the first step to building systems that hallucinate less.

Why LLMs make things up

An LLM generates text by predicting the next token based on patterns learned in training. It does not look facts up by default, and it has no built-in sense of “I don’t know.” Researchers from OpenAI and Georgia Tech argue that hallucinations are a predictable statistical outcome: training and evaluation procedures tend to reward guessing over acknowledging uncertainty, so models learn to be good test-takers that answer even when unsure (Kalai et al., “Why Language Models Hallucinate”).

In practice, hallucinations get more likely when:

  • The question is about rare facts, niche topics, or events after the model’s training data ends.

  • The prompt pushes for a specific answer format (“give me five sources”) even when the model has none.

  • The relevant context is missing, buried, or truncated because the input exceeded the model’s limits.

  • The task requires exact values such as dates, prices, IDs, or quotes.

Types of hallucinations

Factual hallucinations

The model states something untrue about the world: a wrong release date, a fake statistic, an invented person.

Faithfulness hallucinations

The model contradicts or adds to the source it was given. A summary that includes a claim that is not in the document is the classic example, and it is the most important type for retrieval-augmented generation (RAG) systems.

Fabricated references and tool calls

The model invents URLs, citations, API parameters, or function names. In agent workflows this can mean calling a tool that does not exist or passing it made-up arguments.

How teams reduce hallucinations

No technique removes hallucinations completely, but several layers together cut them down a lot:

  • Grounding with retrieval (RAG): give the model the relevant documents at answer time and instruct it to answer only from them. Retrieval quality is decisive here, which is why many pipelines add a second ranking step; see our guide on reranking and two-stage retrieval.

  • Permission to abstain: tell the model explicitly that “I don’t have enough information” is an acceptable answer, and do not penalize it in your own evaluations.

  • Citations you can check: require the model to quote or reference the passage it used, then verify the reference exists in the retrieved context.

  • Structured outputs and tool use: for exact values, have the model call a database, calculator, or API instead of recalling numbers from memory.

  • Automated evaluation: measure faithfulness on a test set before and after every change. Many teams use a second model as a grader; learn how in our explainer on LLM-as-a-judge.

  • Human review where stakes are high: keep a person in the loop for medical, legal, financial, or customer-facing commitments.

Why hallucinations matter for data work

Data teams are now asked to put LLMs on top of company data: chat-with-your-dashboard tools, text-to-SQL assistants, and automated report summaries. In these settings a hallucination looks like a plausible SQL query that joins the wrong tables, or a narrative that describes a trend the chart does not show. The fix is rarely a better prompt alone. It is clean, documented data, clear metric definitions, and checks that compare the model’s claims with the query results.

FAQ

Will bigger or newer models stop hallucinating?

Newer models generally hallucinate less on common benchmarks, but they still do it, especially on rare facts and when context is missing. Design your system assuming hallucinations will happen.

Is a hallucination the same as a bias or a bug?

No. Bias is a systematic skew in outputs, and a bug is an error in your code. A hallucination is fluent but unsupported content generated by the model itself, even when the code works as intended.

How do I measure hallucination rate in my app?

Build a set of questions with known answers and source documents, run your system on it, and score each answer for correctness and for faithfulness to the provided context. Track the score over time as you change prompts, models, or retrieval.

Want to build AI applications that stay grounded in real data? Explore these Coderhouse courses:

Dan Patiño

I'm Dan Patiño, head of AI Strategy & Innovation at Coderhouse. My day-to-day work involves merging the tactical management of e-commerce (CRO, Email Marketing and SEO) with the development of disruptive solutions. I specialize in building internal AI-powered apps to automate tasks and boost innovation within the team. I firmly believe that technology is strategy's best ally. To dive deeper into my professional journey, I'll be waiting for you on my LinkedIn profile.