Skip to content

Schemas

A schema is any Pydantic BaseModel. nirmala.field() is a drop-in for pydantic.Field that adds extraction options:

Option Effect
description What to extract; becomes the field's line in the prompt
verbatim=True Snap the answer to the exact printed span (case and spacing kept)
prefixes=[...] Keep a printed prefix when snapping (honorifics such as MR., DR.)
choices=[...] Snap to one allowed value, or None with a note
hint=r"regex" Pull a later page into the prompt when the first pages lack it
critical=True Must be present and confidently verified to auto-approve
normalize=fn Field-specific fn(value, ctx) or fn(value)
instructions= Extra per-field rules for the model

Types drive normalization: Decimal, float and int fields go through parse_number ("₹ 1,23,456.00" becomes 123456.00, (1,200) becomes -1200), date fields through parse_date (ISO, 14/03/2026, 14-Mar-2026, March 14, 2026...). Nested models and lists work; their JSON Schema is included in the prompt.

The first line of the model's docstring describes the target document. extract_best uses it to pick the right file out of several.

Invalid values for optional fields are dropped to None (recorded in notes and validation_errors) rather than failing the whole record. An invalid required field makes result.data None.