filmov
tv
Get LLM output as Python object with Langchain and Pydantic | Hands-on tutorial
Показать описание
The #Pydantic output parser is a tool that allows users to define a JSON schema to query LLMs for outputs that adhere to that schema. This is pivotal for applications that require structured data, as it ensures outputs conform to predefined formats. The parser leverages Pydantic’s BaseModel for data validation and type checking.
With this tutorial you will learn to: set up the data model in a way that Langchain’s output parser can be used to generate structured data.
For example, you can grab from #LLM not a plain text (as an answer), but re-usable Python objects, such as Python list, dictionary, Pandas dataframe and more.
This functionality allows you to create super powerful LLM applications where any kind of data transformation, parse or passing to ML models (such as example) are required.
To utilize this parser, one must define the data structure using Pydantic’s BaseModel. You will learn that in the tutorial.
Useful links and references:
In this tutorial I used OpenAI's ChatGPT API to support LLM. Feel free to use any supported LLM using LangChain (now testing on IBM WatsonX).
The content of the tutorial:
0:00 - Main idea using Pydantic with Langchain
1:09 - Implementation scheme for hands-on
3:29 - Hands-on part (coding)
15:06 - BONUS: Github repo
#langchain
Happy learning!
With this tutorial you will learn to: set up the data model in a way that Langchain’s output parser can be used to generate structured data.
For example, you can grab from #LLM not a plain text (as an answer), but re-usable Python objects, such as Python list, dictionary, Pandas dataframe and more.
This functionality allows you to create super powerful LLM applications where any kind of data transformation, parse or passing to ML models (such as example) are required.
To utilize this parser, one must define the data structure using Pydantic’s BaseModel. You will learn that in the tutorial.
Useful links and references:
In this tutorial I used OpenAI's ChatGPT API to support LLM. Feel free to use any supported LLM using LangChain (now testing on IBM WatsonX).
The content of the tutorial:
0:00 - Main idea using Pydantic with Langchain
1:09 - Implementation scheme for hands-on
3:29 - Hands-on part (coding)
15:06 - BONUS: Github repo
#langchain
Happy learning!
Комментарии