Pydantic is all you need: Jason Liu

Поделиться
HTML-код
  • Опубликовано: 26 сен 2024
  • Please return only json, do not add any other comments ONLY RETURN JSON OR I'LL TAKE A LIFE
    If this was you, then you've probably been pretty happy to see OpenAI function_call get released, I'm here to show you how you can get the most out of such powerful feature. Instead of writing prompts that turn strings into strings, we can write Pydantic objects and get Pydantic objects out of OpenAI.
    In this talk we explore some model driven development. Where we go step by step with some examples on how to represent your problem as simple code so we can model, generate diagrams, and write prompts as code to save time and model complex data correctly, allow us to use the same best practices rather than having to invent new ones for how we manage prompts.
    Recorded live in San Francisco at the AI Engineer Summit 2023. See the full schedule of talks at ai.engineer/su... & join us at the AI Engineer World's Fair in 2024! Get your tickets today at ai.engineer/wo...
    About Jason Liu
    Previously stitch fix and Facebook. Currently consulting startups on production using llm systems.

Комментарии • 135

  • @jxnlco
    @jxnlco 11 месяцев назад +262

    Thanks for having me on! this was my first publish speaking thing in like.. .5 years

    • @aiDotEngineer
      @aiDotEngineer  11 месяцев назад +9

      Our pleasure! You did excellent!

    • @philsheard832
      @philsheard832 10 месяцев назад +8

      Really great talk. Credible on the code but effortlessly natural in delivery. Hope to hear more from you, do you have a blog or other outputs?

    • @shanegleeson5823
      @shanegleeson5823 10 месяцев назад +1

      I'm having so much fun playing with some of your insights. I had already built some interesting tools when functions first came out and twitter was showing how pydantic was the key to making it really usable. But this is such a great progression. Thanks!

    • @jxnlco
      @jxnlco 10 месяцев назад

      @@philsheard832yeah I have a personal blog and int instructor docs.

    • @samdroid37
      @samdroid37 10 месяцев назад

      Really enjoyed this. Thanks Jason!

  • @DKLHensen
    @DKLHensen 10 месяцев назад +28

    Jason Lio is seriously next level, he brings so much in this video, can watch this 10 times.

    • @ultmusic
      @ultmusic 4 месяца назад +1

      hopefully watching it the 11th time you can spell his name properly

  • @josephmdev
    @josephmdev 11 месяцев назад +22

    I was at the conference in person -- this talk was a major highlight. Glad to see it again!

    • @jxnlco
      @jxnlco 10 месяцев назад +1

      thanks for sharing!

  • @parttimelarry
    @parttimelarry 11 месяцев назад +37

    Wow, outstanding talk. I came in thinking a 15 minute talk on typing wouldn't be that interesting, but by the end I felt like this was the most well explained and immediately useful presentation on here.

    • @ccerrato147
      @ccerrato147 11 месяцев назад

      Same here!

    • @jxnlco
      @jxnlco 11 месяцев назад

      Thanks for the kind words would love any feedback on the docs or on the talk if you have any

    • @alexemilcar6525
      @alexemilcar6525 11 месяцев назад

      @@jxnlcoawesome presentation. Where can I dive deeper into this for other models? I heavily use Pydantic today, but other models for work. You mention ask Marvin. What are the differences between that and Instructor?

  • @ilianos
    @ilianos 8 месяцев назад +5

    🎯 Key Takeaways for quick navigation:
    00:01 🎵 *Introduction and Scope*
    - Jason Liu introduces himself as a keynote speaker, providing an overview of his talk on type hints, Pydantic, and structured prompting.
    - Discusses the challenges of using language models in production, particularly when outputting JSON or structured data.
    01:19 🌐 *Introduction to Pydantic*
    - Introduces Pydantic as a library for data model validation, emphasizing its similarity to data classes and its reliance on type hints.
    - Highlights the benefits of using Pydantic, including better validation, cleaner code, and automatic generation of JSON schema.
    04:21 🧩 *Introduction to Structured Prompting with Pydantic*
    - Discusses the concept of structured prompting, where prompts are actual code represented by Pydantic objects.
    - Demonstrates how Pydantic enables defining objects with nested references, methods, and cleaner code for language model prompts.
    05:28 🔧 *Introduction to Instructor Library*
    - Introduces the "instructor" library, designed to simplify the usage of Pydantic for prompting language models, especially for OpenAI function calls.
    - Explains how "instructor" patches the completion API and facilitates type-safe and auto-complete features.
    06:24 🔄 *Advantages of Structured Prompting*
    - Explores the advantages of structured prompting, emphasizing the ability to define nested references, methods, and reusable components.
    - Discusses how this approach leads to more modular, maintainable, and bug-free code.
    07:47 🛡️ *Using Validators with Pydantic*
    - Demonstrates the use of validators with Pydantic, showcasing the ability to add custom validation functions.
    - Illustrates how language model validators can be integrated to catch and handle errors effectively.
    08:57 🌐 *Structured Prompting for Knowledge Workflows*
    - Explores how structured prompting can go beyond structured outputs, enabling the modeling of knowledge workflows and plans.
    - Discusses the potential for representing knowledge graphs and leveraging language models for more productive development.
    12:14 🔄 *Advanced Applications: Search Query Planning*
    - Demonstrates advanced applications, such as search query planning using structured prompting.
    - Shows how defining a data structure for search types and execution methods simplifies the process of querying multiple backends.
    14:34 📊 *Advanced Applications: Knowledge Graph Extraction*
    - Illustrates an advanced application focused on extracting knowledge graphs by closely modeling the data structure to the graph visualization API.
    - Emphasizes the simplicity achieved in code with the structured prompting approach.
    16:11 🔮 *Future Possibilities and Conclusion*
    - Discusses the future possibilities of structured outputs, including multimodal applications and generative UI over images, audio, and more.
    - Concludes with excitement about the evolving space of structured prompting and its potential in various domains.
    Made with HARPA AI

  • @friendlydroid42
    @friendlydroid42 10 месяцев назад +2

    I used decorators over my calls to allow for feedback loops ! Pydantic is a must 😊

  • @swannschilling474
    @swannschilling474 10 месяцев назад +5

    This is something very different from all the other stuff out there!

  • @ReflectionOcean
    @ReflectionOcean 8 месяцев назад +2

    - Consider using structured prompting for better LL model outputs (00:31)
    - Ensure LL models output JSON or structured data compatible with existing software (00:50)
    - Utilize OpenAI function calls for improved JSON schema validation (2:49)
    - Employ the Pantic library for data model validation and to generate JSON schema (3:53)
    - Implement instructor library to simplify OpenAI function calling with Pantic (5:16)
    - Use doc strings in Pantic models to improve prompt and data quality (6:47)
    - Create validators in Pantic models for data integrity and error handling (7:20)
    - Use LL models to output structured data for complex data processing (11:08)
    - Explore advanced applications of structured prompts for knowledge extraction (12:07)
    - Check out additional examples and documentation on structured prompting (16:29)

  • @anthonyd2988
    @anthonyd2988 10 месяцев назад +2

    Well this really helped me learn Pydantic🎉

  • @pythagoran
    @pythagoran 10 месяцев назад +13

    Engineers used to be expensive because they produced potentially infinite automation.
    Today, they're expensive because they consume potentially infinite automation.

    • @softdevstuff1008
      @softdevstuff1008 8 месяцев назад

      engineers are expensive because not everyone wants to deal with things that abstract and complex. I mean, engineers are close to create a machine that is smarter than them, which can make them obsolete, but still did it. which other profession is so true to it?

  • @rstar899
    @rstar899 7 месяцев назад

    Thank you Jason. Phenomenal work and effort + you & your team.

  • @shanky1897
    @shanky1897 10 месяцев назад +1

    Awesome talk jasonliu ......really learned something new today.Thank you for sharing this

  • @ristopaasivirta9770
    @ristopaasivirta9770 10 месяцев назад +3

    Respond only with a valid json and nothing else. MY AND MY FAMILY'S LIFE DEPEND UPON THIS!
    Let us hope Roko's basilisk will look kindly upon us emotionally manipulating our poor LLMs

  • @gigabytechanz9646
    @gigabytechanz9646 2 месяца назад

    Really interesting! Thx!

  • @DeruwynArchmage
    @DeruwynArchmage 10 месяцев назад

    This awesome! Thank you for sharing this!

  • @anujkhandelwal7523
    @anujkhandelwal7523 7 месяцев назад

    Incredible talk!

  • @kevon217
    @kevon217 10 месяцев назад

    Great talk. Such a useful workflow, thanks!

  • @agarbanzo360
    @agarbanzo360 10 месяцев назад

    Such a smooth talk!!

  • @jairajsahgal7101
    @jairajsahgal7101 10 месяцев назад

    Thank you

  • @sanyamjain4378
    @sanyamjain4378 10 месяцев назад +4

    Validation with citation is very interesting. I did this using normal prompt engineering and hoped I’d get good results every time 😂

  • @RajabNatshah
    @RajabNatshah 10 месяцев назад

    Thank you :)

  • @eugenio.cabral
    @eugenio.cabral 11 месяцев назад

    Great talk and content!

  • @jakobkristensen2390
    @jakobkristensen2390 10 месяцев назад

    Great talk!

  • @ATH42069
    @ATH42069 10 месяцев назад +2

    this is so good it hurts my feelings a little

  • @pz8087
    @pz8087 9 месяцев назад

    TIL that you can copy text from youtube videos. very slick... and great talk Jason :)

  • @shaunbowman8036
    @shaunbowman8036 5 месяцев назад

    lol i JUST finished our pydantic based datamodels - it’s great, nice to see this, feels like `validation` lol

  • @iumair_mehmood
    @iumair_mehmood 6 месяцев назад

    This is soo good, would love to have a link for repo for the reference

  • @tomlonghaymingway9396
    @tomlonghaymingway9396 11 месяцев назад

    Nice one!

  • @Adrian_Galilea
    @Adrian_Galilea 10 месяцев назад

    This has been growing on me.

  • @jcourson8
    @jcourson8 10 месяцев назад +5

    Makes me interested in using Rust for LLM interactions. Whether the LLM return is validated or not you’re forced to handle every case and thus will make more robust systems by design.

  • @nikilragav
    @nikilragav 10 месяцев назад +2

    How come instructor requests don't need async await for calling the APIs?

    • @jxnlco
      @jxnlco 10 месяцев назад

      cause it just uses `create` vs `acreate`

  • @egonkirchof
    @egonkirchof 6 месяцев назад +2

    70M downloads a month...how many developers exist in the world ?

  • @fkxfkx
    @fkxfkx 10 месяцев назад

    Hi: thanks for the talk. Where can we find out more about instructor? (16:33) Oops, there it is one second later.

  • @aitools24
    @aitools24 10 месяцев назад +9

    00:13 Pydantic is all you need: Jason Liu
    02:08 Pydantic is a library for data model validation.
    04:07 Pydantic is a trusted library for handling JSON schema and object definition in Python.
    06:06 Pydantic allows for cleaner code and easier maintenance by defining nested references and object behavior.
    07:54 Validation error handling in Instructor helps fix errors in language models.
    09:45 Pydantic allows for structured prompting and object-oriented programming.
    11:38 Language models can output data structures to traverse and process data more effectively.
    13:27 Pydantic enables easy creation and visualization of graph structures.
    15:27 The paraphrasing detection algorithms help identify quotes and provide more accurate answers.
    17:20 Pydantic enables extraction of bounding boxes and structured outputs.
    Crafted by Merlin AI.

    • @richcaputo2929
      @richcaputo2929 10 месяцев назад +2

      this "all you need" trend in the AI community is out of hand lol

    • @aitools24
      @aitools24 10 месяцев назад

      True haha @@richcaputo2929

  • @udaynj
    @udaynj 10 месяцев назад

    This just seems to be wrapping a prompt into a python class or function. How is this any more reliable/reliant that just straight prompts/json, since what goes to OpenAI API's is still a prompt. Not sure what I am missing here, but I don't see this being that much more useful.

  • @nartrab1
    @nartrab1 10 месяцев назад +1

    Now this is good. This is going to be the way to actually integrate llm models with apps that goes beyond chatbots more reliable

    • @jxnlco
      @jxnlco 10 месяцев назад

      thank you! let me know if you have any thoughts, available in the github issues etc or on twitter

  • @zmeta8
    @zmeta8 9 месяцев назад

    I don't want to install the whole rust toolchain to install pydantic on riscv.

  • @MichaelDoty-n2w
    @MichaelDoty-n2w 5 дней назад

    Taylor Christopher Rodriguez Charles Lewis George

  • @roseesewinter5111
    @roseesewinter5111 4 дня назад

    Rodriguez Christopher Lopez Patricia Perez Timothy

  • @samuelschmidt6150
    @samuelschmidt6150 10 месяцев назад

    How is this different from langchain?

  • @jason13gaming
    @jason13gaming 10 месяцев назад

    jason here

  • @OliveHughes-v3o
    @OliveHughes-v3o 15 дней назад

    Hernandez Kimberly Garcia Gary Rodriguez Scott

  • @jesuslovesyoujohn314-21
    @jesuslovesyoujohn314-21 6 месяцев назад

    John 3:16 For God so loved the world, that he gave his only begotten Son, that whosoever believeth in him should not perish, but have everlasting life.
    Isaiah 53:6 All we like sheep have gone astray; we have turned every one to his own way; and the LORD hath laid on him the iniquity of us all.
    Romans 4:5 But to him that worketh not, but believeth on him that justifieth the ungodly, his faith is counted for righteousness.
    1 Corinthians 15:3 For I delivered unto you first of all that which I also received, how that Christ died for our sins according to the scriptures;
    1 Corinthians 15:4 And that he was buried, and that he rose again the third day according to the scriptures:
    Ephesians 1:12 That we should be to the praise of his glory, who first trusted in Christ.
    Ephesians 1:13 In whom ye also trusted, after that ye heard the word of truth, the gospel of your salvation: in whom also after that ye believed, ye were sealed with that holy Spirit of promise,
    Ephesians 1:14 Which is the earnest of our inheritance until the redemption of the purchased possession, unto the praise of his glory.
    Ephesians 4:30 And grieve not the holy Spirit of God, whereby ye are sealed unto the day of redemption.

  • @bartech101
    @bartech101 10 месяцев назад +2

    -- "AI will take software engineer job"
    -- Software engineer: "Hold my beer."

  • @BealleMoriniE
    @BealleMoriniE Месяц назад

    Lopez Mark Jones Angela Rodriguez Jason

  • @alivecoding4995
    @alivecoding4995 10 месяцев назад

    Who is the speaker, where is he on Twitter?

    • @jxnlco
      @jxnlco 10 месяцев назад

      jxnlco !

  • @MichaelDoty-n2w
    @MichaelDoty-n2w 13 дней назад

    Garcia William Gonzalez Christopher Martinez Ronald

  • @alivecoding4995
    @alivecoding4995 10 месяцев назад

    I don't get it. What's new about this? Has been part of langchain for a while now.

    • @jxnlco
      @jxnlco 10 месяцев назад +5

      well who do you think introduced this to langchain ;)

    • @alivecoding4995
      @alivecoding4995 10 месяцев назад

      @@jxnlco I see & apologize 😀 This has been fantastic. Loved the idea straightaway.
      Are you on Twitter?

    • @jxnlco
      @jxnlco 10 месяцев назад

      @@alivecoding4995 @jxnlco
      haha yeah i was the reviewer on the langchain function calling PRS when it came out. but we do validation differently.

  • @Nurof3n_
    @Nurof3n_ 10 месяцев назад

    I still don't understand how instructor works behind the scenes, for example if I want chapters from a youtube transcript how do I prompt it?

    • @jxnlco
      @jxnlco 10 месяцев назад

      you might ask for a chapter with a title and body, and then ask for a list
      class Chapter:
      timestamp: int
      title: str
      summary: str
      class VideoChapters:
      chapters: List[Chapter]
      response_model=VideoChapters
      something. like this! i actually build youtubechapters dot app so there ya go

  • @_guru
    @_guru 10 месяцев назад

    so basically typescript....... ?

    • @jxnlco
      @jxnlco 10 месяцев назад +2

      Models have behavior. Type hints do not.
      Base model has runtime type information. Typescript does not. You would need zod. Which lacks coloration of behavior.

  • @daviseaustin5648
    @daviseaustin5648 10 дней назад

    Taylor Melissa White Kenneth Clark Daniel

  • @DinaDurbin-e2v
    @DinaDurbin-e2v 13 дней назад

    Rodriguez Sandra Martin Karen Gonzalez Lisa

  • @DjdyehxXjehrf
    @DjdyehxXjehrf 6 дней назад

    Lewis Patricia Johnson Scott Taylor Frank

  • @monicawalkman8563
    @monicawalkman8563 14 дней назад

    Robinson Maria Jackson Anthony Hall Joseph

  • @WatomaSjdob-b6o
    @WatomaSjdob-b6o 12 дней назад

    Perez Eric Martin Jose Gonzalez Betty

  • @ЕфросинияКуклева
    @ЕфросинияКуклева 12 дней назад

    Lopez William Robinson Robert Garcia Ruth

  • @michaelcroftoon5509
    @michaelcroftoon5509 12 дней назад

    Martin Kenneth Gonzalez Jennifer Davis Dorothy

  • @JerrellMerica-c8z
    @JerrellMerica-c8z 26 дней назад

    Harris Scott Smith Kenneth Taylor Shirley

  • @DinaDurbin-e2v
    @DinaDurbin-e2v 13 дней назад

    Young Kimberly Martinez Kenneth Rodriguez Robert

  • @ChaucerGrace-r1j
    @ChaucerGrace-r1j 22 дня назад

    Lewis Angela Lopez Eric Moore Maria

  • @gackerman99
    @gackerman99 10 месяцев назад +2

    i hate everything about what llms are doing to us, and the fact that a bunch of hangers-on blockchain type bros are just making as much bullshit as possible on top of them

  • @LucyTaylor-n4m
    @LucyTaylor-n4m 6 дней назад

    Thomas Frank Davis Karen Rodriguez Sandra

  • @spokesperson_usa
    @spokesperson_usa 10 месяцев назад

    And people say rustc is too complicated.

  • @EdenTyrone-g5t
    @EdenTyrone-g5t 24 дня назад

    Walker John Anderson Dorothy Lewis Brenda

  • @burningredphoenix3
    @burningredphoenix3 10 месяцев назад

    if you want to integrate with legacy software, named pipes are your friends. thank me later

  • @GenciOsmanie
    @GenciOsmanie 9 дней назад

    Harris Christopher Harris Donna Miller Frank

  • @NicholasMichaud-u7e
    @NicholasMichaud-u7e 24 дня назад

    Johnson David Lewis Donald White Dorothy

  • @ClydeHeloise-k4m
    @ClydeHeloise-k4m 8 дней назад

    Harris Carol Hall John White Margaret

  • @sajidurrahman7903
    @sajidurrahman7903 9 месяцев назад

    If I want so much of gibberish boilerplate with types i will use Java.

  • @bullpup1337
    @bullpup1337 10 месяцев назад +2

    Or…. you could just use a statically typed language to begin with….

    • @jxnlco
      @jxnlco 10 месяцев назад +5

      an llm is not statically typed.

    • @bullpup1337
      @bullpup1337 10 месяцев назад

      @@jxnlco what I meant is have the LLM generate code in a typed language, and write the code that interprets the results in a typed language.

  • @mlcat
    @mlcat 10 месяцев назад

    Whoever decided to make a fresh version of pydantic without backwards compatibility (breaking fastapi and everything else), you wasted so many human-hours, and made people remember what are virtual environments. 😡

  • @andgatehub
    @andgatehub 10 месяцев назад +1

    great talk, but please stop using pydantic!

    • @jxnlco
      @jxnlco 10 месяцев назад +2

      what do you suggest?

    • @andgatehub
      @andgatehub 10 месяцев назад

      ​@@jxnlco haskell \s
      To be honest, pydantic is so far ahead of other solutions like dataclasses and attrs that I have trouble arguing against them. But they come with their own typesystem and the authors have been known for causing drama in the python community.

    • @RatafakRatafak
      @RatafakRatafak 9 месяцев назад

      @@jxnlco attrs

  • @annaczgli2983
    @annaczgli2983 10 месяцев назад +2

    Oh, this is on Python. Sorry, not interested.

  • @ymous7051
    @ymous7051 10 месяцев назад

    LMAO, I made something better than this tbh! I don't even want to go on to showcase it to you all, but it's way better than this. dude, I never thought this was a problem to all, lolz. well, I'll be releasing it too then ig. thanks for making this video!

    • @xlagunaa
      @xlagunaa 4 месяца назад

      How its called and where I can try it

    • @abhayshandle
      @abhayshandle 4 месяца назад

      @@xlagunaa okay, so basically i made it a private repo, well this is the idea ig i didn't explain it well back then lol, well, this is how it works, we get a json response, and i convert the json response into a class like object so now instead of accessing data like: response["user"]["name"], you can do it like response.user.name and this just makes ig the typing easier and the code more readable, i mean that's my preference tbh, but then it didn't really work that well, if u liked the concept then ig i'd give u the link to it.

  • @danielsbosworth474
    @danielsbosworth474 12 дней назад

    Allen Matthew Miller Brenda Lopez Joseph

  • @messi_maeun_stew
    @messi_maeun_stew 10 месяцев назад

    amazing job!

  • @SherylWhittemore
    @SherylWhittemore 22 дня назад

    Martin Carol Taylor John Anderson William

  • @ChaucerGrace-r1j
    @ChaucerGrace-r1j 18 дней назад

    Johnson Amy Williams Timothy Robinson Sarah

  • @MichaelMiller-r7t
    @MichaelMiller-r7t 6 дней назад

    Smith Nancy Rodriguez Barbara Perez Lisa

  • @victonypauslon-yd9bc
    @victonypauslon-yd9bc 16 дней назад

    Hall Carol Davis Dorothy Williams Helen

  • @PaulDarcy-h8r
    @PaulDarcy-h8r 15 дней назад

    Johnson Scott Smith Susan Johnson Angela

  • @JonathanPlasse
    @JonathanPlasse 10 месяцев назад

    Thank you for your presentation

  • @danielneal3952
    @danielneal3952 8 дней назад

    Thomas Shirley Harris John Gonzalez Lisa

  • @ElsieMay-z1h
    @ElsieMay-z1h 20 дней назад

    Lee Brenda Wilson Scott Lewis Maria

  • @KennedyLouise-i5v
    @KennedyLouise-i5v 9 дней назад

    Robinson Gary White Gary Martinez Mary

  • @MajinaLaror
    @MajinaLaror 14 дней назад

    Anderson Barbara Jackson Donald Jackson Laura

  • @PaulDarcy-h8r
    @PaulDarcy-h8r 15 дней назад

    Johnson Scott Smith Susan Johnson Angela

  • @atursams5501
    @atursams5501 10 месяцев назад

    I wish that was more like a tutorial. It is really hard to follow.

    • @jxnlco
      @jxnlco 10 месяцев назад +3

      I'll be making one coming out in a month or so!

  • @jamiekenber
    @jamiekenber 10 месяцев назад +1

    This is great. I've been using openai to process survey data in begging mode "please respond with valid json"... try/except/loop
    Anyone know:
    1. If using pydantic, will we hit any issues with async calls?
    2. Can we achieve structured, error-handled responses using langchain instead? Is that the way to go?

    • @jxnlco
      @jxnlco 10 месяцев назад +1

      we'll run into issues of using async validators, but async don't be an issue otherwise