instructor

Extract structured data from LLM responses into Pydantic models.

Updated Mar 13, 2026
One-click install
npx skills add https://github.com/hochoa13/Asistente-Harlest --skill instructor-hochoa13
Or copy as Structured Prompt for Agentâ–¼
Please help me install this Agent Skill.
Skill: instructor
Source: https://github.com/hochoa13/Asistente-Harlest/tree/main/skills/mlops/inference/instructor
Command: npx skills add https://github.com/hochoa13/Asistente-Harlest --skill instructor-hochoa13

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires instructor, pydantic, openai, anthropic, and includes references (resource) components.

What problem does it solve?

This Skill solves the challenge of reliably extracting structured data from Large Language Model (LLM) responses, ensuring type safety and validation.

Core Features & Use Cases

  • Structured Data Extraction: Extract data into Pydantic models.
  • Automatic Validation: Ensures LLM outputs conform to defined schemas.
  • Automatic Retries: Handles validation errors by retrying LLM calls.
  • Streaming Outputs: Process partial results as they are generated.
  • Use Case: Extracting customer details (name, email, age) from unstructured text into a Pydantic model, with automatic retries if the LLM initially fails to provide valid data.

Quick Start

Use the instructor skill to extract user data from the provided text into a Pydantic model.

Frequently Asked Questions about instructor

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I extract structured data from LLM responses using Pydantic?â–¼

Structured LLM outputs are achieved by mapping generated text directly into Pydantic models for strict schema validation and type safety. This mechanism automatically retries failed LLM calls upon encountering validation errors.

What is the best way to validate LLM outputs for structured data extraction?â–¼

Validating LLM outputs for structured data extraction is best handled using Pydantic models to enforce strict schemas. This ensures the generated data conforms to your defined types and automatically triggers retries if validation fails.

Does this structured output approach work with both OpenAI and Anthropic models?â–¼

Yes, structured data extraction using Pydantic integrates directly with multiple LLM providers like OpenAI and Anthropic. It validates responses against your schemas and handles errors by automatically retrying the generation.

Can I stream partial LLM outputs during structured data extraction?â–¼

Yes, you can stream partial results during structured data extraction for real-time processing. This allows you to process Pydantic model fields incrementally as the LLM generates the response, rather than waiting for the full completion.

How do I handle validation errors when extracting data into a Pydantic model?â–¼

Handling validation errors during data extraction into a Pydantic model is managed through automatic retries. When the LLM output fails schema validation, the system automatically retries the call to retrieve valid structured data.