-
-
Notifications
You must be signed in to change notification settings - Fork 514
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft Pydantic Intro #271
Draft Pydantic Intro #271
Conversation
Important Auto Review SkippedDraft detected. Please check the settings in the CodeRabbit UI or the To trigger a single review, invoke the Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on X ? TipsChat with CodeRabbit Bot (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice first draft 👍
docs/blog/posts/pydantic.md
Outdated
|
||
# Steering Large Language Models with Pydantic | ||
|
||
In the past year, significant progress has been made in utilizing large language models. Prompt engineering, in particular, has gained attention, and new prompting techniques are being developed to guide language models toward specific tasks. While many are building chat bots, an even more exciting application is the generation of structured outputs, whether its extracting structured data, augmenting your RAG application, or even generating |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm guessing you meant to finish the "or even generating..." at the end here, but otherwise I like this as an intro paragraph. As someone who hasn't worked with LLMs a bunch, it could be helpful to add an additional sentence going into more detail about what "prompt engineering" is.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
added!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice, I like the changes you've made!
|
||
In the past year, significant progress has been made in utilizing large language models. Prompt engineering, in particular, has gained attention, and new prompting techniques are being developed to guide language models toward specific tasks. While many are building chat bots, an even more exciting application is the generation of structured outputs, whether its extracting structured data, augmenting your RAG application, or even generating synthetic data. | ||
|
||
!!! question "What is Prompt Engineering?" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I feel like most people have heard the term "Prompt Engineering" now so kind of are familiar with the concept, but if the goal with this block is really to clarify for people who aren't familiar, I personally would be inclined to try to phrase it in a less technical way. I read this and it almost sounds like some advanced machine learning technique, maybe even involving math, etc. lol. And the linked article also talks about it in highly technical language that I expect would be confusing for someone who assumes that AI/machine learning is "above their pay grade".
Like, I am assuming the audience of this article might find this intimidating (screenshot from the link below):
Whereas I feel like my intuition for prompt engineering is closer to "Creatively rephrasing how you pose your question to the AI until it consistently gives responses you want". I understand how that might seem reductive, but I feel like it gives a better intuition and is more inviting to newcomers. And I think once you get that "prompt engineering" is something that's ultimately very intuitive (anyone who has used ChatGPT for more than a few questions has probably independently "discovered" the idea of prompt engineering) it's still easy to appreciate more sophisticated techniques, like using Pydantic models to validate outputs/guide inputs.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess best to say something like "You can think of it very technically like ..., or as just creatively rephrasing how you pose your question to the AI until it consistently gives responses you want".
Co-authored-by: David Montague <35119617+dmontagu@users.noreply.github.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall looks great.
These notes are mostly minor stylistic things, I'll share "bigger-picture" thoughts to you directly.
docs/blog/posts/pydantic.md
Outdated
client = OpenAI() | ||
|
||
|
||
class Package(BaseModel): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
class Package(BaseModel): | |
class PythonPackage(BaseModel): |
and elsewhere below, or change where it says PythonPackage
above to Package
. But I think PythonPackage
is clearer
docs/blog/posts/pydantic.md
Outdated
) | ||
``` | ||
|
||
Now, by using the `response_model` argument, inspired by `FastAPI`, you can specify the desired output, and `instructor` will take care of the rest! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Now, by using the `response_model` argument, inspired by `FastAPI`, you can specify the desired output, and `instructor` will take care of the rest! | |
Now, by using the `response_model` argument (inspired by `FastAPI`) you can specify the desired output and `instructor` will take care of the rest! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
a few tiny things, but overall I think this looks great.
|
||
In the past year, significant progress has been made in utilizing large language models. Prompt engineering, in particular, has gained attention, and new prompting techniques are being developed to guide language models toward specific tasks. While many are building chat bots, an even more exciting application is the generation of structured outputs, whether its extracting structured data, augmenting your RAG application, or even generating synthetic data. | ||
|
||
!!! question "What is Prompt Engineering?" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess best to say something like "You can think of it very technically like ..., or as just creatively rephrasing how you pose your question to the AI until it consistently gives responses you want".
|
||
## Pydantic | ||
|
||
Unlike libraries like `dataclasses`, `Pydantic` goes a step further and defines a schema for your dataclass. This schema is used to validate data, but also to generate documentation and even to generate a JSON schema, which is perfect for our use case of generating structured data with language models! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
technically dataclasses isn't a library, but part of the standard library.
I would say pydantic goes further, in that it 1) enfoces the types in your class and 2) can generate JSON schema for your class.
Co-authored-by: Samuel Colvin <s@muelcolvin.com>
No description provided.