QuestionQ100

Prompt Engineering & Structured Output

You are developing a structured data-extraction system using Claude. The system extracts information from unstructured documents, validates output with JavaScript Object Notation (JSON) schemas, and preserves high accuracy. It must gracefully handle edge cases and integrate with downstream systems.

Testing shows that when source documents lack certain specifications, the model invents plausible-sounding values to fulfill your schema’s required fields. For example, a document that mentions only dimensions is returned with a fabricated "weight: 2.3 kg" in the extraction output.

Which schema-design change most effectively addresses this hallucination behavior?

Explanation

Specifications that may be absent from a source document should be optional rather than required. This allows the extraction output to omit unavailable information instead of forcing the model to generate a plausible value solely to satisfy schema validation.

Community Discussion

No comments yet. Be the first to start the discussion!