OpenAI Discovers JSON (And Zod???)

Поділитися
Вставка
  • Опубліковано 1 жов 2024
  • OpenAI is using Zod to make using LLMs actually feasible for devs, so hyped to see AI companies taking DX seriously with structured outputs!
    OpenAI Article: openai.com/ind...
    Check out my Twitch, Twitter, Discord more at t3.gg
    S/O Ph4se0n3 for the awesome edit 🙏

КОМЕНТАРІ • 103

  • @LooksGoodMusic
    @LooksGoodMusic Місяць тому +59

    This is basically just an iteration on function calling which has been around a long time now, openai has supported json outputs via function calling for a long time now and it covers the same use cases

    • @hola_chelo
      @hola_chelo Місяць тому +4

      Yeah, before it was just verifying that the JSON was valid, now it's a system to format the output, I just started watching so not sure if Theo talks about it but the example they gave on the official statement was pretty cool, basically allowed the model to output a JSON to create an SQL statement with. Pretty cool but not so impressive, this should have been done years ago. It'd take a decent developer a few weeks of work to add a verify to the JSON output to check if it follows the exact schema. But I guess there's more to it than just validating it, you gotta make the model actually spit what you want which is basically as hard as making a potato talk and they achieved that.

    • @frazuppi4897
      @frazuppi4897 Місяць тому

      nha man you are getting all wrong, you parse parameters using it to "make a json" is like an hack and it has not create performances (+ nested stuff is not great)

    • @creaky2436
      @creaky2436 Місяць тому

      Exactly what I was saying. Been doing this for a while now, although it has been enhanced for sure, overall.

    • @KeyStorm
      @KeyStorm Місяць тому

      Also all VSCode AI extensions using OpenAI models use JSON as a means to obtaining only code all the time as part of a structured response.

    • @frazuppi4897
      @frazuppi4897 Місяць тому +1

      @@creaky2436 YOU CANNOT SINCE YOU DON"T HAVE ACCESS TO THE SAMPLER FFS

  • @lynxcat4life
    @lynxcat4life Місяць тому +55

    Actual purpose-built improvement to AI tools?? Never thought I'd see the day

  • @hightidesed
    @hightidesed Місяць тому +26

    small correction, when including a list of reasoning steps in the output, it is not used to reference how the llm arrived at the answer, but to actually boost llm performance by allowing it to "think" before generating a response, which is why it is important that the steps array comes before the answer field, otherwise you will not see improvement at all.

    • @themprsndev
      @themprsndev Місяць тому +7

      Theo has no idea how LLMs work, like he literally has zero clue. It's sad to see that after sooooo many people told him this he still hasn't spent a few hours to learn about it.

    • @twitchizle
      @twitchizle Місяць тому +1

      ​@@themprsndevhe doesnt know anything but bullshet , influencers

  • @diogotrindade444
    @diogotrindade444 Місяць тому +2

    I think this is lazy and bad architecture design. Yes, it is a really good idea to add JSON schema rules. But it is nonsense for me to add an extra dependency called zod with zero code architecture on the NPM source code and make the devs install an extra dependency in production… It could be just a simple JSON example or simple JSON format with a validator function helper, much more simple to implement with a simple documentation page. Adding any dependency small or not it is be really lazy on a product that will live inside a huge range of applications types. It doesn’t matter if you like zod, be minimal needs to be a much in a product that is used at this scale.

    • @diogotrindade444
      @diogotrindade444 Місяць тому

      After some resarch even the zod playground is not helpful. I found some free online tools that convert JSON to zod, but non until now that converts zod to zod JSON output.
      In conclusion, who does not want to install zod can ask a LLM what will be the zod output because most of the time the output is really simple (it is computed already) and use it as input on the new OpenAI API. If some of you know about better tools to do it without install it, please let me know.

  • @levi3970
    @levi3970 Місяць тому +5

    We're using structured json for our project.
    OpenAI can take a "description" field for each value. Which means you can actually embed a subprompt inside each field. describing what the output of that specific field is.

  • @Maxjoker98
    @Maxjoker98 Місяць тому +4

    19:20 Nobody ever claimed JSON, HTML, CSS, etc are not languages, they're just not programming languages. For HTML, it obviously considers itself a language, it's got language in it's name(HpyerText Markup *Language*).

    • @twitchizle
      @twitchizle Місяць тому

      He is stoopid influencer

  • @theskyblockman
    @theskyblockman Місяць тому +3

    Someone tell him Google's Gemini already had this feature before?

  • @furyzenblade3558
    @furyzenblade3558 Місяць тому +1

    Doesn’t Google also offer this with their Gemini models?

  • @steve_jabz
    @steve_jabz Місяць тому +1

    GPTs don't suck at counting, you just have to prompt them to account for tokenization. It's an ebkac/skill issue. Same as the 9.9 vs 9.11 'problem'.
    If you say Write out the letters in "Javascript" and test if each letter is "a" or not to count how many a's are in it, it will get it right 100% of the time, even on old models.

    • @OneEyedMonkey9000
      @OneEyedMonkey9000 Місяць тому

      I misheard him say 9.9 vs 9.91 sounds like an excuse to laugh at people who don’t speak English as their first language 🤔

  • @Popo-pd3ps
    @Popo-pd3ps Місяць тому +3

    Vercel AI and Langchain support these feature a decade ago 😂

  • @PrajwalDSouza
    @PrajwalDSouza Місяць тому +4

    And I thought function calling was the solution already.

    • @justy1337
      @justy1337 Місяць тому +2

      Yeah and TGI has grammar sampling

    • @J3R3MI6
      @J3R3MI6 Місяць тому +2

      Exactly

  • @InfiniteWithout
    @InfiniteWithout Місяць тому +1

    This sounds awesome and would be a step in the right direction for current artificial specific intelligence

  • @friendlywavingrobot
    @friendlywavingrobot Місяць тому +1

    Take a picture of some text and ask ChatGPT to format it as JSON. I did it with some tables of numbers in a book.

  • @Dent42
    @Dent42 Місяць тому +1

    2:50 “Agentic” is the word used in the “systems” argot, as you’re not designing agents so much as you’re designing a system that uses an “agentic” framework

  • @winstonyeo4342
    @winstonyeo4342 Місяць тому +1

    tl;dr JSON is now a language. Looking for a dev with 16 years of experience with the JSON language

  • @DMZT_dhruv
    @DMZT_dhruv Місяць тому

    Hey theo, you are a mac user, why don't you use the desktop app of chat gpt

  • @andgatehub
    @andgatehub 3 дні тому

    This is bigger news than Theo seems to realize. That 40% accuracy figure has been a problem for awhile. Not even models trained specifically for json output could score much higher. There are workarounds (retrying model calls), but nothing as good as this structured outputs approach.
    Also, why is he randomly plugging Vercel's AI "sdk"? You think curl is too hard for experienced developers or something? I would be shocked if anyone actually used that.

  • @martinbechard
    @martinbechard Місяць тому +6

    The support for Zod is great. However apparently it messes with the “reasoning” so you need to have a 2 step process - one to generate the answer in unstructured format, then another call to actually format the answer. By the way the flakiness of previous versions is much exaggerated, I created complex JSON outputs based on typescript interfaces provided in the system prompt for non-trivial tress of objects and found GPT-4 and 4o to be very consistent. What did happen is that extraneous text such as: “here is your answer:” but it was easy enough to parse.

    • @halopro77
      @halopro77 Місяць тому

      100%, been using chat gpt 4/4o to extract information following a typescript interface as well. Kinda felt like magic, then the output json feature was added and it was pretty good

    • @frazuppi4897
      @frazuppi4897 Місяць тому

      no man, it doesn't use zod to make json, it used zod so the user can write zod stuff and parse it back, it is converted to a json schema, a cfg is created and it is used to do constrained decoding, so we remove tokens that do not make sense for a valid json

    • @martinbechard
      @martinbechard Місяць тому

      @@frazuppi4897 does it get applied on the server or is this just happening on the client in the api library? It seemed like the API has a field for it

    • @frazuppi4897
      @frazuppi4897 Місяць тому +1

      @@martinbechard happens on the server on their side. Imagine decoding a json from a language model, you know that the first token must be "{" thus only that one is sampled, then you know that the first key is, for example from the json schema, "hello" so you can just fill it, then a ":" must appear and so on
      It is explained in the blog post

  • @matserdam
    @matserdam Місяць тому

    The fact that ChatGPT 4 does not put in a code block is actually something I prefer. While experiencing whit some llms using ollama I received json wrapped in markdown when asking for json with some models, even with customized modelfiles. When you ask for json, you should get json!

  • @mamad-dev
    @mamad-dev Місяць тому

    not putting the result in a code block is the right thing to to tbh, you asked them not to include anything else, which is what they did by not putting it in a code block, putting it in a codeblock needs the model to respond with
    ```json
    JSON DATA
    ```
    which is not what you've asked

  • @andreicozma6026
    @andreicozma6026 Місяць тому

    lol the comments in the live so confidently saying incorrect things about how LLMs work is so ironic… Reminds me of how LLMs can so confidently hallucinate wrong answers.

  • @ollamaapi
    @ollamaapi Місяць тому

    you could fine-tune an open-source language model to perform this task. Fine-tuning a base model typically takes minutes, and the output can be consistently formatted according to your specifications , also the cost is free.

  • @allie-ontheweb
    @allie-ontheweb Місяць тому +1

    5:30 it didn't forget to put it in a code block, it just followed your instructions and gave you raw text instead of wrapping it with ``` ```

  • @Aoredon
    @Aoredon Місяць тому +1

    Aren't you supposed to use the API if you want to test out the new features of the model?

  • @creaky2436
    @creaky2436 Місяць тому

    Of course mine wasn't this good, i'm not delusional. Lol. However, using ai as an api with structured data is awesome. You can create any api you want.

  • @kamertonaudiophileplayer847
    @kamertonaudiophileplayer847 Місяць тому +5

    Unstructured data to structured is what we all wanted.

  • @malvoliosf
    @malvoliosf Місяць тому

    Hahaha, I have been working for several weeks on a project that had as a core assumption that ChatGPT could already do this. It’s like St. Elizabeth and the Roses.

  • @peterlittle4937
    @peterlittle4937 Місяць тому

    nah I actually really like the ai videos, like it or not most developers are going to be working on or with ai tools sooner or later

  • @6lack5ushi
    @6lack5ushi Місяць тому

    We had JSON mode.
    but I built my own function calling model to handle this issue because it just did not listen to JSON and still I get outputs that are so on the edge its WILD!

  • @pukimaa
    @pukimaa Місяць тому

    Love the vid! (even though I watched it on stream. great topics as always btw)

  • @FilipFranik
    @FilipFranik Місяць тому

    L in HTML stands for Language It's a Markup Language mot a Programming Language.

  • @domenicurso
    @domenicurso Місяць тому +8

    Bro it’s been 1 minute and the bots are already digging in

    • @rennyhoang3737
      @rennyhoang3737 Місяць тому +2

      hopefully reporting them actually does something

    • @ProSureString
      @ProSureString Місяць тому +1

      I can’t see them, I think he removed them

  • @teddyfulk
    @teddyfulk Місяць тому

    We've been able to get structured outputs with instructor for a year now?

  • @frazuppi4897
    @frazuppi4897 Місяць тому

    it doesn't use zod to make json, it used zod so the user can write zod stuff and parse it back, it is converted to a json schema, a cfg is created and it is used to do constrained decoding, so we remove tokens that do not make sense for a valid json

  • @E_m1ly_6302
    @E_m1ly_6302 Місяць тому

    Hmmmm, i read an openai article already in April of 2023, where they described, that the "tool use" capability of ChatGPT (wich came out then), was able to output valid JSON (i mean only generating valid JSON). So this capability existed for over a year...
    The only actual improvement is that it adheres to schemas now.

  • @MrEnriqueag
    @MrEnriqueag Місяць тому

    Langchain has done this for years now for any inference endpoint

  • @matthewwoodard9810
    @matthewwoodard9810 Місяць тому

    Even before this getting the exact format you wanted back wasn’t that hard. If your prompt is good, you can get back the right format 13 or 14 times out of 15. You put retry logic to try again if you get error on the format, and you use a simple Regex to parse out anything that’s not part of, say, your JSON object

  • @xyzzy12345
    @xyzzy12345 Місяць тому

    I'm starting to understand why zod is so much more popular than something like typia, when the stuff you're validating is json anyway. Might as well use json to structure it instead of typescript.

  • @hexxt_
    @hexxt_ Місяць тому

    not putting it in a code block is the correct response bruh

  • @by010
    @by010 Місяць тому

    16:03 we actually use AI for that at work. There are already solutions that will hook into google meet and record it, transcribe it, and make notes. Our absolutely PO loves it. I found it useful quite few times too, especially it makes it easy to narrow down where it came from, and re-listen to that part of meeting if you are unsure or looking for specific anwser for question you know was asked etc. Very useful stuff.

  • @BellCube
    @BellCube Місяць тому

    I'd wager half the people getting mad at comparing GPT models to a suped-up autocomplete fundamentally does not understand how GPT models works (generating individual tokens based on the tokens that came before)

  • @nickwoodward819
    @nickwoodward819 Місяць тому +1

    Have you ever done a video on why you use ORMs? I use Drizzle, but have been solidifying my sql knowledge recently and was wondering why not jump in two-footed? Might make a good video if you haven't done it?

    • @boccobadz
      @boccobadz Місяць тому

      ORMs fall apart when you do anything non-trivial. But most js devs queries are 'select * from xyz where a = b' so it's enough. Try writing nested loops (pretty standard in Postgres) in ORM lol

    • @nickwoodward819
      @nickwoodward819 Місяць тому

      @@boccobadz Sure, it was more a rhetorical question on my part, and a specific one on why he personally uses them. I mean you aren't wrong, but non-trivial sql queries are still non-trivial in sql, no?

    • @CHROMIUMHEROmusic
      @CHROMIUMHEROmusic Місяць тому

      I'd say the primary reasons for me are:
      1. ORMs offer protection from SQL injection, which is pretty vital if your statement involves some amount of user input
      2. ORMs can make it easier to dynamically construct statements programatically - e.g. if you want to apply a bunch of filters/grouping/ordering determined by a user, I'd say its a LOT simpler to add these filters together through an object interface in Python/JS, rather than attempting to concatenate strings yourself
      There's probably plenty more reasons but I can't think of them off the top of my head. I would say if your SQL query is static, doesn't involve any user input values, and you observe significant performance benefits for raw SQL over the ORM, then perhaps raw SQL is the way to go. But never prematurely optimise :)

  • @Fanaro
    @Fanaro Місяць тому

    The timeline in which deterministic output is a newsworthy feature... lol

  • @tomasb3191
    @tomasb3191 Місяць тому

    function calling has been around for a while, zod types are also implemented at the vercel AI SDK. I think you should cover it.

  • @6lack5ushi
    @6lack5ushi Місяць тому

    WELP I cant use this! why not make it a model parameter and not a just when function calling caveat???

  • @kyuss0x1
    @kyuss0x1 Місяць тому

    Teo is click bate talking shit anbout Postgres

  • @wumbl3
    @wumbl3 Місяць тому

    JSDOC support would be nice :)

  • @WiseWeeabo
    @WiseWeeabo Місяць тому

    we had this already with openai function calling, but it's cool that it's now "100% reliable"

  • @weathercontrol0
    @weathercontrol0 Місяць тому

    Some models were wise enough not to put in markdown markup in responses as you said that you'll parse the response directly, you saw it as a mistake

  • @helleye311
    @helleye311 Місяць тому

    AI sucks, it can't even answer "What is love" with "baby don't hurt me". 0/10

  • @cid-chan-2
    @cid-chan-2 Місяць тому

    Gave it a documentation one. Asked it questions about it. It rejected my documentation and substituted it with its own. Lets see if it works now.

  • @jnevercast
    @jnevercast Місяць тому

    Watching all the wrong answers in the chat 🙈

  • @tobiaszimmermann5149
    @tobiaszimmermann5149 Місяць тому

    Can please someone make tree shaking in zodiac possible or we all just start using valibot please

  • @creaky2436
    @creaky2436 Місяць тому

    I have been doing this since ai came out.

  • @nikev
    @nikev Місяць тому +1

    Damn. Every comment at this time is a bot.

    • @ProSureString
      @ProSureString Місяць тому

      Only you? I don’t see anyone else 👀
      EDIT: seems Theo removed them. Yay!

  • @AbstruseJoker
    @AbstruseJoker Місяць тому

    Theo has had his head in the sand for so long on AI that he thinks this is groundbreaking

  • @hexxt_
    @hexxt_ Місяць тому

    yeah like gemini had for months

  • @Definesleepalt
    @Definesleepalt Місяць тому

    i guess we might not want to piledrive theo for this information .....

  • @GilesBathgate
    @GilesBathgate Місяць тому

    So is this a LSLM ? (Large structured language model)

  • @pempheromkuka7874
    @pempheromkuka7874 Місяць тому

    Gemini already have this

  • @attilazimler1614
    @attilazimler1614 Місяць тому

    lol, imagine the situation where your website is so dynamic that you just on the fly always pull it out from an LLM and maybe do some vector database to store already generated pages :D

  • @Pekieend
    @Pekieend Місяць тому

    Now let it return htmx

  • @nickwoodward819
    @nickwoodward819 Місяць тому +2

    oof, love your stuff, but openAI? don't care. it's that much worse than claude. i'd rather have claude structure my data using the medium of dance than use openAI with zod. and i love zod

  • @relix3267
    @relix3267 Місяць тому

    superman

  • @bestpoker
    @bestpoker Місяць тому

    Theo- can you do a video on how you use Apple Notes? TY

  • @RajdeepSingh11
    @RajdeepSingh11 Місяць тому

    My like is for AI SDK. 12:44

  • @Sbeve.
    @Sbeve. Місяць тому

    thats huge!💪

  • @sadface
    @sadface Місяць тому

    Report the bots

  • @ahmadgazzz
    @ahmadgazzz Місяць тому

    Second

  • @wandenreich770
    @wandenreich770 Місяць тому +1

    I feel like these formatted output are a big release the possibilities are endless

  • @beofonemind
    @beofonemind Місяць тому

    omfg

  • @Triyanox
    @Triyanox Місяць тому +1

    zod in the box