Why a text answer is not enough
A procurement assistant extracting an order identifier, amount and delivery date needs a stable contract. Structured output defines field names and types so downstream software can consume the response. Google Cloud documents schema-guided generation, with support and limitations that depend on the service. Verify supported constraints rather than assuming every JSON Schema rule is enforced.
An editorial implementation example
For a purchase letter, begin with an order ID, amount, currency, delivery date and evidence location. Allow an explicit unknown state. Requiring a value without sufficient evidence can encourage plausible guesses. Keep currency separate from amount, preserve the original date representation, and perform calendar conversion with validated application code. Store the schema version so consumers can handle changes deliberately.
Validate meaning after validating structure
A valid number may still come from the wrong row. Check domain rules, reference identifiers and source locations after parsing. Return specific validation errors and limit retries. Sensitive fields should remain a reviewable draft until an authorized person approves the action. Schema compliance does not grant permission to write a record.
For more on this topic, read Validating AI output with Pydantic: JSON is not enough in the Liyan knowledge base.
Test missing and ambiguous information
Build a small reference set containing ordinary letters, poor scans, multiple currencies and ambiguous dates. Have a domain expert label expected fields. Track schema validity, field accuracy and review rate separately. Include documents without order identifiers: choosing a phone number instead is a failure even when the output parses successfully.
Walk a purchase letter through the whole workflow
For a synthetic purchase letter, place an order number, a quotation number and a telephone number together. Label the expected fields before running extraction. Separate document intake, structured extraction, business validation and draft review. Show the selected value beside its source passage so reviewers can resolve the actual ambiguity. Record corrections with a reason: a reading error, wrong-row selection and a unit-conversion error require different fixes.
Distinguish missing, zero and conflicting values
An absent shipping charge must not silently become zero. Define field states such as extracted, absent and conflicting, and decide which states block submission. If a table and the accompanying letter disagree, preserve both evidence locations for review. Establish currency and calendar conversions in application rules. Make the data contract explicit across consumers so the same numeric amount cannot be interpreted in different units.
Route failures and measure the review work
Send malformed output to parsing or generation repair, unreadable text to document review and unknown reference IDs to the responsible business team. Bound repeated attempts. Keep document IDs, schema and prompt versions, and validation outcomes without copying sensitive documents into general logs. Test schema migrations against saved fixtures. For acceptance, measure time through final approval and corrections per form, including missing-value cases. Deliver a versioned schema, labeled examples, validation rules and a usable review screen; a well-formed response alone is insufficient.
A review-ready delivery checklist
Before building the integration, agree which fields are mandatory for submission and which can remain incomplete. For a synthetic letter containing 125 million rials and a Persian-calendar delivery date, preserve the original expressions beside normalized values. Have a domain expert approve the expected conversions. Put a conflicting amount in the accompanying table to test whether the workflow raises a review case instead of choosing a convenient value.
Test recovery separately for malformed responses, unreadable scans and identifiers missing from the procurement system. The first may need format repair, the second a better document and the third a business investigation. Repeating the same model call cannot reliably resolve all three. When a reviewer changes a value, preserve the initial extraction, accepted value and correction category under the organization's retention rules. This provides actionable feedback without requiring every operator to inspect raw technical logs.
Measure a complete batch from intake to accepted forms. Report the sample size, mandatory-field errors, missing-value behavior, review time and rework alongside parsing success. Agree consequential error criteria before the run. Include old-schema fixtures when releasing a contract change, and confirm that each consumer interprets units and empty states consistently. The deliverable is a usable, versioned extraction workflow with evidence and ownership, not just a schema or a high parsing percentage. Keep the examples synthetic until the data path and access requirements have been reviewed for the intended documents.
Frequently asked questions
Does valid JSON mean correct data?
No. Content accuracy requires evidence and domain checks in addition to structural validation.
Should extraction write directly to production?
Only through a separately authorized workflow with appropriate validation and review.
Sources
- Google CloudStructured outputOfficial documentation
Further reading in the Liyan knowledge base
- Liyan Data ParsValidating AI output with Pydantic: JSON is not enoughTo enforce output contracts, Liyan’s Pydantic example demonstrates type checks, extra-field rejection and validation errors.