instructor

Extract structured data from LLM outputs using Pydantic schema validation.

Updated Mar 25, 2026
One-click install
npx skills add https://github.com/afel6/scal-ai-pipeline --skill instructor-afel6
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: instructor
Source: https://github.com/afel6/scal-ai-pipeline/tree/main/hermes_skills_library/optional-skills/mlops/instructor
Command: npx skills add https://github.com/afel6/scal-ai-pipeline --skill instructor-afel6

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

LLM responses are often free-form and inconsistent, making automated consumption by downstream systems unreliable; this Skill extracts structured, typed data from model outputs and ensures correctness through schema validation and retries.

Core Features & Use Cases

  • Pydantic validation and automatic retrying: Validate outputs against Pydantic models and automatically request corrected output from the model when validation fails.
  • Robust JSON parsing and type safety: Parse nested and union types safely, normalize values, and provide model-level checks for complex business logic.
  • Streaming and batch workflows: Emit partial objects during generation for real-time UIs and support iterable/batch extraction for bulk processing across providers like Anthropic, OpenAI, and local servers.
  • Use Case: Extract entities, classifications, and structured reports from large document corpora and ingest them into analytics pipelines with guaranteed schema conformance.

Quick Start

Use the instructor client to extract a validated Pydantic model from an LLM response for a supplied text input.

Frequently Asked Questions about instructor

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

FAQPage Schema
How do I get structured JSON output from an LLM with Pydantic validation?

To get structured JSON output from an LLM with Pydantic validation, you define a Pydantic model and pass it to the extraction client. The tool parses the LLM response and validates it against your schema, automatically requesting corrections if validation fails.

Can I stream partial Pydantic objects during LLM generation for real-time UIs?

Yes, you can stream partial Pydantic objects during LLM generation. The tool emits iterable partial objects as the model generates text, enabling real-time UI updates and progressive data display without waiting for the full response.

Does this structured output tool work with both OpenAI and Anthropic models?

Yes, this structured output tool works with both OpenAI and Anthropic models. It supports provider-specific JSON modes and local model deployments, allowing entity extraction and batch processing across multiple LLM providers.

What is the best way to extract entities from large document corpora into analytics pipelines?

The best way to extract entities from large document corpora into analytics pipelines is using schema-validated parsing with batch processing. This approach normalizes nested and union types, guaranteeing schema conformance for downstream analytics ingestion.

Why does my LLM output fail JSON parsing when handling nested and union types?

LLM output fails JSON parsing when handling nested and union types due to inconsistent free-form responses. This tool solves the problem by applying robust JSON parsing and type safety, normalizing values and performing model-level checks for complex business logic.

How does automatic retry work when LLM structured output fails validation?

Automatic retry works by re-prompting the model for corrected output when validation fails. If the initial LLM response does not match the Pydantic schema, the tool automatically requests a corrected response to ensure strict schema conformance.