Loading video...

Video Failed to Load

Go Home

Anyone need some good news? Pydantic validating streamed structured responses on the fly from OpenAI. (using pre-release Pydantic v2.10). There's something cooking in the Pydantic kitchen...

52,971 views • 1 year ago •via X (Twitter)

10 Comments

Samuel Colvin's profile picture
Samuel Colvin1 year ago

This is made possible by the new "allow partial" functionality added in @pydantic v2.10.

Jonas Vetterle's profile picture
Jonas Vetterle1 year ago

@pydantic @OpenAI llms and pydantic are like that chaotic friend and their super organised roommate 😂 a match made in heaven

TadasG | topyappers.com's profile picture
TadasG | topyappers.com1 year ago

@pydantic @OpenAI please please add other LLMs as well. From my personal experience @LeadsOnTrees Gemini is a lot better for parsing unstructured text into Pydantic models <3

Samuel Colvin's profile picture
Samuel Colvin1 year ago

@pydantic @OpenAI @LeadsOnTrees Gemini is already supported, although their JSON Schema support is much less sophisticated than @OpenAI.

William Bakst's profile picture
William Bakst1 year ago

@pydantic @OpenAI @jxnlco i feel like instructor and mirascope have had this functionality for quite a while now @samuel_colvin I’m curious to see what’s different here any timeline? guessing this will be the `pydantic-ai` package?

Daniel Micallef's profile picture
Daniel Micallef1 year ago

@pydantic @OpenAI Is the example open-sourced?

Samuel Colvin's profile picture
Samuel Colvin1 year ago

@pydantic @OpenAI Not yet, will be soon.

Teknium (e/λ)'s profile picture
Teknium (e/λ)1 year ago

@pydantic @OpenAI Why’s it so slow

Snehasish Barman's profile picture
Snehasish Barman1 year ago

@pydantic @OpenAI Awesome work. Now I can remove some external dependencies.

Omar MHAIMDAT's profile picture
Omar MHAIMDAT1 year ago

@pydantic @OpenAI What are you guys cooking 🧑‍🍳?

Related Videos

New Short Course: Getting Structured LLM Output! Learn how to get structured outputs from your LLM applications in this course, built in partnership with .txt, and taught by Will Kurt, a Founding Engineer, and , Developer Relations Engineer. It's challenging for software to automatically parse through an LLM's freeform text outputs. Structured outputs—like JSON—solve this by converting natural language into consistent, clear, data that a machine can read and process. This course teaches you how to generate structured outputs while building several use cases, including a social media analysis agent. You’ll learn about structured outputs and efficient ways to generate outputs in your defined schema or format. You’ll begin by using structured output APIs, then use re-prompting libraries like “instructor” to generate structured output. Finally, you’ll learn how constrained decoding works; this is a very clever technique in which constraints are applied on each subsequent token generated, blocking any tokens that don’t fit your defined schema. In detail, you’ll: - Learn why structured outputs are important, how they allow for scalable software development, and the different approaches to generate them, including vendor-provided APIs, re-prompting libraries, and structured generation. - Build a simple social media agent using OpenAI’s structured output API, learn how to define a model's desired structured output using Pydantic, and perform basic programming with your outputs, such as importing structured data into a data frame using pandas. - Learn how to use the open-source library "instructor," which checks the structured output of the model and re-prompts the model until it validates the desired output, and explore the limitations of this approach. - Understand how structured generation by the “outlines” library works by modifying LLM logits, on a per-generated-token basis based on the desired format, to give a particular output structure. - Learn how regular expressions, which outlines works with, are represented as finite-state machines, and how they can be used to develop a range of structured outputs beyond JSON. By the end of this course, you’ll have broadened your knowledge of the approaches you can use to get structured outputs from your LLM applications. Please sign up here:

Andrew Ng

89,792 views • 1 year ago