instructor

Extract structured data from LLM responses using Pydantic models.

228k|44.7k|Updated Jul 22, 2025
One-click install
npx skills add https://github.com/NousResearch/hermes-agent --skill instructor-nousresearch
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: instructor
Source: https://github.com/NousResearch/hermes-agent/tree/main/skills/mlops/instructor
Command: npx skills add https://github.com/NousResearch/hermes-agent --skill instructor-nousresearch

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, validated data from Large Language Model (LLM) responses, ensuring type safety and automatic error handling.

Core Features & Use Cases

  • Structured Data Extraction: Extract data into Pydantic models for type-safe access.
  • Automatic Validation: Pydantic schemas validate LLM outputs, retrying on failure.
  • Streaming Outputs: Process partial results as they are generated by the LLM.
  • Use Case: Extracting customer details (name, email, age) from unstructured text into a Pydantic User model, with automatic retries if the LLM fails to provide valid data.

Quick Start

Use the instructor skill to extract user data 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 extract structured data from LLM responses by passing a Pydantic model to define the expected schema, which validates the LLM output for type safety. The process automatically retries if the LLM fails to generate valid data matching your schema.

What is the best way to validate LLM outputs and retry on validation failures?

Validating LLM outputs is best handled using Pydantic schemas to enforce type safety on the generated text. The system automatically detects validation failures and triggers retries to ensure the final output strictly matches the defined model.

Can I get streaming partial results from an LLM into a Pydantic model?

Yes, you can process partial results as they are generated by the LLM. This streaming capability allows you to incrementally populate and interact with a Pydantic model while the text generation is still in progress.

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

Yes, structured data extraction using Pydantic validation works with both OpenAI and Anthropic models. The implementation relies on their respective dependencies to ensure type-safe data parsing and automatic retries across different LLM providers.

When do I need structured LLM outputs for data parsing and classification tasks?

You need structured LLM outputs when performing complex data parsing, classification, or information retrieval tasks that require reliable formats. Using Pydantic validation ensures the extracted data is type-safe and automatically corrected upon failure.

Why do LLM data extraction attempts fail and how can Pydantic validation prevent it?

LLM data extraction often fails due to malformed or unstructured text outputs. Pydantic validation prevents this by enforcing a strict schema for type safety, automatically triggering retries to correct any outputs that fail validation.