🦆 Local-First Semantic Layer for AI-Powered Analytics 🚀
Snowflake Cortex for Local-First Databases.
Run powerful, zero-shot tabular predictions directly in your database with simple SQL.
No data movement, no complex pipelines—just ML-powered insights right where your data lives.
Note: This project is archived as of November 2025 as a complete reference implementation. It demonstrates best practices for building a local-first semantic layer for AI analytics, but it is not under active development.
Imagine running churn predictions on your customer data with a single line of SQL:
-- The entire vision in one line:
SELECT customer_id, predict_churn(*) FROM customers;Mallard makes this a reality by leveraging foundation models that adapt to any tabular schema, enabling zero-shot predictions without the need for model training or complex feature engineering. It's designed for data engineers, BI analysts, and developers who need to integrate ML insights into their workflows with minimal friction.
- 🎯 Zero-Shot Predictions: Use powerful foundation models (TabPFN, FT-Transformer) for classification and regression on any tabular dataset, without training.
- 🤖 Simple SQL Interface: All functionality is exposed through declarative SQL UDFs. If you know SQL, you know Mallard.
- ⚡ High-Performance & Local-First: Built in Rust 🦀 as a DuckDB extension. All processing happens in-database, eliminating data transfer overhead and ensuring privacy.
- 🔮 Automatic Feature Engineering: Mallard introspects your table schema and automatically selects and preprocesses features for inference.
- ✨ Embeddings & Explainability: Generate dense vector embeddings for semantic search and get feature importance explanations for every prediction.
- 📦 ONNX-Native: Load and manage any ONNX-compatible model directly from SQL.
Mallard is built on a modern, high-performance, local-first stack. It integrates directly into DuckDB as an extension.
┌───────────────────┐ ┌────────────────────────┐ ┌──────────────────────┐
│ │ │ │ │ │
│ SQL Interface ├─────►│ Mallard DuckDB Ext. ├─────►│ ONNX Runtime (C-API)│
│ (DuckDB) │ │ (Rust) │ │ │
│ │ │ │ │ │
└───────────────────┘ └──────────┬─────────────┘ └──────────┬───────────┘
│ │
│ │
▼ ▼
┌───────────────────┐ ┌──────────────────────┐
│ │ │ │
│ Schema Introspection & │ Foundation Models │
│ Auto-Preprocessing │ (TabPFN, FT-Transformer) │
│ │ │ │
└───────────────────┘ └──────────────────────┘
Get up and running with Mallard in just a few steps.
Prerequisites:
- Rust (stable toolchain)
- Python 3.9+ (
uvpackage manager recommended) - A C/C++ compiler toolchain
-
Clone the Repository:
git clone https://github.com/sbdk-dev/local-inference.git cd local-inference -
Build the DuckDB Extension:
cd mallard-core cargo build --releaseThe compiled extension will be at
target/release/libmallard_core.so(or.dll/.dylib). -
Run an Example Query: Start DuckDB and load the Mallard extension to run a prediction.
duckdb # Load the extension (use the correct path) D LOAD './mallard-core/target/release/libmallard_core.so'; # Run a zero-shot classification on the Iris dataset D SELECT predict_classification('tabpfn', *) FROM 'data/iris.csv';
Mallard's SQL API is designed to be intuitive and composable.
Get churn predictions for customers, letting Mallard automatically select the relevant features.
SELECT
customer_id,
predict_classification('churn_model', *) AS churn_probability
FROM customers
WHERE churn_probability > 0.8;Create embeddings for semantic search or downstream AI tasks.
ALTER TABLE customers ADD COLUMN embedding FLOAT[256];
UPDATE customers
SET embedding = embed_tabular('customer_encoder', *);Understand why a model made a certain prediction with feature importance scores.
SELECT
customer_id,
predict_classification('churn_model', *) AS churn_prob,
explain_prediction('churn_model', *) AS explanation
FROM customers;This project is archived, so we are not accepting contributions. However, you are welcome to fork the repository and build upon it for your own use cases.
This project is licensed under the MIT License. See the LICENSE file for details.