Outlines is a Python library for constrained language generation. It provides a unified interface to various language models and allows for structured generation using techniques like regex matching, type constraints, JSON schemas, and context-free grammars.Outlines supports multiple backends, including:
pip install transformers torch datasets
pip install llama-cpp-python
pip install vllm
pip install mlx
Outlines
class:
ChatOutlines
class:
Outlines
and ChatOutlines
classes share similar configuration options:
model
parameter can be:
backend
parameter specifies which backend to use:
"transformers"
: For Hugging Face Transformers models (default)"llamacpp"
: For GGUF models using llama.cpp"transformers_vision"
: For vision-language models (e.g., LLaVA)"vllm"
: For models using the vLLM library"mlxlm"
: For models using the MLX framework