Zero-shot tabular machine learning inside DuckDB — classification and regression via Google's TabFM foundation model on ONNX Runtime, no training loop
Installing and Loading
INSTALL anofox_tabfm FROM community;
LOAD anofox_tabfm;
Example
-- Enable Google's license gate and download the weight-free model once.
-- The extension ships only the computation graph; you fetch the weights
-- yourself from Hugging Face under Google's non-commercial license.
INSTALL httpfs; LOAD httpfs; -- weights are fetched over HTTPS
SET anofox_tabfm_accept_hf_license = true; -- non-commercial, no redistribution
CALL tabfm_download('classification'); -- ~6.6 GB, cached under ~/.cache/anofox-tabfm
-- Zero-shot classification: the model reads labelled rows as in-context
-- examples and predicts the unlabelled ones — no training step.
CREATE TABLE history AS SELECT * FROM VALUES
(25, 40000, true), (52, 90000, false), (31, 55000, true), (44, 62000, false)
AS t(age, income, churned);
CREATE TABLE prospects AS SELECT * FROM VALUES
(29, 48000), (60, 120000) AS t(age, income);
SELECT * FROM tabfm_classify('history', 'churned', test := 'prospects');
About anofox_tabfm
anofox_tabfm embeds Google's TabFM tabular foundation model — a TabPFN-style in-context learner — into DuckDB, so tabular classification and regression become a single SQL statement. There is no training loop, no Python, and no MLOps: the model reads your labelled rows as context and predicts the rest.
Inference runs on ONNX Runtime, statically linked into the extension (CPU execution provider). CUDA and ROCm/MIGraphX flavors exist in the source tree for self-builds; this community build ships the portable CPU flavor.
License / weights
No Google model weights are distributed with this extension — it bundles only a
weight-free computation graph. You download the weights yourself from Hugging
Face after accepting Google's license
(SET anofox_tabfm_accept_hf_license = true; CALL tabfm_download(...)). The
weights (~6.6 GB for classification) are cached locally under
~/.cache/anofox-tabfm and reused across sessions.
Surface
tabfm_classify/tabfm_regress— zero-shot predict over a test settabfm_predict,tabfm_predict_by,tabfm_predict_agg,tabfm_predict_wintabfm_download/tabfm_models/tabfm_load/tabfm_unload/tabfm_removetabfm_devices— discover CPU/GPU execution providersSET anofox_tabfm_*settings (license gate, cache dir, threads, device, tracing)
Full function names are anofox_tabfm_* with short tabfm_* aliases. See the
project repository for the full
SQL API and examples.
Added Functions
| function_name | function_type | description | comment | examples |
|---|---|---|---|---|
| __anofox_tabfm_predict_agg | aggregate | NULL | NULL | |
| __anofox_tabfm_predict_win | aggregate | NULL | NULL | |
| anofox_tabfm_classify | table_macro | Zero-shot tabular classification with the TabFM foundation model. Uses the labelled rows of data as in-context examples to score the rows whose target is NULL (single-relation form) or every row of the test relation (train/test form). Returns one row per scored row with yhat, yhat_score, is_training and (detail mode) a proba MAP. Optional features restricts the feature columns; opts is a MAP of options (seed, softmax_temperature, output_mode, …). |
NULL | [SELECT age, plan, yhat, yhat_score FROM tabfm_classify('customers', 'churned') WHERE churned IS NULL;] |
| anofox_tabfm_devices | table | List the inference devices this build can see (device_id, ep, name, arch, vram, driver, usable). The cpu row always exists; GPU rows appear only in the matching flavor (cuda/rocm) and report usable=false when a device is present but unsupported. | NULL | [SELECT * FROM tabfm_devices();] |
| anofox_tabfm_download | table | Download the TabFM model weights for a task ('classification' or 'regression') from Hugging Face into the local cache. Requires SET anofox_tabfm_accept_hf_license = true. Returns one row per file (file, url, bytes, status). | NULL | [CALL tabfm_download('classification');] |
| anofox_tabfm_gpu_precompile | table | Warm the GPU path for a task by compiling the model for a shape bucket ahead of the first predict (on ROCm this builds and caches the .mxr program; a no-op cost on CPU/CUDA). Returns task, rows, features, device, status. | NULL | [CALL tabfm_gpu_precompile('classification', 1000, 50);] |
| anofox_tabfm_load | table | Eagerly load a downloaded TabFM model for a task into memory so the first predict is warm (otherwise the model loads lazily on first use). | NULL | [CALL tabfm_load('classification');] |
| anofox_tabfm_models | table | List the TabFM models known to the local cache (model, task, revision, path, bytes, loaded, license). | NULL | [SELECT * FROM tabfm_models();] |
| anofox_tabfm_regress | table_macro | Zero-shot tabular regression with the TabFM foundation model. Uses the rows of data with a known numeric target as in-context examples to predict the target for rows where it is NULL (single-relation form) or every row of the test relation (train/test form). Returns one row per scored row with yhat (yhat_score is NULL for regression). Optional features restricts the feature columns; opts is a MAP of options. |
NULL | [SELECT * FROM tabfm_regress('sold_homes', 'price', test := 'listings');] |
| anofox_tabfm_remove | table | Delete a downloaded TabFM model's weights from the local cache (by task, optionally a specific revision). | NULL | [CALL tabfm_remove('classification');] |
| anofox_tabfm_unload | table | Unload a loaded TabFM model from memory (all models if no task is given), freeing its RAM/VRAM. | NULL | [CALL tabfm_unload('classification');] |
| tabfm_classify | table_macro | Zero-shot tabular classification with the TabFM foundation model. Uses the labelled rows of data as in-context examples to score the rows whose target is NULL (single-relation form) or every row of the test relation (train/test form). Returns one row per scored row with yhat, yhat_score, is_training and (detail mode) a proba MAP. Optional features restricts the feature columns; opts is a MAP of options (seed, softmax_temperature, output_mode, …). |
NULL | [SELECT age, plan, yhat, yhat_score FROM tabfm_classify('customers', 'churned') WHERE churned IS NULL;] |
| tabfm_devices | table | List the inference devices this build can see (device_id, ep, name, arch, vram, driver, usable). The cpu row always exists; GPU rows appear only in the matching flavor (cuda/rocm) and report usable=false when a device is present but unsupported. | NULL | [SELECT * FROM tabfm_devices();] |
| tabfm_download | table | Download the TabFM model weights for a task ('classification' or 'regression') from Hugging Face into the local cache. Requires SET anofox_tabfm_accept_hf_license = true. Returns one row per file (file, url, bytes, status). | NULL | [CALL tabfm_download('classification');] |
| tabfm_gpu_precompile | table | Warm the GPU path for a task by compiling the model for a shape bucket ahead of the first predict (on ROCm this builds and caches the .mxr program; a no-op cost on CPU/CUDA). Returns task, rows, features, device, status. | NULL | [CALL tabfm_gpu_precompile('classification', 1000, 50);] |
| tabfm_load | table | Eagerly load a downloaded TabFM model for a task into memory so the first predict is warm (otherwise the model loads lazily on first use). | NULL | [CALL tabfm_load('classification');] |
| tabfm_models | table | List the TabFM models known to the local cache (model, task, revision, path, bytes, loaded, license). | NULL | [SELECT * FROM tabfm_models();] |
| tabfm_regress | table_macro | Zero-shot tabular regression with the TabFM foundation model. Uses the rows of data with a known numeric target as in-context examples to predict the target for rows where it is NULL (single-relation form) or every row of the test relation (train/test form). Returns one row per scored row with yhat (yhat_score is NULL for regression). Optional features restricts the feature columns; opts is a MAP of options. |
NULL | [SELECT * FROM tabfm_regress('sold_homes', 'price', test := 'listings');] |
| tabfm_remove | table | Delete a downloaded TabFM model's weights from the local cache (by task, optionally a specific revision). | NULL | [CALL tabfm_remove('classification');] |
| tabfm_unload | table | Unload a loaded TabFM model from memory (all models if no task is given), freeing its RAM/VRAM. | NULL | [CALL tabfm_unload('classification');] |
Overloaded Functions
This extension does not add any function overloads.
Added Types
This extension does not add any types.
Added Settings
| name | description | input_type | scope | aliases |
|---|---|---|---|---|
| anofox_tabfm_accept_hf_license | Accept the upstream model license (tabfm-non-commercial-v1.0: non-commercial use, no redistribution). Downloads of Google-licensed weights fail without this. | BOOLEAN | GLOBAL | [] |
| anofox_tabfm_cache_dir | Weight cache root directory (default ~/.cache/anofox-tabfm) | VARCHAR | GLOBAL | [] |
| anofox_tabfm_cpu_prepack | Enable ONNX Runtime weight prepacking on the CPU EP: faster matmuls at ~+16% resident memory. | BOOLEAN | GLOBAL | [] |
| anofox_tabfm_device | Execution device: auto|cpu|cuda|rocm|coreml ('migraphx' alias). Each flavor errors helpfully on devices it does not carry. | VARCHAR | GLOBAL | [] |
| anofox_tabfm_ep_path | Directory with ONNX Runtime provider / plugin-EP shared libraries | VARCHAR | GLOBAL | [] |
| anofox_tabfm_gpu_precision | MIGraphX compile precision on the ROCm GPU: bf16|fp16|fp32. bf16 (default) runs ~2x faster than fp32 on RDNA4 and halves VRAM/.mxr, keeping fp32's exponent range; fp32 is the accuracy reference. | VARCHAR | GLOBAL | [] |
| anofox_tabfm_max_features | Maximum feature columns per predict call | BIGINT | GLOBAL | [] |
| anofox_tabfm_max_rows | Maximum rows per predict call or group | BIGINT | GLOBAL | [] |
| anofox_tabfm_model_manifest | Path to an extra model manifest JSON (pluggable models, CI fixture) | VARCHAR | GLOBAL | [] |
| anofox_tabfm_mxr_source | Directory holding precompiled MIGraphX .mxr programs (offline/CI/shared cache). Before compiling a shape-bucket (~27 min on ROCm), a matching ' |
VARCHAR | GLOBAL | [] |
| anofox_tabfm_threads | ONNX Runtime intra-op thread count for CPU inference | BIGINT | GLOBAL | [] |
| anofox_tabfm_trace_level | Diagnostic verbosity: error|warn|info|debug|trace | VARCHAR | GLOBAL | [] |
| anofox_telemetry_enabled | Enable or disable anonymous usage telemetry | BOOLEAN | GLOBAL | [] |
| anofox_telemetry_key | PostHog API key for telemetry | VARCHAR | GLOBAL | [] |