{ "cells": [ { "cell_type": "markdown", "id": "d9b7d2edd30ecc1d", "metadata": {}, "source": [ "# LLM Validation With Retries\n", "\n", "This recipe demonstrates how to leverage Large Language Models (LLMs) -- specifically Anthropic's Claude 3.5 Sonnet -- to perform automated validation on any value. We'll cover how to use **LLMs for complex validation tasks**, how to integrate this with Pydantic's validation system, and how to leverage [Tenacity](https://tenacity.readthedocs.io/en/latest/) to automatically **reinsert validation errors** back into an LLM call to **improve results**.\n", "\n", "
Mirascope Concepts Used
\n", "Background
\n", "\n", "While traditional validation tools like type checkers or Pydantic are limited to hardcoded rules (such as variable types or arithmetic), LLMs allow for much more nuanced and complex validation. This approach can be particularly useful for validating natural language inputs or complex data structures where traditional rule-based validation falls short.\n", "
\n", "Additional Real-World Examples
\n", "