Remove invented values with an evidence check
A substring check is a crude evidence test. Real systems normalise spaces, case and number formats first.
Extraction pulls fields out of text and classification picks one label from a list. Both go wrong the same way: a model asked to fill every field will invent a value. Give it an honest way out (null or unknown), and check values against the source.
Change the code and press Run (Ctrl+Enter). Predict what will happen first, then break it on purpose and read what changes. Your edits are saved and match the lesson page.
Ready for more? This phase has 6 hands-on exercises with automatic checks.
Practice questions
Write the code in the editor, run it, then open the model answer to compare.
Write normalise(s) that lowercases a string and removes spaces and dashes, and supported(value, source) that returns True when the normalised value is inside the normalised source.
Write route(label, confidence) that returns "auto" if the label is not unknown and the confidence is at least 70, and "human" otherwise.
Explain it without notes
Why does a required field in a schema encourage hallucination?
What is an evidence check, and what are its limits?
How would you design the label list for a classifier?
How do you use a confidence value responsibly?
Expected output
model that fills every field
name: Priya
company: Acme
phone: (missing)
invoice: 4471
invented and removed: phone
model told to use null
name: Priya
company: Acme
phone: (missing)
invoice: 4471
invented and removed: none