Techniques··4 min read

Why AI Hallucinates: How Bad Input Causes Bad Answers

How noisy, incomplete or contradictory input leads to AI hallucinations, and simple preprocessing steps that reduce them.

Garbage in, confident garbage out

When text is scrambled, truncated or missing, models fill gaps with plausible guesses. A table extracted out of order or a document cut off by the context limit invites invention.

Reduce the risk

Practical steps:

Ask for grounding

Instruct: 'Answer only from the document. If the answer is not there, say so.' Combined with clean input, this sharply reduces made-up details.

Try it free in your browser

  • PDF to Clean Text — Strips headers, footers, page numbers, and hyphenation. Outputs TXT or Markdown.
  • Context Compressor — Reduce token usage with compression strategies tuned for LLMs.
  • Token Counter — Live token, character, and context-window meter for any prompt. Uses official tiktoken encoders.

Tools mentioned

Frequently asked

Can clean input eliminate hallucinations?

No, but it reduces them significantly by making correct information easy to find.

What prompt helps?

Ask the model to answer only from the provided text and say when information is missing.

Keep reading