top of page

Why AI hallucinates, and how Formic Engine prevents it

3 hours ago
4 min read

Based on research by Daniel J. Escott (CEO), Souvik Kundu (Machine Learning Engineer) and Varun Ranganathan (CTO) of Formic AI


Ask most AI tools a question your documents don't answer, and they'll answer it anyway. That's how many hallucinations start: when the information they need is missing, unclear or buried in too much text, they fill the gap with something that sounds right.


Formic Engine, our enterprise AI search for regulated industries, produced zero hallucinations across 559 answers when tested on two independent legal AI benchmarks, one of the toughest tests for AI in any regulated field. The full results are in Formic AI's first benchmarking whitepaper, The Right for AI to Remain Silent. The difference comes down to architecture.


Where most AI tools go wrong


Most enterprise AI tools use retrieval-augmented generation (RAG). They split your documents into chunks of text and convert each chunk into a string of numbers that represents its general meaning. When you ask a question, the tool converts it the same way and pulls the chunks whose numbers are closest to it. This is called vector search. The tool then asks a large language model (LLM), like ChatGPT or Gemini, to write an answer based only on those chunks. That approach breaks down in four places:


  • Search loses structure.

    Splitting documents by length separates rules from their exceptions and terms from their definitions. And the search itself can't tell an official rule from a draft, or from someone's opinion about it.


  • Too much gets lost. 

    LLMs can only process so much text at once. Many now advertise context windows of hundreds of thousands of tokens (a token is roughly three-quarters of a word), but 2026 research testing current models, including GPT-5.2, found that accuracy drops sharply as the amount of text grows, even when the task stays the same.


  • Gaps get filled.

    Every answer an LLM writes blends the retrieved text with patterns the model learned from the huge amount of data it was trained on, known as its "weights," which users can't see. If your documents don't fully answer the question, the LLM doesn't flag it. It guesses at the missing pieces. The answer sounds plausible, but there's no way to tell which parts came from your documents and which were guessed.


  • LLMs run on probability, not truth.

    They're designed to predict the most likely next word, so a sentence can sound correct and still say something the source doesn't.


The researchers behind CanLegalRAGBench, one of the benchmarks Formic Engine was tested on, found that 8% to 29% of the claims in AI-generated answers weren't backed by the AI's own search results.


Prompting an LLM not to hallucinate doesn't fix this, because it can't tell when it's guessing. An instruction can't change how the model works underneath. The problem is built into the architecture, so the fix has to be too.


How is Formic Engine different?


Formic Engine sits between your documents and the LLM, and takes over the work of finding, organizing and checking information. The LLM isn't allowed to add facts from its training data. Its only job is to turn what it's given into a clear, readable answer, so it works like a language calculator: the same facts in, the same answer out. Formic Engine gets there in four steps:


  • It keeps your documents' structure intact.  Instead of slicing documents into chunks, Formic Engine maps them into a hierarchy, from files and pages down to individual sentences and clauses. When it ingests your files, it creates its own consistent metadata, so your files don't need to be perfectly labelled or organized for it to find what's in them. Definitions and cross-references stay attached to the clauses they govern, so when a passage is retrieved, its definitions and exceptions come with it.

  • It sends only what's relevant, in manageable pieces.  Rather than handing the LLM everything at once, Formic Engine first works out which parts of your documents are relevant to the question. Its search runs on a thesaurus graph, a map of terms and how they relate to each other, so it finds the right information even when your question and your documents use different words. It then passes only that information to the LLM, in order of relevance, across multiple runs of up to 32,000 tokens each, and combines the results into one answer. The LLM never has to sift through more than it can reliably handle.

  • It checks the evidence before answering.  Before the LLM writes anything, a component called the Predicate Gate tests whether the information it found actually answers every part of the question. If it doesn't, Formic Engine doesn't guess. It responds, word for word: "The provided context does not contain any information related to the query." We'll look further into why that matters in an upcoming article.

  • It ties every claim to its source.  In many AI tools, the LLM writes citations by predicting text, which is how sources get invented or attached to claims they don't support. Formic Engine starts from the source instead. Because it has already mapped your documents down to the sentence, every fact it hands the LLM is already linked to the exact sentence it came from, and that link becomes the citation. Before you see an answer, any claim that can't be traced back to your documents is removed.


What this means for your team


In regulated work, an AI answer is only useful if you can stand behind it. With Formic Engine, every claim comes with a record of exactly where it came from, down to the sentence. So when an auditor, a regulator or a client asks you to back up an answer, the proof is already there.


See how Formic Engine performs on your own documents.


 
 
 

Comments


bottom of page