Close Menu
    Trending
    • Reading Research Papers in the Age of LLMs
    • The Machine Learning “Advent Calendar” Day 6: Decision Tree Regressor
    • TDS Newsletter: How to Design Evals, Metrics, and KPIs That Work
    • How We Are Testing Our Agents in Dev
    • A new AI agent for multi-source knowledge
    • MIT researchers “speak objects into existence” using AI and robotics | MIT News
    • Differential Privacy vs. Encryption: Securing AI for Data Anonymization
    • The Step-by-Step Process of Adding a New Feature to My IOS App with Cursor
    ProfitlyAI
    • Home
    • Latest News
    • AI Technology
    • Latest AI Innovations
    • AI Tools & Technologies
    • Artificial Intelligence
    ProfitlyAI
    Home » 5 Techniques to Prevent Hallucinations in Your RAG Question Answering
    Artificial Intelligence

    5 Techniques to Prevent Hallucinations in Your RAG Question Answering

    ProfitlyAIBy ProfitlyAISeptember 23, 2025No Comments7 Mins Read
    Share Facebook Twitter Pinterest LinkedIn Tumblr Reddit Telegram Email
    Share
    Facebook Twitter LinkedIn Pinterest Email


    downside when working with LLMs. They’re an issue for 2 essential causes. The primary obvious motive is {that a} hallucination naturally causes the person to obtain an incorrect response. The second, arguably worse motive, is that hallucinations decrease the customers’ belief within the system. With out the person believing in your query answering system, it is going to be troublesome to maintain the customers in your platform.

    Desk of contents

    Why do it is advisable to decrease hallucinations?

    When shoppers consider using an LLM to unravel an issue, one of many first ideas that usually involves thoughts is hallucinations. They’ve typically heard that LLMs generally output textual content that isn’t true, or at the very least solutions you can not totally belief.

    Sadly, they’re typically right, and it is advisable to take steps to attenuate hallucinations in your query answering methods. The contents of this text will seek advice from hallucinations particularly for query answering methods, although the entire strategies might be utilized to different LLM purposes as nicely, similar to:

    • Classification
    • Data extraction
    • Automations

    All through this text, I’ll focus on real-world strategies you may apply to mitigate the affect of hallucinations, both by stopping them from taking place in any respect or by minimizing the injury a hallucination causes. This will, for instance, be injury such because the person trusting your software much less after experiencing

    Methods to stop hallucinations

    I’ll separate this part into two subsections:

    1. Methods to instantly decrease the quantity of hallucinations you expertise from the LLMs
    2. Methods to mitigate the injury of hallucinations

    I do that as a result of I believe it’s useful to get an outline of strategies you may make the most of to attenuate the affect of hallucinations. You possibly can both attempt to stop them from taking place in any respect (the primary approach), although that is close to inconceivable to attain with 100% accuracy, or you may mitigate the injury of a hallucination as soon as it occurs (approach quantity two).

    Decrease the quantity of hallucinations

    On this subsection, I’ll cowl the next strategies:

    • Verification step (LLM decide)
    • RAG enhancements
    • Optimize your system immediate

    LLM decide verification

    The primary approach I’ll cowl is using LLM as a decide to confirm your LLM responses. This system depends on the idea under:

    Verifying a response, is often an easier process than producing the response

    This quote is usually extra simply understood for math issues, the place developing with an answer is commonly relatively troublesome, however verifying that the answer is right is quite a bit less complicated. Nevertheless, this idea additionally applies to your query answering system.

    To generate a response, an LLM has to learn via a number of textual content and interpret the person’s query. The LLM then has to provide you with an acceptable response, given the context it’s been fed. Verifying the reply, nonetheless, is often simpler, contemplating the LLM verifier wants to guage whether or not the ultimate response is smart given the query and the context. You possibly can learn extra about LLM validation in my article on Large Scale LLM Output Validation.

    RAG enhancements

    There are additionally a number of enhancements you can also make to your RAG pipeline to stop hallucinations. Step primary is to fetch the proper paperwork. I recently wrote about this process, with strategies to each improve the precision and recall of the paperwork you fetch for RAG. It primarily boils all the way down to filtering away doubtlessly irrelevant paperwork (rising precision) via strategies like reranking and LLM verification. On the opposite facet, you may guarantee to incorporate related paperwork (improve recall), with strategies similar to contextual retrieval and fetching extra doc chunks.

    This picture highlights a conventional RAG pipeline, the place the person inputs their question. You embed this question and discover essentially the most semantically related paperwork via embedding similarity. These paperwork are fed into an LLM, which offers a solution to the person’s question, given the offered paperwork. Picture by the writer.

    Optimize your system immediate

    One other approach you may make the most of to decrease the quantity of hallucinations is to enhance your system immediate. Anthropic just lately wrote an article about writing instruments for AI brokers, highlighting how they use Claude Code to optimize their prompts. I like to recommend doing one thing related, the place you feed all of your prompts via an LLM, asking the LLM to enhance your immediate normally, and in addition highlighting instances the place your immediate succeeds and the place it fails.

    Moreover, it is best to embody a sentence in your immediate highlighting that the LLM ought to solely make the most of the offered data to reply the person’s query. You wish to stop the mannequin from developing with data primarily based on its pre-training, and relatively make the most of the context it’s been offered.

    immediate = f"""
    
    
    It's best to solely reply to the person query, given data offered 
    within the paperwork under.
    
    Paperwork: {paperwork}
    Consumer query: {query}
    """

    This may drastically cut back how typically the LLM responds primarily based on its pre-training, which is a standard supply of hallucinations for LLMs.

    Mitigate the injury of hallucinations

    Within the earlier subsection, I lined strategies to stop hallucinations from taking place. Nevertheless, generally the LLM will nonetheless hallucinate, and also you want measures in place to mitigate the injury when this occurs. On this subsection, I’ll cowl the next strategies, which assist decrease the affect of hallucinations:

    • Citing your sources
    • Assist the person make the most of the system successfully

    Citing your sources

    One highly effective approach is to make the LLM cite its sources when offering solutions. You possibly can, for instance, see this everytime you ask ChatGPT to reply a query, primarily based on content material on the web. ChatGPT will offer you the response, and after the response textual content, you too can see a quotation pointing to the web site from which the reply was taken.

    You are able to do the identical on your RAG system, both stay whereas answering the query or in post-processing. To do it stay, you may, for instance, give particular person IDs to every doc chunk, and ask the LLM to quote which doc chunk it used to quote the reply. If you’d like larger high quality citations, you are able to do it in post-processing, which you’ll read more about in this Anthropic Docs.

    Guiding the person

    I additionally suppose it’s price mentioning how it is best to information the person to effectively make the most of your software. You, because the creator of your RAG query answering system, know precisely its strengths and weaknesses. Possibly your system is superb at answering one kind of query, however performs worse on different query sorts.

    When that is the case (which it fairly often is), I extremely advocate you inform the person of this. The counter argument right here is that you simply don’t need the person to learn about your system’s weaknesses. Nevertheless, I might argue it’s manner higher to tell the person of those weaknesses beforehand, relatively than the person experiencing the weak point themselves, for instance, via a hallucination.

    Thus, it is best to both have an information textual content round your query answering system, or an onboarding move, which informs the person that:

    1. The mannequin works very nicely, however can often make errors
    2. What sort of questions is the mannequin good at answering, and what forms of questions are you engaged on enhancing

    Abstract

    On this article, I’ve mentioned hallucinations for LLMs. Hallucinations are a large downside, which a number of customers are conscious of. It’s best to thus have a number of particular measures in place to mitigate hallucinations. I’ve lined strategies to outright cut back hallucinations, similar to enhancing RAG doc fetching, optimizing your system immediate, and LLM validation. Moreover, I additionally mentioned how one can decrease the injury of hallucinations as soon as they occur, for instance, by offering citations to sources and guiding the person to make use of your software successfully.

    👉 Discover me on socials:

    🧑‍💻 Get in touch

    🔗 LinkedIn

    🐦 X / Twitter

    ✍️ Medium



    Source link

    Share. Facebook Twitter Pinterest LinkedIn Tumblr Email
    Previous ArticleAI models are using material from retracted scientific papers
    Next Article Replit’s CEO Says Your Company’s Org Chart Is Obsolete. Here’s What Replaces It.
    ProfitlyAI
    • Website

    Related Posts

    Artificial Intelligence

    Reading Research Papers in the Age of LLMs

    December 6, 2025
    Artificial Intelligence

    The Machine Learning “Advent Calendar” Day 6: Decision Tree Regressor

    December 6, 2025
    Artificial Intelligence

    TDS Newsletter: How to Design Evals, Metrics, and KPIs That Work

    December 6, 2025
    Add A Comment
    Leave A Reply Cancel Reply

    Top Posts

    A platform to expedite clean energy projects | MIT News

    April 7, 2025

    Top Rossum Alternatives for Document Processing in 2024

    April 5, 2025

    When Physics Meets Finance: Using AI to Solve Black-Scholes

    April 18, 2025

    The AI Hype Index: AI-designed antibiotics show promise

    August 27, 2025

    The Reinforcement Learning Handbook: A Guide to Foundational Questions

    November 6, 2025
    Categories
    • AI Technology
    • AI Tools & Technologies
    • Artificial Intelligence
    • Latest AI Innovations
    • Latest News
    Most Popular

    Claude Opus 4 Is Mind-Blowing…and Potentially Terrifying

    May 27, 2025

    Opera Neon är världens första fullständigt agent-baserde webbläsare

    May 30, 2025

    How to Make AI Write Similar to You (aka, a Human)

    April 3, 2025
    Our Picks

    Reading Research Papers in the Age of LLMs

    December 6, 2025

    The Machine Learning “Advent Calendar” Day 6: Decision Tree Regressor

    December 6, 2025

    TDS Newsletter: How to Design Evals, Metrics, and KPIs That Work

    December 6, 2025
    Categories
    • AI Technology
    • AI Tools & Technologies
    • Artificial Intelligence
    • Latest AI Innovations
    • Latest News
    • Privacy Policy
    • Disclaimer
    • Terms and Conditions
    • About us
    • Contact us
    Copyright © 2025 ProfitlyAI All Rights Reserved.

    Type above and press Enter to search. Press Esc to cancel.