outlines-core
Library Listed
Structured Generation
- Downloads
- 2,320
- Dependents
- 1
- Stars
- 320
- Forks
- 80
- Contributors
- 30
- Commits
- 249
- Latest release
- 0.2.14 ·
About

Structured generation (in Rust).
This package provides the core functionality for structured generation, formerly implemented in Outlines, with a focus on performance and portability, it offers a convenient way to:
build regular expressions from JSON schemas
construct an
Indexobject by combining aVocabularyand regular expression to efficiently map tokens from a given vocabulary to state transitions in a finite-state automation
Example
Basic example of how it all fits together.
Read the full README
use outlines_core::prelude::*;
// Define a JSON schema
let schema = r#"{
"type": "object",
"properties": {
"name": { "type": "string" },
"age": { "type": "integer" }
},
"required": ["name", "age"]
}"#;
// Generate a regular expression from it
let regex = json_schema::regex_from_str(&schema, None)?;
// Create `Vocabulary` from pretrained large language model (but manually is also possible)
let vocabulary = Vocabulary::from_pretrained("openai-community/gpt2", None)?;
// Create new `Index` from regex and a given `Vocabulary`
let index = Index::new(®ex, &vocabulary)?;
let initial_state = index.initial_state();
let allowed_tokens = index.allowed_tokens(&initial_state).expect("Some allowed token ids");
let token_id = allowed_tokens.first().expect("First token id");
let next_state = index.next_state(&initial_state, token_id);
let final_states = index.final_states();
Vocabulary
You can create a Vocabulary in three ways:
Vocabulary::from_pretrained(model, parameters)- Loads from a pretrained model (as in the example above)Manual creation - You can create a vocabulary from token mappings:
Vocabulary::new(eos_token_id)- Creates an empty vocabulary, then add tokens withtry_insert():let mut vocabulary = Vocabulary::new(50256); vocabulary.try_insert("hello", 0)?; vocabulary.try_insert(vec![32], 1)?;Vocabulary::try_from((eos_token_id, tokens))- Creates a vocabulary by directly providing the token mappings.It can be done either with the tokens as strings:
use rustc_hash::FxHashMap as HashMap; let eos_token_id: u32 = 50256; let mut tokens: HashMap<String, Vec<u32>> = HashMap::default(); tokens.insert("hello".to_string(), vec![0]); tokens.insert("world".to_string(), vec![1]); let vocabulary = Vocabulary::try_from((eos_token_id, tokens))?;Or with the tokens as byte vector keys:
use rustc_hash::FxHashMap as HashMap; let eos_token_id: u32 = 50256; let mut tokens: HashMap<Vec<u8>, Vec<u32>> = HashMap::default(); tokens.insert(b"hello".to_vec(), vec![0]); tokens.insert(b"world".to_vec(), vec![1]); let vocabulary = Vocabulary::try_from((eos_token_id, tokens))?;
Important: When creating a Vocabulary manually from tokenizer data, ensure tokens are converted to their string representations to replace special tokens that wouldn't be recognized by the DFA.
Python Bindings
Additionally, project provides interfaces to integrate the crate's functionality with Python.
import json
from outlines_core.json_schema import build_regex_from_schema
from outlines_core import Guide, Index, Vocabulary
schema = {
"title": "Foo",
"type": "object",
"properties": {"date": {"type": "string", "format": "date"}}
}
regex = build_regex_from_schema(json.dumps(schema))
vocabulary = Vocabulary.from_pretrained("openai-community/gpt2")
index = Index(regex, vocabulary)
guide = Guide(index)
# Get current state of the Guide:
current_state = guide.get_state()
# Get allowed tokens for the current state of the Guide:
allowed_tokens = guide.get_tokens()
# Advance Guide to the next state via some token_id and return allowed tokens for that new state:
next_allowed_tokens = guide.advance(allowed_tokens[-1])
# To check if Guide is finished:
guide.is_finished()
# If it's finished then this assertion holds:
assert guide.get_tokens() == [vocabulary.get_eos_token_id()]
How to contribute?
Setup
Fork the repository on GitHub and clone the fork locally:
git clone git@github.com/YourUserName/outlines-core.git
cd outlines-core
Create a new virtual environment and install the dependencies in editable mode:
python -m venv .venv
source .venv/bin/activate
pip install -e ".[test]"
pre-commit install
Before pushing your code
If working with Python bindings don't forget to build Rust extension before testing, for example, in debug mode:
make build-extension-debug
Run Python tests:
pytest
Run Rust tests:
cargo test
Or alternatively using Makefile for both:
make test
Finally, run the code style checks:
pre-commit run --all-files
Or using Makefile:
make pcc
If necessary you can run benchmarks locally:
make pybench
Join us
Compatibility
- Runs on
- GPU support unknown
What shows it
- no dependency or feature matches a backend row
- Native code
- None found
- No native code found
- Python bindings
- Has Python bindings
- outlines-core needs Python only with feature python-bindings
- License
- Apache-2.0
Compare with similar projects
Order: strongest tier first, then most downloads, then name, with unmeasured values last. A library counts downloads over 30 days. An app counts binary downloads per release. An app with none counts its crate downloads over 30 days. ML Rust runs this catalogue, so its closest project always gets a row.
| Project | Downloads | Dependents | Stars | Latest release | Runs on (GPU) | Native code | License |
|---|---|---|---|---|---|---|---|
|
Structured Generation Python bindings |
2,320 downloads over 30 days | 1 | 320 | 0.2.14 | GPU support unknown | No native code found | Apache-2.0 |
|
ort Featured
A safe Rust wrapper for ONNX Runtime 1.31 - Optimize and accelerate machine learning inference & training Also in Run and serve models. |
3,902,768 downloads over 30 days | 694 | 2,611 | 2.0.0-rc.15 | CUDA, WebGPU, ROCm | Binds native code: onnxruntime, ort-sys. Build uses a native toolchain: pkg-config (feature pkg-config) | Apache-2.0 OR MIT |
|
rten Featured
Tensor library for the RTen machine learning runtime Also in Run and serve models. |
496,924 downloads over 30 days | 29 | 360 | 0.27.0 | GPU support unknown | No native code found | Apache-2.0 OR MIT |
|
llguidance Featured
LLM Token Trie library Also in Build LLM apps and agents. |
182,570 downloads over 30 days | 22 | 909 | 1.9.1 | GPU support unknown | No native code found | MIT |
|
Fast, flexible LLM inference. Python bindings Also in Build LLM apps and agents. |
1,498 binary downloads per release | Not applicable | 7,819 | 0.8.1 | CUDA, Metal | Binds native code: accelerate-src (feature accelerate-src), intel-mkl-src (feature intel-mkl-src) | MIT |
|
A Datacenter Scale Distributed Inference Serving Framework Also in Build LLM apps and agents. |
6,860 downloads over 30 days | Not applicable | 8,457 | 1.6.2 | CUDA | Binds native code: k8s-openapi, nixl-sys, pcre2-sys, ring, zmq-sys and 2 more | Apache-2.0 |
|
Inference server for LLMs, speech and embeddings: OpenAI-compatible routes with streaming, plus speech synthesis (TTS) and transcription (ASR). Serves Llama, Mistral, Qwen, Mamba2, MLA+MoE and hybrid models from SafeTensors, AWQ, GPTQ and GGUF. Also in Build LLM apps and agents. |
8 binary downloads per release | Not applicable | 7 | 0.7.1 | CUDA, WebGPU | Binds native code: ring (feature distributed) | Apache-2.0 |
All projects in Build LLM apps and agentsAll projects in Run and serve models
Why ListedNo archive, New or Featured rule places it, so it is Listed.
What it lacks for Featured
- It has 1 active dependents and 1 new dependents in 365 days. Featured needs 11 active dependents or 9 new dependents in 365 days. The repository route reads 320 stars, 80 forks and 30 contributors. It needs 4,539 stars, 434 forks and 79 contributors together.
What else the check found
- The last activity is on 5 Aug 2026, 96 days ago. The rules expect an update within 450 days. Dormancy rule
- The latest release requires the deprecated dependency bincode. RUSTSEC-2025-0141 Rot signals rule
Check notes
- the latest release was packaged from a dirty working tree
Exact rules: Listed, Featured library. The check on applied thresholds version 9.
Every rule outcome, as the check records it
expected-interval: version 0.2.14 base 450: E = 450 daysdormancy: last activity 2026-08-05, 96 days ago, E = 450: activerot: deprecated requirement `bincode (RUSTSEC-2025-0141, https://rustsec.org/advisories/RUSTSEC-2025-0141.html)`featured: not featured: active_users 1 < 11 and new_adopters 1 < 9 and repository route stars 320 (needs 4539), forks 80 (needs 434), contributors 30 (needs 79)listed: listed: no archive, new or featured rule applies
Measurements and sources
Each signal row shows the raw value, its source and the fetch date. The Sources list gathers every distinct source on this page. Movement needs more history.
Sources6 sources
- Description: the crates.io description
- crates.io database dump, fetched
- RustSec advisory database, fetched
- GitHub repository, fetched
- crates.io package, fetched
- GitHub contributors, fetched
Adoption1 active dependents, 1 new dependents in 365 days1 not measured
| Signal | Value | Source | Fetched | Counts |
|---|---|---|---|---|
| Active dependents | 1 | crates.io database dump | Yes | |
| New dependents (365 days) | 1 | crates.io database dump | Yes | |
| Peak active dependents | 1 | crates.io database dump | Yes | |
| Active dependents as a share of the peak | 1 | crates.io database dump | Yes | |
| Binary downloads per release | Not measured | Yes |
MaintenanceLatest human commit: 3 months ago3 not measured
| Signal | Value | Source | Fetched | Counts |
|---|---|---|---|---|
| Latest human commit | 2026-08-05 | GitHub repository | Yes | |
| Latest release | 2026-01-09 | crates.io database dump | Yes | |
| First release | 2024-09-06 | crates.io database dump | Yes | |
| Latest version | 0.2.14 | crates.io database dump | Yes | |
| Days the oldest outside issue waits for a reply | 650 | GitHub repository | Yes | |
| Maintainer replies over 365 days | 2 | GitHub repository | Yes | |
| Repository archived | false | GitHub repository | Yes | |
| Repository gone | false | GitHub repository | Yes | |
| Release commit or manifest in the repo | true | crates.io package | Yes | |
| Published docs | true | crates.io database dump | Yes | |
| Latest release fails cargo check | Not measured | Yes | ||
| Build check date | Not measured | Yes | ||
| Build check toolchain | Not measured | Yes |
SecurityUnpatched vulnerabilities: none
| Signal | Value | Source | Fetched | Counts |
|---|---|---|---|---|
| Unpatched vulnerabilities past the grace window | none | RustSec advisory database | Yes | |
| RustSec unmaintained advisory | none | RustSec advisory database | Yes | |
| Deprecation notice | none | crates.io database dump | Yes | |
| Deprecated requirement | bincode (RUSTSEC-2025-0141, https://rustsec.org/advisories/RUSTSEC-2025-0141.html) | crates.io database dump | Yes |
Distribution19 releases, 2,320 downloads over 30 days5 not measured
| Signal | Value | Source | Fetched | Counts |
|---|---|---|---|---|
| Releases | 19 | crates.io database dump | Yes | |
| Downloads over 30 days | 2320 | crates.io database dump | Yes | |
| Binary downloads over the last 3 releases | Not measured | Yes | ||
| Homebrew installs on request over 365 days | Not measured | Yes | ||
| Repology repository families | Not measured | Yes | ||
| Docker pull growth over 90 days | Not measured | Yes | ||
| Docker pulls at the growth baseline | Not measured | Yes | ||
| Every version a prerelease | false | crates.io database dump | Yes | |
| Every version 0.0.x | false | crates.io database dump | Yes | |
| Every version yanked | false | crates.io database dump | Yes | |
| Crate deleted from crates.io | false | crates.io database dump | Yes |
Repository320 stars, 80 forks, 30 contributors, 249 commits. Stars alone never qualify a project.
| Signal | Value | Source | Fetched | Counts |
|---|---|---|---|---|
| GitHub stars | 320 | GitHub repository | Yes — one part of the repository route | |
| GitHub forks | 80 | GitHub repository | Yes — one part of the repository route | |
| Contributors with a GitHub account | 30 | GitHub contributors | Yes — one part of the repository route | |
| Commits on the default branch | 249 | GitHub repository | No | |
| Repository's main crate left out of the entry | none | crates.io database dump | Yes |
Facts that never count
| Signal | Value | Source | Fetched | Counts |
|---|---|---|---|---|
| License | Apache-2.0 | crates.io database dump | No | |
| Runs on, from listed crates and their direct dependencies | GPU support unknown | crates.io database dump | No | |
| What shows each backend | no dependency or feature matches a backend row | crates.io database dump | No | |
| Native code, from listed crates and their dependencies | No native code found | crates.io database dump | No | |
| Python bindings, from direct dependencies of listed crates | Has Python bindings: outlines-core needs Python only with feature python-bindings | crates.io database dump | No | |
| Crates that depend on a listed crate directly | 1 | crates.io database dump | No |
Corrections and review history
No correction applies to this entry.
Judgments
A judgment enters only through an approved issue and a merged pull request.
No judgment applies to this entry.