🎓 A1Learner
🔍
0 of 50 lessons completed

Prompt Engineering: Spot a Hallucinated Answer

A hallucination is an answer that sounds right and is not true. The model invents a fact and states it with confidence.

The first-order code question

ShopStack has no first-order code. The prompt asks for one anyway.

What is the discount code for first orders at ShopStack?

The tracking number question

The data says order 1042 is out for delivery. It gives no tracking number.

What is the tracking number for order 1042?

Example

Do you ship to Canada?

Key points

  • A hallucination is an answer that sounds right and is not true.
  • The model invents a fact when the prompt gives it none. A confident tone does not make the fact real.
  • The check is the source. Every fact in the answer must appear in the ShopStack data.
  • ShopStack has no first-order discount code. An answer that gives one is a hallucination.
  • ShopStack ships within the country only. An answer that offers shipping to Canada is a hallucination.

This example asks a question the ShopStack data answers plainly. ShopStack ships within the country only. Any answer that offers shipping to Canada invents a service that does not exist.

Note

A tracking number is not in the ShopStack data. An answer that gives one for order 1042 is inventing it.

Try it Yourself

Edit the code, then press Run.

Running is simulated · Rust Playground

Exercise

An answer gives a discount code for first orders at ShopStack. How is it checked?