davidberenstein1957/dspydantic

DSPydantic: Auto-Optimize Your Prompts and Pydantic Models with DSPy

What it solves

DSPydantic eliminates the need for manual trial-and-error prompt engineering when extracting structured data from unstructured sources. It solves the problem of inconsistent accuracy and the tedious process of updating prompts every time a new use case or data format is introduced.

How it works

Built on the DSPy framework and Pydantic, the tool allows users to define a Pydantic model for their desired data structure. Users provide a small set of examples (text, images, or PDFs) and their expected outputs. DSPydantic then automatically optimizes the prompt and the field descriptions within the Pydantic model to maximize extraction accuracy based on those examples.

Who it’s for

Developers who need to extract structured data from documents, images, or PDFs using LLMs and want to move away from manual prompt tuning to a data-driven optimization process.

Highlights

  • Automatic Prompt Optimization: Uses data to find the best prompts and field descriptions, typically improving accuracy by 10-30%.
  • Pydantic Integration: Provides full type safety and native Pydantic model support.
  • Multi-modal Support: Capable of extracting data from text, images, and PDFs.
  • Production-Ready Features: Includes support for batch processing, asynchronous calls, caching, and the ability to save and load optimized prompters.
  • Confidence Scoring: Provides per-extraction confidence scores to help validate results.

Related

  • Project
  • Project
  • Project
  • Project