Favicon of Instructor

Instructor

An MIT-licensed LLM data extraction library that validates structured outputs with Pydantic and works with Ollama, llama-cpp-python, vLLM and cloud APIs.

Screenshot of Instructor website

Instructor is an open-source library for developers who need structured data from local LLMs or cloud models. It turns natural-language input into typed objects that applications can use, with validation and retries built into the extraction process. Its focus is data extraction.

The Python library uses Pydantic to describe the expected data and check model responses against it. Schemas can include nested objects, lists and custom validation rules, so extraction can cover a customer support case with multiple tickets as well as a simple name-and-age record. When a response fails validation, Instructor retries with the validation error as feedback. These checks enforce the schema and your rules; they don't establish that every extracted fact is correct.

For local inference, it works with Ollama, llama-cpp-python and vLLM. The model runs through your chosen local backend. It also connects to cloud providers including OpenAI, Anthropic, Google, Mistral, Cohere and DeepSeek, where model requests go to the selected provider. A shared interface keeps structured output handling consistent across providers.

Streaming supports partial objects and lists before the full response arrives. Python developers also get type inference, IDE autocompletion, and synchronous or asynchronous calls. Instructor is available in TypeScript, Go, Ruby, Elixir and Rust as well, and the Python repository uses the MIT license.

Similar to Instructor