Загрузка видео...

Не удалось загрузить видео

На главную

Messing about with getting structured outputs from an LLM. The concept of 'tools' in Vercel's 'ai' lib makes this pretty simple.

41,182 просмотров • 1 год назад •via X (Twitter)

Комментарии: 10

Фото профиля David K 🎹
David K 🎹1 год назад

Nice! Unsolicited feedback: I'd use gpt-4o-mini (more recent) and wouldn't rely too much on the confidence score, since those aren't easily quantifiable and LLMs are not that good with numbers. Another idea is to have it return "not confident", "somewhat confident", ... from an enum instead. Another idea: have a chain of prompts which first classify whether the input is a country or not, and if it is, provide the capital. Begins to look like a state machine 🚀

Фото профиля Nico Albanese
Nico Albanese1 год назад

tools are so cool! Btw if you’re looking for pure structured output, check out the generateObject and streamObject functions

Фото профиля typeofalex
typeofalex1 год назад

Tools exist on the original APIs, no need for Vercel’s ai libs I want to add.

Фото профиля Matt Pocock
Matt Pocock1 год назад

Useful, thanks!

Фото профиля saurabh gaur
saurabh gaur1 год назад

It’d be amazing to see a full totaltypescript kind of course from you on the Vercel AI SDK soon, pls pls make one!

Фото профиля Jayden Carey
Jayden Carey1 год назад

Maybe worth checking out agentic by @transitive_bs if you're wanting to go deeper with tools. Has a good stdlib collection to play with + you can use it to write SDK agnostic tools if desired.

Фото профиля 0xPooka
0xPooka1 год назад

LOL trying to get the LLM to cooperate the same way it did previously with Djibouti was just hilarious. I haven’t seen this before though I’m excited to try it!

Фото профиля Christoffer Bjelke
Christoffer Bjelke1 год назад

Have you looked at TypeChat? Havent digged deep yet, but seems very interesting. Maybe "outdated" with these new APIs though

Фото профиля Masood
Masood1 год назад

That's awesome! I didn't know you could use zod with Vercel AI

Фото профиля Tarek Kh
Tarek Kh1 год назад

Really Nice!

Похожие видео

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,578 просмотров • 1 год назад