dais-labo/flock

Beyond Quacking: Deep Integration of Language Models and RAG into DuckDB (VLDB Demo 2025)

What is Flock?

Flock is an extension for DuckDB, a database system. It lets you run AI-powered analysis directly inside your database queries using plain SQL — no separate AI pipeline needed.

Think of it as adding a "semantic brain" to your database: alongside normal data operations (filtering, aggregating, joining), you can now ask the database to generate text, classify rows, summarize content, create embeddings, and more — all in the same query language you already use.

The problem it solves

Modern data analysis often mixes two very different worlds:

  • Structured data — tidy tables of numbers and text (e.g., sales records, product names).
  • Unstructured data — free-form text, images, audio, which traditionally require separate AI tooling.

Normally, you'd have to glue together a database with external AI services, moving data back and forth. Flock removes that friction by embedding the AI capabilities inside DuckDB, so you can combine analytics and semantic analysis in one declarative SQL query.

How it works

Flock connects DuckDB to Large Language Models (LLMs) — the technology behind tools like ChatGPT — and supports RAG (Retrieval-Augmented Generation) pipelines, a technique that lets an LLM answer questions using your own data as context.

You can plug in any of several AI providers:

  • OpenAI
  • Azure (Microsoft's cloud version of OpenAI)
  • Ollama (a local, self-hosted option)
  • Anthropic/Claude
  • TypeSafe/Jev

You just need API credentials for at least one of them.

Key features

  • Declarative SQL interface — run text generation, classification, summarization, filtering, and embedding generation using SQL queries.
  • End-to-end RAG pipelines — retrieval and augmentation workflows built in.
  • Map and Reduce functions — combine semantic tasks with data analytics directly in DuckDB.
  • Multimodal support — handle text, images, and audio (via transcription) in SQL.
  • LLM observability — built-in metrics for token usage, latency, and call counts, so you can monitor cost and performance.
  • Browser support — works in the browser via DuckDB-WASM, enabling client-side analytics without a server.

A concrete example

Here's a query from the README that generates product descriptions:

SELECT llm_complete(
            { 'model_name': 'summarizer'},
            { 'prompt_name': 'description-generation', 'context_columns': [{ 'data': product_name }]}
       ) AS product_description
  FROM UNNEST(['Wireless Headphones', 'Gaming Laptop', 'Smart Watch']) AS t(product_name);

This takes a list of product names and asks an LLM to write a description for each — all inside a standard SQL query.

Installation

Two options:

Option 1 — Community extension (recommended):

INSTALL flock FROM community;
LOAD flock;

Option 2 — Build from source:

Clone the repo with submodules and run the interactive build script:

git clone --recursive https://github.com/dais-labo/flock.git
cd flock
./scripts/build_and_run.sh

The script handles prerequisites (CMake, C++ compiler, build tools) and launches DuckDB with Flock ready to use.

Requirements: DuckDB version 2.0.0 or later, and credentials for at least one AI provider. Works on Linux, macOS, and Windows.

Project status

  • License: MIT
  • Team: Developed by the Data & AI Systems Laboratory (DAIS Lab) at Polytechnique Montréal.
  • Published research: The project is described in a peer-reviewed paper in the Proceedings of the VLDB Endowment (2025), titled "Beyond Quacking: Deep Integration of Language Models and RAG into DuckDB."
  • Roadmap: Upcoming features are tracked in a GitHub issue (#39).

Bottom line

Flock is a bridge between traditional database analytics and modern AI. If you already use DuckDB and want to add LLM-powered capabilities without leaving your SQL workflow, Flock lets you do exactly that — with multiple provider options, multimodal support, and built-in cost monitoring.

Related

  • Project
  • Dispatch
  • Project
  • Project
  • Project