Introduction
Quail (QUery Aware Inference Layer) is an open-source, extensible query engine for AI functions in SQL. We develop Quail at Full Stack Data Lab at CMU.
You can use AI functions to write instructions in natural language for a language model to evaluate on your data.
For example, imagine a reviews table with a movie review ID in id
and review text in body. The query below returns the IDs of reviews
that discuss the movie's ending:
SELECT r.id
FROM reviews r
WHERE AI.IF(PROMPT('Does this review discuss the ending?\n\n{0}', r.body));The model answers the question for each review. Quail returns the
review ID when the answer is TRUE.
Quail supports AI functions for filtering rows, joining tables,
scoring documents, and assigning classification labels. You can also
use EXISTS and NOT EXISTS in queries. See the
SQL reference for the supported functions.
Quail supports two AI-SQL dialects (Snowflake and BigQuery) and a Python builder API.
Requirements
- Python 3.12
- Qwen3 4B fp8, Qwen3 32B fp8, or DiffusionGemma 26B-A4B fp8 (all models)
- One CUDA GPU per model copy (local, or on Modal)
Get started
Install quail-engine from PyPI:
uv pip install quail-engine