Skip to content
Proyek

Tentang

An open-source inference engine for AI functions in SQL

Data dan analisis

Cara angka ini diukur

211 bintang23 Fork +1 dalam 24 jam

Pertumbuhan bintang terukur

dalam 24 jam
+1
dalam 7 hari
+14
dalam 15 hari
+18
dalam 1 bulan
Mengumpulkan riwayat

Perubahan bersih pada periode yang tumpang tindih, bukan total harian. Pengukuran yang belum tersedia dibiarkan kosong. Bintang menunjukkan perhatian, bukan kualitas.

README.md

Asli

Quail logo

Quail

A fast engine for AI functions in SQL
from the Full Stack Data Lab at CMU

PyPI crates.io Docs License: MIT

Quail runs SQL with AI functions. An AI function, such as AI.IF, sends a row's text to a model and returns the model's answer. Quail is an Apache DataFusion extension: we use DataFusion to parse, plan, and run the rest of the SQL.

Documentation | Quickstart | QUAIL-B | When to use Quail

Install

Quail needs Python 3.12 and a supported CUDA GPU.

uv pip install quail-engine

The package is quail-engine, and you import it as quail. Install from source to run the code on main, which can be ahead of the last release.

Example

The query below keeps the reviews that discuss the ending, and labels each one as praise or a complaint. It runs Qwen3 4B on one H100:

import pyarrow as pa
import quail

reviews = pa.table({
    "id": ["r1", "r2", "r3"],
    "body": [
        "The ending was perfect and the cast was great.",
        "Too long, and the ending made no sense.",
        "Great music, but I want my money back.",
    ],
})
config = quail.EngineConfig(model="qwen3-4b-fp8", device="h100-sxm")
with quail.Session(config=config) as session:
    session.register("reviews", quail.DocumentProvider.from_table(reviews, id_col="id"))
    result = session.sql("""
        SELECT r.id, AI.CLASSIFY(r.body, ['praise', 'complaint']) AS kind
        FROM reviews r
        WHERE AI.IF(PROMPT('Does the review discuss the ending? {0}', r.body))
    """).collect()
    print(result)

AI.IF keeps a review when the model answers yes, and AI.CLASSIFY returns one of the two labels. Quail reads each review once for both functions, and classifies only the reviews that AI.IF keeps.

AI functions

Function Returns
AI.IF TRUE when the model answers yes; use it in a filter or a join
AI.SCORE A number from 0 to 1; a higher number is a stronger yes
AI.CLASSIFY The one label the model chooses from your list
AI.EXTRACT Each question's answer, as text copied from the document
AI.EXTRACT_SPAN The position of each AI.EXTRACT answer in the document
AI.MAP Open-ended text: the model's answer to your instruction, up to a token limit
AI.SAE_FEATURES The model's strongest internal features for the prompt

The SQL reference describes each function. The model decides which functions you can use; Supported models and GPUs lists the models and the GPU each one needs. They include Qwen3, Qwen3.5 (4B, 9B, and 27B), Qwen3.6, Qwen3.8, and LFM2, and Base Labs' decision models mammoth-1 and elephant-1. mammoth-1 and elephant-1 are fine-tunes of Qwen3.5 27B and 9B, and run AI.IF filters, AI.SCORE, and AI.CLASSIFY on H100 and B200.

Quail Server

Quail Server runs your queries on a remote GPU. Start quail-server on the GPU machine, and pass its address as endpoint when you create the session. The server keeps a submitted query running after the client disconnects.

Rust

A Rust program adds the quail-engine crate and calls quail::Session. A program with its own DataFusion session adds Quail's AI functions to the session. Use Quail from Rust shows both.

Contributing

Report a bug on GitHub. Follow the developer guide to contribute to Quail; the guide says how to build from source and which checks to run.

Jelajahi proyek terkait

Memuat…