EN
返回档案库

档案库 · AI 与模型 · 产品决策 · 2023–2026

Outlines(.txt):在采样时屏蔽无效令牌,使 LLM 输出结构化

Louf 和 Willard 的 Outlines 通过令牌掩码将 LLM 采样限制在正则表达式/JSON 模式上;2023-08-14 的 Show HN 获得 854 分,仓库达到 15.7k 星。

.txt (dottxt) · Outlines

它在赌什么LLM 的可靠性在采样时获得——屏蔽会破坏正则表达式或 JSON 模式的令牌——而不是通过解析或重试坏输出来获得;开源它,销售 API。已上线

做的是什么生意

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.

起因

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).

经过

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.

结果

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.

背景

Outlines 是一个开源的 Python 库,在生成过程中保证 LLM 输出的结构:它不是要求模型返回 JSON 然后修复或重试,而是限制采样本身,使每个令牌都保持输出针对正则表达式、JSON 模式、Pydantic 模型或上下文无关语法有效。该项目始于 2023 年中期,由 Rémi Louf 和 Brandon T. Willard 发起,他们的背景是概率、关系和符号编程,而不是 LLM 研究,他们说开始只是为了理解文本生成是如何工作的。

创始赌注是可靠性在采样时赢得,而不是之后:将目标正则表达式或模式转换为有限状态机,一次将该机器在语言模型的令牌词汇表上重新派生,然后在每一步用字典查找屏蔽无效令牌。这使引导生成足够快用于生产——接近无约束采样的速度——并保证任何模型(包括小模型)都能产生可解析的输出。该方法写在了《Efficient Guided Generation for Large Language Models》(arXiv 2307.09702,2023 年 7 月第一版)中。

Louf 于 2023-08-14 在 Hacker News 上以“Show HN: LLMs can generate valid JSON 100% of the time”为标题宣布了该库。该帖子获得 854 分和 303 条评论,讨论将令牌屏蔽方法与 Microsoft TypeChat、guidance、LMQL 和 llama.cpp 的语法采样进行了对比。作者认为他们的一次索引比每一步全词汇表屏蔽便宜得多。项目后来从 normal-computing GitHub 组织转移到 dottxt-ai/outlines,因为维护者成立了 .txt (dottxt) 公司。

截至 2026 年,该库仍在积极维护——2026-09-04 快照显示 15.7k 星、868 分叉和 1,325 次提交——README 宣传了涵盖 vLLM 和 Ollama 服务器以及 OpenAI、Gemini 和 Dottxt API 的模型集成,同时将 NVIDIA、Cohere 和 HuggingFace 列为值得信赖的用户。.txt 销售商业层:早期访问结构化生成 API、衡量合规率的模式审计以及企业级库。材料中没有出现资金或收入数字。

这件事要成立,得有什么

  • 具体牵引力:2023-08-14 的 Show HN(项目 37125118)获得 854 分和 303 条评论,到 2026-09-04 仓库达到 15.7k 星和 868 分叉。
  • 该赌注是可证伪的:在采样期间通过屏蔽无效令牌来强制结构,与 TypeChat 式的生成-然后-修复、guidance 式的词汇表循环和 guardrail 拒绝形成对比。
  • 真实的起源弧线:两位非 LLM 研究人员对生成感到好奇,推导出正则到 DFA 的令牌屏蔽,然后推广到 JSON 模式——arXiv 预印本记录了推理过程。
  • 有记录的后续行动:1,325 次提交和从研究仓库到公司 .txt 的转变,提供早期访问 API 和模式审计服务,同时库保持开源。

可借鉴之处

当输出正确性是瓶颈时,将约束移入生成过程内部而不是事后修补结果——并公开技术,让生态系统采用它。

后续进展

截至 2026-09-05,Outlines 仍然活跃并且是 .txt 的核心:仓库显示 15.7k 星、868 分叉和 1,325 次提交,README 仍然宣传早期访问 .txt API 和模式审计,并将 NVIDIA、Cohere、HuggingFace 和 vLLM 列为用户。该库支持跨 vLLM、Ollama、OpenAI、Gemini 和 Dottxt 端点的 JSON/Pydantic、正则和语法输出。没有披露资金、收入或员工人数;记录的弧线是一个研究起源的开源库,成为最受星标的结构化生成工具之一,也是商业 API 的基础。

资料来源

发现哪里写错了?告诉我们。

轮到你了

你刚读完一家。说说你在做什么,看看谁在赌同一件事。

免费账号 · 3 次免费提问 · 不用绑卡

相关案例