Lesson 4.4Lesson 22 of 30
Validation, retry and feedback loops
Implement validation, retry, and feedback loops for extraction quality
Key points
- 1Retry with error feedback: the follow-up includes the original document, the failed extraction and the specific validation errors ("
line_itemssum to 1,180.00,total_amountis 1,280.00"). Re-sending the same prompt just rolls the dice again. - 2Retries fix format and structural errors (a date not in ISO format, a value in the wrong field). They cannot fix missing information: if the value is absent from the source or lives in another document, return null, flag it for review and stop retrying.
- 3Tool use with a JSON schema eliminates syntax errors (broken JSON, wrong types). Semantic errors remain: line items that don't sum to the total, a value placed in the wrong field. Catch them with validation in code.
- 4Self-correction: extract
calculated_totalalongsidestated_total, and add aconflict_detectedboolean when the source contradicts itself. Discrepancies become visible instead of silently "fixed". - 5Feedback loop: add a
detected_patternfield to every finding, so dismissed findings can be grouped by the construct that triggered them and the noisy criteria refined.
What the exam guide checks here
Objective wording from the exam guide (English).
- 4.4.K1Retry with specific validation errors appended
- 4.4.K2Retries fail when the information is absent from the source
- 4.4.K3detected_pattern field enables analysis of dismissed findings
- 4.4.K4Semantic validation errors vs schema syntax errors
- 4.4.S1Follow-up includes original document, failed extraction, specific errors
- 4.4.S2Recognise when retry will fail (info in an external document) vs succeed (format errors)
- 4.4.S3Add detected_pattern to findings to analyse false positives
- 4.4.S4Self-correction: calculated_total vs stated_total, conflict_detected flag
Lock it in
Answer scenario questions on this topic. Every option comes with an explanation.
Practise 4.4 · 21 questions