Skip to main content
Use Pydantic models.
  • Extract only the fields you need.
  • Use Pydantic validation to keep each value valid.
  • Split a complex schema into smaller models you can reuse.
  • Use Field with a descriptive title.
  • A descriptive title improves extraction quality.
  • Test the schema on varied visual inputs.

Mapping Schemas to Task Primitives

  • Classification. Use Literal. Constrain the value to the allowed categories.
  • Captioning. Use str for a text description of the image. Include the style, the context, and a rough word count.
  • Date. Use datetime.date. Include the format, for example YYYY-MM-DD.
  • Do not name the field date. That name is reserved on a Pydantic BaseModel.
  • Use datetime.datetime when the value includes a time, for example YYYY-MM-DD HH:MM:SS.
  • Use datetime.date when the value has no time.