The archive · AI & Models · Product decision · 2023–2026
Outlines (.txt): masking invalid tokens at sampling made LLM output structured
Louf and Willard's Outlines constrains LLM sampling to regex/JSON schemas via token masks; the 2023-08-14 Show HN drew 854 points and the repo hit 15.7k stars.
.txt (dottxt) · Outlines
What the business is
An open-source Python library, Outlines, that forces LLM text generation to match a regex, JSON Schema, Pydantic model or grammar by masking invalid tokens during generation, with .txt (dottxt) selling a structured-generation API, schema audits and enterprise tooling on top.
How it started
Rémi Louf and Brandon T. Willard — whose backgrounds were probabilistic, relational and symbolic programming, not LLM research — started Outlines in 2023, a few months before launch, because they wanted to understand how text generation actually works. Their first insight was fast regex-guided generation: a regular expression maps to a deterministic finite automaton, the automaton is re-derived over the model's token vocabulary, and each sampling step masks out symbols that cannot complete a valid match. JSON Schema and Pydantic output followed as, in Louf's words, a small leap, and the pair posted the preprint 'Efficient Guided Generation for Large Language Models' (arXiv 2307.09702, first submitted 2023-07-19).
What happened
On 2023-08-14 Louf posted Show HN 'LLMs can generate valid JSON 100% of the time', which drew 854 points and 303 comments. The thread compared Outlines with Microsoft TypeChat, guidance, LMQL and llama.cpp's grammar sampling; the authors answered that their one-pass index build kept generation nearly as fast as unconstrained sampling, unlike approaches that loop over the full vocabulary each step. The project later moved from the normal-computing GitHub org to dottxt-ai/outlines as the maintainers formed .txt (dottxt), which kept the library open source and began offering an early-access API for structured generation plus an enterprise schema-audit service.
How it ended up
No funding or revenue figures are disclosed in the material. What is verifiable is that Outlines became one of the most-adopted open-source structured-generation libraries (15.7k stars, 868 forks) and is still actively maintained (1,325 commits), while .txt sells the commercial layer on top: an early-access API, schema audits and enterprise-grade libraries.
Background
Outlines is an open-source Python library that guarantees the structure of LLM output during generation: instead of asking a model for JSON and repairing or retrying what comes back, it constrains sampling itself so every token emitted keeps the output valid against a regex, JSON Schema, Pydantic model or context-free grammar. The project was started in mid-2023 by Rémi Louf and Brandon T. Willard, whose backgrounds were probabilistic, relational and symbolic programming rather than LLM research, and who said they began it simply to understand how text generation works.
The founding bet was that reliability is won at sampling time, not after it: convert the target regex or schema into a finite-state machine, re-derive that machine over the language model's token vocabulary in one pass, then mask out invalid tokens at each step with a dictionary lookup. That made guided generation fast enough for production — near the speed of unconstrained sampling — and guaranteed parseable output for any model, including small ones. The approach was written up in 'Efficient Guided Generation for Large Language Models' (arXiv 2307.09702, first version July 2023).
Louf announced the library on Hacker News on 2023-08-14 with the title 'Show HN: LLMs can generate valid JSON 100% of the time'. The post drew 854 points and 303 comments, and the discussion pitted the token-masking approach against Microsoft TypeChat, guidance, LMQL and llama.cpp's grammar sampling. The authors argued their one-pass index was far cheaper than full-vocabulary masking at every step. The project later moved from the normal-computing GitHub org to dottxt-ai/outlines as the maintainers formed the company .txt (dottxt).
As of 2026 the library is still actively maintained — the 2026-09-04 snapshot shows 15.7k stars, 868 forks and 1,325 commits — and the README advertises model integrations spanning vLLM and Ollama servers plus OpenAI, Gemini and Dottxt APIs, while naming NVIDIA, Cohere and HuggingFace among trusted users. .txt sells the commercial layer: an early-access structured-generation API, schema audits that measure compliance rates, and enterprise-grade libraries. No funding or revenue figures appear in the material.
What has to be true
- Concrete traction: the 2023-08-14 Show HN (item 37125118) scored 854 points with 303 comments, and the repository reached 15.7k stars with 868 forks by 2026-09-04.
- The bet is falsifiable: structure imposed during sampling by masking invalid tokens, versus TypeChat-style generate-then-repair, guidance-style vocabulary loops and guardrail rejection.
- Real origin arc: two non-LLM researchers curious about generation derive regex-to-DFA token masking, then generalize to JSON Schema — the arXiv preprint documents the reasoning.
- Documented follow-through: 1,325 commits and a move from a research repo to a company, .txt, with an early-access API and schema-audit service, while the library stayed open source.
What can be applied
When output correctness is the bottleneck, move the constraint inside the generative process instead of patching results afterwards — and publish the technique so the ecosystem adopts it.
Aftermath
As of 2026-09-05 Outlines remains live and central to .txt: the repository shows 15.7k stars, 868 forks and 1,325 commits, and the README still advertises an early-access .txt API with schema audits, naming NVIDIA, Cohere, HuggingFace and vLLM as users. The library supports JSON/Pydantic, regex and grammar output across vLLM, Ollama, OpenAI, Gemini and Dottxt endpoints. No funding, revenue or headcount is disclosed; the documented arc is a research-originated open-source library that became one of the most-starred structured-generation tools and the base of a commercial API.
Sources
- Show HN: LLMs can generate valid JSON 100% of the time
- dottxt-ai/outlines — Structured Outputs (repository, live as of 2026-09-05)
spotted an error? The archive wants to know.
Your turn
You just read one. Describe what you are building, and see who is betting on the same thing.
Free account · 3 free questions · no card