Implementing Self-Correction with LLM Validator - Instructor
python.useinstructor.com · 634 words · saved by 1 readers
Learn how to use llm_validator for self-healing in NLP applications and improve response accuracy with validation errors.
Self-Correction with llm_validator ¶ Introduction ¶ This guide demonstrates how to use llm_validator for implementing self-healing. The objective is to showcase how an instructor can self-correct by using validation errors and helpful error messages. from pydantic import BaseModel import instructor # Apply the patch to the OpenAI client # enables response_model keyword client = instructor . from_provider ( "openai/gpt-4.1-mini" ) class QuestionAnswer ( BaseModel ): question : str answer : str question = "What is the meaning of life?" context = "The according to the devil the meaning
related reading
- Cookbookcookbook.openai.com
- Prompt generation | OpenAI APIplatform.openai.com
- Parsed | Custom, interpretable AI systems that continuously learnparsed.com
- The Shape of AI | UX Patterns for Artificial Intelligence Designshapeof.ai
- PromptLayer — Prompt Management, Evals & Observabilitypromptlayer.com
- Prompting best practicesdocs.anthropic.com
- GitHub - x1xhlol/system-prompts-and-models-of-ai-tools: FULL Augment Code, Claude Code, Cluely, CodeBuddy, Comet, Cursor, Devin AI, Junie, Kiro, Leap.new, Lovable, Manus, NotionAI, Orchids.app, Perplexity, Poke, Qoder, Replit, Same.dev, Trae, Traycer AI, VSCode Agent, Warp.dev, Windsurf, Xcode, Z.ai Code, Dia & v0. (And other Open Sourced) System Prompts, Internal Tools & AI Modelsgithub.com
- GitHub - 567-labs/instructor: structured outputs for llmsgithub.com
- OpenAI | Research & Deploymentopenai.com
- LangChain: the open agent platform to own your intelligencelangchain.com
- GitHub - brexhq/prompt-engineering: Tips and tricks for working with Large Language Models like OpenAI's GPT-4.github.com
- API Overview | OpenAI API Referenceplatform.openai.com