instructor

Extract structured data from LLM responses using Pydantic schema validation.

Updated Jun 17, 2026
One-click install
npx skills add https://github.com/cxnaive/hermes-agent-llbot --skill instructor-cxnaive
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: instructor
Source: https://github.com/cxnaive/hermes-agent-llbot/tree/main/optional-skills/mlops/instructor
Command: npx skills add https://github.com/cxnaive/hermes-agent-llbot --skill instructor-cxnaive

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 getting consistent, validated, and structured data from LLM outputs, preventing the common issues of malformed JSON or incorrect data types.

Core Features & Use Cases

  • Structured Extraction: Automatically maps LLM responses to Pydantic models for type-safe data handling.
  • Automatic Validation & Retries: If the LLM produces invalid data, the skill automatically retries the request with error feedback to ensure compliance with your schema.
  • Use Case: Use this to extract entities like names, dates, and prices from unstructured text into a clean, ready-to-use Python object for your database.

Quick Start

Use the instructor skill to extract user information 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?

You can extract structured data from LLM responses by enforcing Pydantic schema validation, which automatically maps LLM outputs to type-safe Python objects for reliable data handling.

What is the best way to validate JSON output from an LLM?

The best way to validate JSON output from an LLM is using Pydantic schema validation with automatic retry logic, which feeds validation errors back to the LLM to ensure high-fidelity data compliance.

Does this structured extraction approach work with both OpenAI and Anthropic models?

Yes, structured extraction with Pydantic validation works across multiple LLM providers, supporting diverse workflows including entity extraction, classification, and complex JSON parsing for both OpenAI and Anthropic.

How do automatic retries handle invalid data types during LLM data extraction?

Automatic retries handle invalid data types during LLM data extraction by catching validation failures and automatically retrying the request with error feedback to ensure the output strictly matches your schema.

Why does my LLM return malformed JSON instead of the expected structured output?

LLMs return malformed JSON instead of structured output due to the lack of enforced schema constraints, a problem solved by applying Pydantic model validation to enforce consistent, type-safe data generation.