--- warning: DO NOT CHANGE THIS MANUALLY, THIS IS GENERATED BY https://github.com/duckdb/community-extensions repository, check README there title: decision_tune excerpt: | DuckDB Community Extensions Classify rows, route messages and answer yes/no questions in SQL with the DecisionTune 1.0 model, on CPU via ONNX Runtime extension: name: decision_tune description: Classify rows, route messages and answer yes/no questions in SQL with the DecisionTune 1.0 model, on CPU via ONNX Runtime version: '0.1.0' language: C++ build: cmake license: MIT excluded_platforms: "wasm_mvp;wasm_eh;wasm_threads;windows_amd64_mingw;linux_amd64_musl" requires_toolchains: "vcpkg" maintainers: - redox repo: github: altertable-ai/duckdb-decision_tune # DuckDB 2.0 only. There is no v1.5.6 port, so variegata is unset. ref: a473343b7170efb8edbab3866bd122a606112ae8 docs: hello_world: | INSTALL decision_tune FROM community; LOAD decision_tune; -- DecisionTune 1.0 (1.6 GB) is downloaded from Hugging Face and cached on first use. CREATE TABLE tickets AS FROM (VALUES ('Broken mug', 'The order arrived broken. I want my money back.'), ('Double charge', 'I was charged twice this month.') ) t(subject, message); -- Route every ticket and flag refund requests: an answer, its confidence and all probabilities per question. FROM tickets DECIDE ( CHOOSE 'Which team should handle this customer message?' AMONG ( billing 'Billing: charges, refunds, invoices', shipping 'Shipping: delivery, lost or damaged packages', tech 'Tech support: bugs, crashes, login problems') AS team, ASK 'Is the customer asking for a refund or an exchange?' AS refund GIVEN subject, message ); -- The same decisions as functions. SELECT decision_choose(message, 'Which team?', ['billing', 'shipping', 'tech support']).choice, decision_yes_no(message, 'Is the customer asking for a refund?') FROM tickets; extended_description: | **decision_tune** runs [DecisionTune 1.0](https://decisiontune.com/), a 395M-parameter decision model, inside DuckDB. You give it a state, a question and options; it picks an option and gives a probability for each, or gives P(yes) for a yes/no question, in one encoder pass. There is no prompt engineering of an LLM, no Python and no GPU: the network runs on CPU through a statically linked ONNX Runtime. - `FROM t DECIDE (CHOOSE question AMONG (key 'description', ...) AS name, ASK question AS name, ... GIVEN columns)` adds `name`, `name_confidence` and `name_probabilities` (a MAP of option to probability) per question; filter on them with an ordinary WHERE. - `decision_choose(state, question, options)` returns the choice, its confidence and every option's probability; options are a list of texts, or a MAP or STRUCT of key to description. `decision_yes_no(state, question)` returns P(yes). Both also take the clause's words: `decision_choose('Which team?' AMONG (billing, tech) GIVEN subject, message)`. - A STRUCT, MAP or JSON object state is read as `key: value | ...`, the way the reference engine reads a dict. - `decision_tune_models()` lists the model files and whether they are cached. Set `decision_tune_model_path` to use a local copy offline. Send `LOAD decision_tune` and the first `DECIDE` as two statements. A connection that is already open picks up the new syntax when its current query ends. The tokenizer is a C++ port of the Hugging Face one and matches it token for token; the probabilities match onnxruntime in Python to 1e-4. Rows run in parallel on DuckDB's threads and repeated decisions are scored once. The extension is MIT licensed. The DecisionTune 1.0 weights are Apache-2.0. The model's probabilities are not calibrated; do not use it for high-risk decisions about people without independent validation. extension_star_count: 1 extension_star_count_pretty: 1 extension_download_count: null extension_download_count_pretty: n/a image: '/images/community_extensions/social_preview/preview_community_extension_decision_tune.png' layout: community_extension_doc --- ### Compatibility Matrix This table covers all DuckDB releases that have not reached [end-of-life](https://duckdb.org/release_calendar), including LTS releases, and shows the 2 most recent patch releases of each. Older patch releases are not listed, but the extension may be available for them as well.
| Platform | 1.4.4 | 1.4.5 | 1.5.5 | 1.5.6 | 2.0.0 | | :--- | :---: | :---: | :---: | :---: | :---: | | Linux AMD64 | ❌ | ❌ | ❌ | ❌ | ✅ | | Linux ARM64 | ❌ | ❌ | ❌ | ❌ | ✅ | | macOS AMD64 | ❌ | ❌ | ❌ | ❌ | ❌ | | macOS ARM64 | ❌ | ❌ | ❌ | ❌ | ✅ | | Windows AMD64 | ❌ | ❌ | ❌ | ❌ | ✅ | | Windows ARM64 | ❌ | ❌ | ❌ | ❌ | ❌ | | WebAssembly | ❌ | ❌ | ❌ | ❌ | ❌ | ### Installing and Loading ```sql INSTALL {{ page.extension.name }} FROM community; LOAD {{ page.extension.name }}; ``` {% if page.docs.hello_world %} ### Example ```sql {{ page.docs.hello_world }}``` {% endif %} {% if page.docs.extended_description %} ### About {{ page.extension.name }} {{ page.docs.extended_description }} {% endif %} ### Added Functions | function_name | function_type | description | comment | examples | |------------------------|---------------|-------------|---------|----------| | decision_choose | scalar | NULL | NULL | | | decision_tune_models | table | NULL | NULL | | | decision_tune_tokenize | scalar | NULL | NULL | | | decision_tune_version | scalar | NULL | NULL | | | decision_yes_no | scalar | NULL | NULL | | ### 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 | typed_value | |---------------------------|-------------------------------------------------------------------------------------------------------------|------------|--------|---------|--------------------------------------------------------------------------------------------------------| | active_grammar_extensions | The grammar extensions used by the parser. | VARCHAR[] | LOCAL | [] | [shell, decision_tune] | | decision_tune_cache_dir | Directory downloaded DecisionTune files are cached in | VARCHAR | GLOBAL | [] | ~/.duckdb/decision_tune/1.0 | | decision_tune_model_path | Local directory with tokenizer.json and model.onnx to use instead of the download cache (no checksum check) | VARCHAR | GLOBAL | [] | | | decision_tune_model_url | Base URL the DecisionTune files are downloaded from (a Hugging Face resolve URL) | VARCHAR | GLOBAL | [] | https://huggingface.co/decision-tune/decisiontune-1.0/resolve/27056cb08bcf2b3ba1fd9bccb782b4dfd0498e1f | | temp_directory | Set the directory to which temporary files are written. | VARCHAR | GLOBAL | [] | post.db.tmp |