update docs for validation

This commit is contained in:
Jason
2023-09-07 21:00:15 -04:00
parent d082b2ea44
commit bee7ecd059
2 changed files with 174 additions and 6 deletions
+6 -6
View File
@@ -2,12 +2,14 @@
Validation is crucial when using Large Language Models (LLMs) for data extraction. It ensures data integrity, enables reasking for better results, and allows for overwriting incorrect values. Pydantic offers versatile validation capabilities suitable for use with LLM outputs.
## Validation Features in Pydantic
Pydantic supports:
!!! note "Pydantic Validation Docs"
Pydantic supports validation individual fields or the whole model dict all at once.
- [Field-Level Validation](https://docs.pydantic.dev/latest/usage/validators/)
- [Model-Level Validation](https://docs.pydantic.dev/latest/usage/validators/#model-validators)
- [Field-Level Validation](https://docs.pydantic.dev/latest/usage/validators/)
- [Model-Level Validation](https://docs.pydantic.dev/latest/usage/validators/#model-validators)
To see the most up to date examples check out our repo [jxnl/instructor/examples/validators](https://github.com/jxnl/instructor/tree/main/examples/validators)
## Importance of LLM Validation
@@ -136,8 +138,6 @@ def llm_validator(
temperature=temperature,
) # type: ignore
print(resp.model_dump_json(indent=2))
# If the response is not valid, return the reason, this could be used in
# the future to generate a better response, via reasking mechanism.
assert resp.is_valid, resp.reason