AI hallucinations: why AI makes things up, and how to reduce it
What AI hallucinations are, why language models produce confident errors, and the practical techniques businesses use to keep answers accurate.
A practical approach to testing AI features: building test sets, measuring accuracy and safety, using automated checks and monitoring quality after launch.
AI features need testing just like any other software, but because outputs vary, you test against a collection of realistic examples rather than single cases. Build an evaluation set of real inputs with expected outcomes, define clear quality measures, grade results with automated checks and human review, test for safety and misuse, rerun tests whenever prompts or models change, and monitor live quality.
Traditional software either works or it doesn't: the same input gives the same output. AI features are different. The same question can produce slightly different answers, and a small change to a prompt or model can improve some cases while breaking others. That's why AI needs its own testing discipline, often called evaluation, or "evals."
Before testing, agree on success criteria. Examples:
Clear criteria turn "it seems fine" into something measurable.
Collect realistic examples:
For each example, record the expected outcome or the qualities a good answer must have. Start with 50 to 100 examples and grow over time.
Exact or rule-based checks. For structured outputs: is the extracted date correct? Is the JSON valid? Did the answer include a link to the source?
Reference comparisons. Compare the output with a model answer for key facts.
Model-graded evaluation. Use a separate AI model with a clear rubric to grade answers for accuracy, relevance or tone. This scales well, but check its judgements against human grading periodically.
Human review. Essential for nuanced quality, tone and high-risk content. Use clear scoring guidelines so reviewers are consistent.
Deliberately trying to break your own system, sometimes called red-teaming, finds problems before users do.
For features that answer from your documents, check that each claim is supported by the retrieved content. Our guide to AI hallucinations explains techniques for reducing invented answers.
Rerun your evaluation set every time you change:
Compare scores with the previous version before releasing. A change that improves the average can still break important cases.
Alongside quality, track response time and cost per request. A slightly less accurate model that's much faster and cheaper may be the right choice for some tasks.
Quality can drift as user behaviour, content and models change.
Many evaluation tools and frameworks exist, from simple spreadsheets and scripts to dedicated platforms that run test sets, compare versions and track results. Start simple: a spreadsheet of examples and a script that runs them is far better than no testing.
Assign a clear owner for each AI feature: someone who maintains the evaluation set, reviews results and signs off changes. Involve subject experts from the business, such as support leads or product specialists, in defining what a good answer looks like. Quality isn't just an engineering task.
Our AI solutions team builds evaluation sets and testing pipelines for AI features. Our AI chatbot projects include pre-launch testing and monitoring dashboards, and our web app developers integrate evaluation into your release process.
Start with 50 to 100 realistic examples covering common, edge and misuse cases, and keep adding as you learn.
Yes, with clear rubrics, and it scales well. Check its grading against human reviewers regularly.
Whenever prompts, models, content or integrations change, and periodically to catch drift.
This guide is general information, not legal, tax or financial advice, and details such as prices, features and rules can change. Product and company names mentioned are trademarks of their respective owners and are used only to identify those products; UK Technology Hub is not affiliated with or endorsed by them.
Tell us about your project and get a free, fixed quote.
Get a free quoteWhat AI hallucinations are, why language models produce confident errors, and the practical techniques businesses use to keep answers accurate.
How to write prompts that get consistent, useful results from AI models, with reusable patterns, examples and the habits that separate good prompts from guesswork.
How large language models like the ones behind ChatGPT, Claude and Gemini actually work, what they're good at, where they fall short and how businesses use them.