DevPrep

All topics › AI fundamentals for developers

Why do models "hallucinate" and how do you live with it?

Junior PRO

Essence

A hallucination is a confident, fluent and wrong answer: a method that doesn't exist, a made-up documentation link, the wrong iOS version for when an API appeared. It's not a bug in a particular model but a property of the approach. An LLM is trained to produce a plausible continuation of text, and plausibility is not the same as truth. Hallucinations can't be eliminated completely, but you can build a process in which they're caught cheaply.

The rest of this answer, with code and interview follow-ups, is in the DevPrep app.

Read the full answer in DevPrep

Practice this before your interview

DevPrep turns these answers into one-minute challenges: what does this code print, find the bug, mock interviews. One challenge a day.

Get DevPrep on the App Store