Session brief
Pydantic is all you need: Jason Liu
Overview
This talk introduces Pydantic as a powerful tool for building applications with language models, focusing on structured prompting. The core thesis is that by defining data structures with Pydantic, developers can move beyond unreliable string-based interactions with LLMs and achieve more robust, maintainable, and type-safe code. This approach enhances data validation, simplifies prompt engineering, and enables LLMs to integrate more seamlessly with existing software systems.
Who should watch
- AI Engineers
- Product Managers
- Developers building with LLMs
- Anyone struggling with unreliable structured output from language models
- Those looking to improve data validation and type safety in LLM applications
- Engineers aiming to integrate LLMs with existing APIs and schemas
Key takeaways
- Many LLM applications rely on structured output like JSON, which is often unreliable when parsed with regular expressions.
- Pydantic, a Python library for data validation powered by type hints, offers robust model and field validation, with widespread adoption.
- Pydantic models can generate JSON schema, which is compatible with tools like OpenAI's function calling for more reliable structured output.
- Libraries like Instructor and Marvin simplify the use of Pydantic for prompting language models, providing type safety and better autocomplete.
- Structured prompting allows prompts to be treated as code, enabling better review, maintainability, and integration with IDE features.
- Pydantic enables advanced validation, including LLM-driven validation and custom retry mechanisms for error correction.
- This approach facilitates the modeling of complex data structures, workflows, and even plans that can be dispatched to classical computing systems.
- Advanced applications include RAG systems with dynamic search query generation, planning complex query execution (DAGs), and extracting knowledge graphs.
Notable quotes
The idea is that we can use objects to define what we want back out rather than kind of praying to the LLM gods that the comma is in the right place and the bracket was closed.
The goal for today is effectively introduce open AI function calling, introduce Pydantic, then introduce Instructor and Marvin as a library to make you using Pydantic to prompt language models are much easier.
The idea here is just to make open AI function calling super useful.
Unofficial community note. Prefer the recording for nuance.