Question 113
A system extracts structured fields from messy documents, validates every output against JSON schemas, handles edge cases gracefully, and stays accurate enough to feed downstream systems.
Read the full scenario lessonYou are building a structured data extraction system using Claude. The system extracts information from unstructured documents, validates the output using JavaScript Object Notation (JSON) schemas, and maintains high accuracy. It must handle edge cases gracefully and integrate with downstream systems.
After implementing tool use with strict schema definitions, JSON syntax errors are eliminated, but 5% of extractions still have valid JSON with empty arrays or null values for required fields like citations and methodology. Spot-checking reveals that source documents contain this information, but in varied formats – inline citations vs. bibliographies, methodology sections vs. details embedded in introductions.
What's the most effective way to address these failures?