To Classify, Try a Trie Tree: Quail's constrained decoding is ~1.8x faster than vLLM

sh_reya · x · 2026-10-13

Shreya Shankar and Charles Frye (Full Stack Data Lab) explain how Quail, their AI-SQL execution engine, runs AI.CLASSIFY efficiently. Free-form LLM generation for classification is wasteful and can yield invalid labels (as in BigQuery/Snowflake's classify functions).

Since labels are known up front, Quail stores them in a trie, constrains decoding to trie paths, stops as soon as one label remains, and packs the few decode steps into the same forward passes as other documents' prefill to keep the GPU busy.

The post covers three execution strategies (greedy generation, scoring all labels at once, per-letter scoring), how Quail estimates and picks the cheapest one, and an aside on decision models. On 12 classification queries, Quail is 1.8x faster than a vLLM baseline. Project is open source.

Related event: Quail Speeds Up LLM Classification 1.8x with Trie-Constrained Decoding(4 posts)→

Original post →

More from Infra

Infra channel →