DEV Community

Manohar Papasani
Manohar Papasani

Posted on

How do we stop the model from making things up?

Asked in an AI engineer interview.

What they are really testing: whether you treat hallucination as a risk to be managed with layered controls and measured, not as a bug you can fully eliminate. They want to hear about grounding, verification and graceful refusal.

A strong answer:

  • Start by reframing: LLMs predict likely tokens, so you cannot guarantee factual correctness. Design for bounded, verifiable failure.
  • Ground answers in retrieved sources (RAG): chunk documents, embed them, run hybrid retrieval (BM25 plus dense vectors), rerank, then pass the top few passages (often 3 to 8) into the prompt with instructions to answer only from them.
  • Require citations and span-level attribution, and check that each claim maps to a retrieved passage. Return "I don't know" when retrieval confidence or evidence coverage is low.
  • Lower sampling randomness for factual tasks (temperature near 0) and constrain outputs with a schema where possible, so the model has less room to improvise.
  • Add a verification layer: an NLI or LLM-as-judge step that checks answer-to-source entailment, plus deterministic checks against tools or databases for numbers, dates and IDs.
  • Measure it: build a labeled eval set of questions with gold answers, track faithfulness and answer-relevance metrics, and monitor production samples for regressions after each prompt, model or index change.

Common mistakes:

  • Claiming that fine-tuning on more data will eliminate hallucinations. It can add new facts but does not guarantee the model stops inventing answers.
  • Relying only on a "do not make things up" system prompt with no retrieval, verification or evaluation behind it.
  • Ignoring the trade-offs: stricter refusal lowers hallucination but hurts coverage, and extra verification adds latency and cost.

What would you add to this layered approach, or where would you start if you had to ship a grounded assistant next week? Share your answer below.


Originally shared on LinkedIn.

An AI interview question every day, leadership for tech people and hands-on AI learning:

Top comments (0)