Open source project · Linux CLI

askmdb Ask your MongoDB. In plain language.

You ask. It writes the query, checks it and only reads.

askmdb turns a question in English or Spanish into a MongoDB aggregate pipeline. It explains it, deterministic code checks that it only reads, and it runs only if you confirm. Everything happens on your machine: own models from 0.8B to 9B fine-tuned for this task, inside a native C++ binary with llama.cpp and the official MongoDB driver, on the CPU or, through Vulkan, on the GPU.

  • Read-only, enforced in code
  • CPU or GPU (Vulkan)
  • No account or API key
  • English and Spanish
  • MongoDB 5.0+ and Atlas
  • One 57 MB binary
askmdb — real sessions 2.1 s · desktop CPU
  1. ~$ askmdb "How many orders were cancelled last month?"

    db.orders.aggregate([

    { $match: { $expr: { $and: [{ $gte: ["$created_at", { $dateSubtract: { startDate: { $dateTrunc: { date: "$$NOW", unit: "month" } }, unit: "month", amount: 1 } }] }, { $lt: ["$created_at", { $dateTrunc: { date: "$$NOW", unit: "month" } }] }] }, status: "cancelled" } },

    { $count: "n" }

    ])

    Counts the cancelled orders created in the previous calendar month.

    read only Run it? [Y/n/c(opy)] y

    n24
  2. ~$ askmdb "Revenue per month this year"

    db.orders.aggregate([

    { $match: { $expr: { $gte: ["$created_at", { $dateTrunc: { date: "$$NOW", unit: "year" } }] } } },

    { $group: { _id: { $dateTrunc: { date: "$created_at", unit: "month" } }, total: { $sum: "$total" } } },

    { $sort: { _id: 1 } }

    ])

    Sums the order totals for each month of the current year.

    read only Run it? [Y/n/c(opy)] y

    _id total2026-05-01T00:00:00Z 4,004.002026-06-01T00:00:00Z 10,098.002026-07-01T00:00:00Z 13,625.002026-08-01T00:00:00Z 20,815.002026-09-01T00:00:00Z 27,328.002026-10-01T00:00:00Z 22,910.00
  3. ~$ askmdb "Show the name and country of the 5 customers who spent the most"

    db.orders.aggregate([

    { $group: { _id: "$customer_id", total: { $sum: "$total" } } },

    { $sort: { total: -1 } },

    { $limit: 5 },

    { $lookup: { from: "customers", localField: "_id", foreignField: "_id", as: "customer" } },

    { $unwind: "$customer" },

    { $project: { _id: 0, name: "$customer.name", country: "$customer.country", total: 1 } }

    ])

    Shows the name and country of the 5 customers who spent the most.

    warning

    · Joins collections and can be expensive: $lookup

    Run it? [y/N/c(opy)] y

    total name country5,680.00 Hugo Larkspur Japan5,067.00 Clara Fairbairn Japan4,851.00 Leo Wexley United Kingdom4,360.00 Mia Thistle France4,216.00 Theo Corrigan France
  4. ~$ askmdb "Products with less than 10 units in stock"

    db.products.aggregate([

    { $match: { stock: { $lt: 10 } } }

    ])

    Lists the products with fewer than 10 units in stock.

    read only Run it? [Y/n/c(opy)] y

    _id name category price stockP005 Ember Cast Pan kitchen 64.00 2P008 Pulse Yoga Mat sports 39.00 1
  5. ~$ askmdb "Average order value by customer tier"

    db.orders.aggregate([

    { $lookup: { from: "customers", localField: "customer_id", foreignField: "_id", as: "customer" } },

    { $unwind: "$customer" },

    { $group: { _id: "$customer.tier", average: { $avg: "$total" } } }

    ])

    Averages the order total for each customer tier.

    warning

    · Joins collections and can be expensive: $lookup

    Run it? [y/N/c(opy)] y

    _id averagegold 218.29platinum 170.12standard 205.04
  6. ~$ askmdb "Delete the cancelled orders"

    I can't: askmdb only reads data: it cannot delete documents.

  7. ~$ askmdb "Which products are profitable?"

    I don't know: The schema has no data about profitability.

By the numbers

Accurate on GPU, light on CPU

Measured on 500 test questions, over databases the training never saw. An answer counts as right when its pipeline, actually run, returns the same as the reference one: no judges.

  • 91.6 %

    accuracy on 500 questions

    askmdb-9b (LoRA): 458 of 500, running every query

  • 83.6 %

    with no GPU, from a 529 MB model

    askmdb-0.8b: 418 of 500; the default model, on the CPU

  • + 35.8  pts

    of askmdb-0.8b over the best untuned model

    Qwen3.5-9B stays at 47.8% with a file 10.7 times larger

  • 1.18  s

    median per question on the CPU

    askmdb-0.8b, one process per question; p90 of 1.79 s

Test of 500 questions over databases the training never saw, scored by running each query, no judges; every model in Q4_K_M. Speed: reference desktop with a 16 GB GPU, median with the schema already cached.

In action

Real, unedited recordings

No mock-ups: this is askmdb against a sample database, exactly as you will see it in your terminal. On the CPU with askmdb-0.8b and, on the GPU, with askmdb-4b.

Question, pipeline, result

Relative dates, a monthly grouping and a $lookup that asks before running. askmdb-0.8b on the CPU.

In Spanish

The interface and the explanations, in the language of the question.

Refusal, doubt and block

An honest "I can't", an "I don't know" and a hidden $out that never runs.

On the GPU

It detects the GPU through Vulkan and answers with the more accurate askmdb-4b.

For scripts

Suggest mode, JSON output and a dedicated exit code for anything blocked.

How it works

The model proposes. The code decides.

Each piece has a single job. The model only translates; that the query only reads is guaranteed by deterministic code with hundreds of tests, independent of the model.

One question, end to end The model only translates; code decides whether it runs, and blocked pipelines never run

Everything happens on your machine: only the query goes out, to your MongoDB

You

Question

in English or Spanish

The model translates

Schema sampling

200 documents per collection, block of ≤ 4,500 bytes, cached

Prompt

instructions + schema; the prefix state is cached on disk

Local model

llama.cpp inside the binary; strict JSON: {type, collection, pipeline, explanation}

invalid JSON, refusal or "I don't know" → nothing runs

Code decides and runs

Verifier

C++ rules on the exact BSON

read warning blocked

blocked → the reason is shown, exit code 3

Mode

suggest · confirm · auto

MongoDB aggregate

maxTimeMS 10 s, allowDiskUse false, ≤ 50 rows

Result

table or JSON (--json)

  1. Reads your schema

    It samples 200 documents per collection and derives fields, types and frequent values, so it writes "Madrid" when that is what your data says. It never sees the connection string or the credentials.

  2. Translates locally

    llama.cpp is linked into the binary: no server, no port, no Python. The model answers with strict JSON; anything else is rejected and nothing runs.

  3. Checks it only reads

    C++ rules walk the exact BSON that would be sent, sub-pipelines included. Anything that writes, administers or is not understood is blocked and never runs.

  4. You decide

    Run, cancel or copy the query in mongosh syntax. Always with a time limit, no disk use and a row cap.

Safe by design

It only reads. Not because the model says so.

A tool that sends queries to your database has to be careful. That is why the level is never decided by the model: a deterministic verifier decides it, on the exact pipeline that would run.

  • askmdb "How many orders were cancelled last month?"

    db.orders.aggregate([{ $match: { $expr: { $and: [{ $gte: ["$created_at", { $dateSubtract: { startDate: { $dateTrunc: { date: "$$NOW", unit: "month" } }, unit: "month", amount: 1 } }] },{ $lt: ["$created_at", { $dateTrunc: { date: "$$NOW", unit: "month" } }] } ] },status: "cancelled" } },{ $count: "n" }])

    read only

    Known read stages and operators, on collections of the schema. Runs after a plain Enter.

  • askmdb "Average order value by customer tier"

    db.orders.aggregate([{ $lookup: { from: "customers", localField: "customer_id", foreignField: "_id", as: "customer" } },{ $unwind: "$customer" },{ $group: { _id: "$customer.tier", average: { $avg: "$total" } } }])

    warning · Joins collections and can be expensive: $lookup

    It reads, but may be expensive or surprising. It never runs without an explicit "y"; Enter means no.

  • # A hand-written pipeline with a $out hidden inside a $facet

    [{ $facet: {stats: [{ $count: "n" }],copy: [{ $out: "orders_copy" }]} }]

    blocked · Stage that writes to the database: $out

    It writes, administers, runs JavaScript or is not understood. The reason is shown and it never runs, in any mode.

And when it shouldn't answer, it doesn't

  • askmdb "Delete the cancelled orders"

    I can't: askmdb only reads data: it cannot delete documents.

    refusal Anything that asks to change data is refused, with a clear reason.

  • askmdb "Which products are profitable?"

    I don't know: The schema has no data about profitability.

    doubt When the answer is not in your data, it says so instead of guessing.

Three modes, your choice

  • mode = suggest

    Shows the pipeline and never runs it.

  • mode = confirm default

    Asks before running. This is the default.

  • mode = auto

    Runs read-only pipelines directly; asks for everything else.

And always with limits

  • aggregate only

    The only MongoDB operation in the code, and a test checks it.

  • maxTimeMS 10000

    The server stops the query if it takes longer.

  • allowDiskUse: false

    No query writes temporary files on the server.

  • 50 rows

    A row cap, configurable up to 1,000.

The verifier is one layer; the real guarantee is your database's access control. Connect askmdb with a read-only user.

Results

91.6% on GPU, 83.6% on CPU with 529 MB

Against 47.8% for the best untuned model I tested, Qwen3.5-9B, even when given worked examples in its prompt that the askmdb models don't need. Every askmdb size, measured the same way: each one clearly beats its own base model, and the smallest beats that 9B by 35.8 points with a file 10.7 times smaller.

Accuracy on 500 questions: each untuned Qwen3.5 against its askmdb Fine-tuning lifts all four sizes, and the smallest one (529 MB) already beats every untuned model, the 9B included
  • Untuned Qwen3.5, same size
  • askmdb (fine-tuned)
  • Goal 80%
  • Best untuned model of any size (47.8%)
View data
Accuracy of each askmdb model against the untuned Qwen3.5 of the same size
Size Untuned Qwen3.5 askmdb Gain Correct, × askmdb GGUF
0.8B 6.6% (33) 83.6% (418) +77.0 pts ×12.7 529 MB
2B 20.4% (102) 86.8% (434) +66.4 pts ×4.3 1.3 GB
4B 37.4% (187) 89.6% (448) +52.2 pts ×2.4 2.7 GB
9B 47.8% (239) 91.6% (458) +43.8 pts ×1.9 5.6 GB

Source: test of 500 questions over 10 databases the training never saw, scored by running each query and comparing its result with the reference, no judges; every model in Q4_K_M; untuned models get worked examples in the prompt.

Test accuracy · 500 questions askmdb-9b (LoRA) reaches 91.6%, 43.8 points above the best untuned model; all four sizes beat the 80% goal
  • askmdb fine-tuned: 0.8B, 2B, 4B and 9B
  • Untuned models
  • 95% confidence interval (Wilson)
  • Goal 80%
  • Best untuned (47.8%)
+43.8 pts
View data
Test accuracy of each model, with its confidence interval and size
Model Correct Accuracy 95% CI GGUF
askmdb-9b (LoRA) 458 / 500 91.6% 88.8–93.7% 5.6 GB (×10.6)
askmdb-4b 448 / 500 89.6% 86.6–92.0% 2.7 GB (×5.1)
askmdb-2b 434 / 500 86.8% 83.6–89.5% 1.3 GB (×2.4)
askmdb-0.8b 418 / 500 83.6% 80.1–86.6% 529 MB (×1.0)
Qwen3.5-9B 239 / 500 47.8% 43.5–52.2% 5.7 GB (×10.7)
Gemma 4 E4B-it 227 / 500 45.4% 41.1–49.8% 5.0 GB (×9.4)
Gemma 4 E2B-it 221 / 500 44.2% 39.9–48.6% 3.1 GB (×5.9)
Qwen3.5-4B 187 / 500 37.4% 33.3–41.7% 2.7 GB (×5.2)
Qwen3.5-2B 102 / 500 20.4% 17.1–24.2% 1.3 GB (×2.4)
Qwen3.5-0.8B 33 / 500 6.6% 4.7–9.1% 533 MB (×1.0)

Source: test of 500 questions over 10 databases the training never saw, scored by running each query and comparing its result with the reference, no judges; every model in Q4_K_M; untuned models get worked examples in the prompt.

Models

Choose: CPU or GPU

One binary and the same safety, with the model that best fits your machine. On the first run, askmdb looks at your GPU and offers one; it always asks before downloading.

  • CPU default and fallback

    askmdb-0.8b

    83.6% correct on the test

    418 of 500 questions best untuned: 47.8%

    Download
    529 MB
    VRAM in use
    none: runs on the CPU
    Per question
    1.2 s reference desktop, 8 CPU threads

    When askmdb picks it

    When there is no dedicated GPU, it has less than 4 GiB of free VRAM, or you say no. And, as a fallback, when the chosen GPU fails or is gone.

    Hugging Face
  • GPU default on GPU

    askmdb-4b

    89.6% correct on the test

    448 of 500 questions best untuned: 47.8%

    Download
    2.7 GB
    VRAM in use
    ≈3.3 GiB
    Per question
    1.3 s reference desktop with a 16 GB GPU

    When askmdb picks it

    A dedicated GPU with 4 GiB or more of free VRAM. With 8 GiB or more it is the default choice (Enter): the fastest on GPU.

    Hugging Face
  • GPU if you choose it

    askmdb-9b

    91.6% correct on the test

    458 of 500 questions best untuned: 47.8%

    Download
    5.6 GB
    VRAM in use
    ≈5.5 GiB
    Per question
    1.8 s reference desktop with a 16 GB GPU

    When askmdb picks it

    A dedicated GPU with 8 GiB or more of free VRAM, if you pick option 2: a little slower, the most accurate.

    Hugging Face

There is one more size, askmdb-2b (86.8%, 1.3 GB), to use directly with llama.cpp. The CLI does not download it, but you can pass it with --model. The 4 models on Hugging Face

First run, or askmdb --detect askmdb picks the model that fits your machine, downloads nothing without asking and, if the GPU fails, answers on the CPU

First run

or askmdb --detect to choose again

Finds the dedicated GPU with the most free VRAM

Through Vulkan. An integrated GPU is never picked on its own.

Free VRAM

≥ 8 GiB

Lets you choose

askmdb-4b (Enter) or askmdb-9b, more accurate

≥ 4 GiB

Offers askmdb-4b

on the GPU

no dedicated GPU or < 4 GiB

askmdb-0.8b on the CPU

the default model

Asks before downloading

529 MB, 2.7 GB or 5.6 GB; checks the SHA-256

Prepares the GPU only once

compiles the shaders on the first run (≈11 s), not on your first question

Safety net. If the chosen GPU fails or is gone, askmdb warns and answers with askmdb-0.8b on the CPU (unless you force --device gpu).

Source: askmdb model selection rules (src/infer/hw.hpp); sizes of the published GGUF files.

Time per question, by phase On the GPU, loading the model in every process weighs the most: 0.76 s of askmdb-4b's 1.34 s. Reading the question and generating the pipeline takes 0.38 s
  • Model load
  • Reading the question
  • Generation
  • Rest
  • Up to p90
  • Goal < 3 s

askmdb starts a new process per question, so the model load is paid every time. On the CPU generation dominates: 0.64 s of askmdb-0.8b's 1.18 s. The first question against a database also reads the whole schema: 3.02 s on the CPU.

View data
Time per question with the schema cached and on the first question, by model and device
Model and device Median p90 1st question (median / p90) Load Question Generation Rest tokens/s
askmdb-0.8b · CPU 1.18 s 1.79 s 3.02 s / 3.60 s 0.38 s 0.10 s 0.64 s 0.06 s 67
askmdb-0.8b · GPU 0.72 s 0.82 s 0.79 s / 0.92 s 0.40 s 0.04 s 0.10 s 0.18 s 442
askmdb-2b · GPU 0.94 s 1.12 s 0.98 s / 1.13 s 0.54 s 0.05 s 0.15 s 0.20 s 288
askmdb-4b · GPU 1.34 s 1.68 s 1.54 s / 1.85 s 0.76 s 0.09 s 0.28 s 0.20 s 162
askmdb-9b · GPU 1.85 s 2.40 s 2.14 s / 2.63 s 1.07 s 0.10 s 0.44 s 0.24 s 104

Source: askmdb on the reference desktop with a 16 GB GPU; 30 questions, a new process per answer and 5 runs per question with the schema cached; wall-time median and p90, excluding MongoDB's own time. Phases are medians and the rest is process start, verification and the like.

VRAM in use, process peak askmdb asks for more free VRAM than it uses: 4 GiB for a model that takes 3.3 GiB, 8 GiB for one of 5.5 GiB. The headroom stays with the desktop
  • VRAM peak
  • Headroom up to the threshold
  • Free VRAM askmdb requires
View data
VRAM peak of each model and the free VRAM askmdb requires before offering it
Model VRAM peak Weights (MiB) Free VRAM required Headroom Use in the CLI
askmdb-0.8b 1.2 GiB 494 — — runs on the CPU by default
askmdb-2b 1.9 GiB — — — not used by the CLI
askmdb-4b 3.3 GiB 2,573 4 GiB 0.7 GiB offered with ≥ 4 GiB free
askmdb-9b 5.5 GiB 4,812 8 GiB 2.5 GiB can be chosen with ≥ 8 GiB free

Source: real process VRAM peak (nvidia-smi, minus the baseline) on the reference desktop with a 16 GB GPU, 4,096-token context; free VRAM thresholds of askmdb's model selection.

Install

Install it in a minute

A single Linux binary for CPU and GPU, with the MongoDB driver and TLS built in. Copy, paste and ask your first question.

You need
  • Linux x86_64 with AVX2
  • glibc 2.29 or later
  • MongoDB 5.0 or later (self-hosted or Atlas)
  • curl or wget, to download the model
  • Optional GPU: dedicated, ≥ 4 GiB free VRAM, driver and Vulkan loader
  • Windows: through WSL 2

Binary recommended

  1. Check the requirements

    A CPU with AVX2 and glibc 2.29 or later: Ubuntu 20.04, Debian 11, Fedora 30 or newer. The last number ldd prints is your glibc version. The third line only matters for the GPU: without the Vulkan loader (libvulkan.so.1), askmdb uses the CPU and tells you what to install.

    grep -q avx2 /proc/cpuinfo && echo "AVX2: OK" || echo "AVX2: not supported"ldd --version | head -n 1/sbin/ldconfig -p | grep -q libvulkan.so.1 && echo "Vulkan loader: OK" || echo "Vulkan loader: missing (CPU only)"
  2. Download, verify and install

    From the latest release on GitHub: a single file of about 57 MB for CPU and GPU. No Python, no mongosh, no root. The check must print "askmdb-linux-x86_64: OK". It installs for your user only, in ~/.local/bin.

    curl -LO https://github.com/manuelgscom/askmdb/releases/latest/download/askmdb-linux-x86_64curl -LO https://github.com/manuelgscom/askmdb/releases/latest/download/SHA256SUMSsha256sum -c --ignore-missing SHA256SUMSchmod +x askmdb-linux-x86_64mkdir -p ~/.local/binmv askmdb-linux-x86_64 ~/.local/bin/askmdb
  3. Check that your shell finds it

    It should print the askmdb version, whether it has TLS and Vulkan, and its models. Getting "askmdb: command not found"? Open a new terminal, or see "Troubleshooting" below.

    askmdb --version
  4. Connect and ask your first question

    The connection string goes in ASKMDB_URI (or --uri, or the configuration); the database, in the URI or with --db. The first time, it looks for a dedicated GPU and its free VRAM: with 8 GiB or more you choose between askmdb-4b (fast, Enter) and askmdb-9b (more accurate); with 4 GiB or more it offers askmdb-4b; otherwise it uses askmdb-0.8b on the CPU. It always asks before downloading the model (529 MB, 2.7 GB or 5.6 GB), checks its SHA-256 and stores it in ~/.local/share/askmdb/models/. After that, the only connection it makes is to your MongoDB.

    export ASKMDB_URI='mongodb://localhost:27017/shop'askmdb "how many orders were cancelled last month?"

Use a read-only user: the verifier is one layer, but the real guarantee is the database's access control. In mongosh, as an administrator:

use shopdb.createUser({ user: "askmdb", pwd: passwordPrompt(), roles: [{ role: "read", db: "shop" }] })

To update, repeat step 2: the downloaded models are kept. To uninstall, including the models, the schema cache, the first-run choice and your configuration:

rm ~/.local/bin/askmdbrm -rf ~/.local/share/askmdb ~/.cache/askmdb ~/.local/state/askmdbrm -rf ~/.config/askmdb

From source

  1. Install the build tools

    git, CMake 3.28 or later, GCC 13 or later and the OpenSSL headers. Run only your distribution's line. Ubuntu 22.04 and Debian 12 ship older versions: there, use the binary.

    # Ubuntu 24.04 or later, Debian 13 or latersudo apt install build-essential cmake git libssl-dev# Fedorasudo dnf install gcc-c++ make cmake git openssl-devel# Arch Linuxsudo pacman -S --needed base-devel cmake git openssl
  2. Get the code

    --recursive also fetches llama.cpp, the MongoDB C driver and doctest, which are git submodules.

    git clone --recursive https://github.com/manuelgscom/askmdb.gitcd askmdb
  3. Build and install

    The default build is CPU-only. llama.cpp and the MongoDB driver are compiled along with askmdb; OpenSSL comes from your distribution. The binary is optimised for the CPU of the machine where you build it.

    cmake -B build -DCMAKE_BUILD_TYPE=Release -DASKMDB_TEST_HOOKS=OFFcmake --build build -j"$(nproc)" --target askmdbinstall -Dm755 build/askmdb ~/.local/bin/askmdbaskmdb --version
  4. Optional: with GPU (Vulkan)

    Instead of step 3, add -DASKMDB_VULKAN=ON to the first command. It needs the Vulkan headers, SPIRV-Headers and the glslc shader compiler, from the Vulkan SDK or your distribution (the apt line is for Debian and Ubuntu). The result still starts without a Vulkan loader, like the release binary.

    # Debian, Ubuntusudo apt install libvulkan-dev spirv-headers glslccmake -B build -DCMAKE_BUILD_TYPE=Release -DASKMDB_TEST_HOOKS=OFF -DASKMDB_VULKAN=ONcmake --build build -j"$(nproc)" --target askmdbinstall -Dm755 build/askmdb ~/.local/bin/askmdbaskmdb --version
  5. Optional: development build and tests

    Unit tests, the verifier cases and end-to-end tests in a pseudo-terminal. They use a fake engine, so they need no model. This build keeps the test hooks: do not use it as your everyday binary.

    cmake -B build-devcmake --build build-dev -j"$(nproc)"ctest --test-dir build-dev

Model only

The 4 published GGUF files (Q4_K_M)
Model Size Test SHA-256 In the CLI
askmdb-0.8b 529 MB 83.6% 856c3502… CPU
askmdb-2b 1.3 GB 86.8% 25b290a7… llama.cpp only
askmdb-4b 2.7 GB 89.6% 2d0a5241… GPU
askmdb-9b 5.6 GB 91.6% bd2c49de… GPU
  1. Download the GGUF and check it

    The example is askmdb-0.8b; for another one, change the name in the path. The SHA-256 must start with the prefix in the table. You can also use it with the CLI: askmdb --model PATH "question", or with the model key of the configuration.

    curl -LO https://huggingface.co/manuelgscom/askmdb-0.8b-GGUF/resolve/main/askmdb-0.8b-1.0.0-Q4_K_M.ggufsha256sum askmdb-0.8b-1.0.0-Q4_K_M.ggufllama-server -m askmdb-0.8b-1.0.0-Q4_K_M.gguf -c 4096 --reasoning off --port 8080
  2. Or let llama-server download it

    With -hf, llama-server fetches it from Hugging Face the first time. -ngl 99 puts every layer on the GPU, with a GPU build of llama.cpp; CPU only, drop it.

    # CPUllama-server -hf manuelgscom/askmdb-0.8b-GGUF:Q4_K_M -c 4096 --reasoning off --port 8080# GPUllama-server -hf manuelgscom/askmdb-4b-GGUF:Q4_K_M -c 4096 --reasoning off -ngl 99 --port 8080
  3. Turn reasoning off

    --reasoning off already does it on the server; with an older llama.cpp build, add this to the body of every request to /v1/chat/completions. Follow the model card's prompt contract to the letter: the schema block and the question. Outside askmdb there is no read-only verifier: add your own review.

    "chat_template_kwargs": {"enable_thinking": false}

Usage

askmdb "average order value by month this year"askmdb --db shop -c orders,customers "customers from Spain with more than 3 orders"# show the pipeline, never run itaskmdb --mode suggest "the 10 most expensive products"# one JSON object, for scriptsaskmdb --json --mode auto "orders per status"# what the model is told about your databaseaskmdb --print-schema# detect the GPU and choose the model againaskmdb --detect
  • y runs
  • n cancels
  • c copies in mongosh syntax

Exit codes

  • 0 ok (also "I can't" and "I don't know")
  • 1 askmdb error
  • 2 usage error
  • 3 blocked for safety
  • 4 MongoDB error

Optional configuration

~/.config/askmdb/config
# suggest | confirm | automode = confirm# auto | en | es (language of the interface)lang = auto# with a password, the file must have mode 0600uri = mongodb://askmdb:secret@db.example.com:27017/shop?authSource=shop# collections given to the model (default: all)collections = orders, customers, products# row cap (1-1000) and server time limit in msmax_rows = 50max_time_ms = 10000# auto | cpu | gpu (auto follows the first-run choice)device = auto

~/.config/askmdb/config, and every key is optional: askmdb never creates or edits it. Command-line options take precedence over the configuration. mongodb+srv:// (Atlas included), TLS and SCRAM work out of the box.

askmdb can be wrong. Always read the pipeline and its explanation before trusting the result.

Troubleshooting

If something doesn't work as expected

The most common stumbles, each with its exact fix.

PATH "askmdb: command not found"

Open a new terminal: most distributions add ~/.local/bin to your PATH at login, but only once the folder exists. If it still isn't found, add it yourself:

echo 'export PATH="$HOME/.local/bin:$PATH"' >> ~/.bashrcsource ~/.bashrc
CPU "Illegal instruction" or "GLIBC_2.29 not found"

The binary needs a CPU with AVX2 and glibc 2.29 or later: Ubuntu 20.04, Debian 11, Fedora 30 or newer. Check both; the last number on the second line is your glibc version:

grep -q avx2 /proc/cpuinfo && echo "AVX2: OK" || echo "AVX2: not supported"ldd --version | head -n 1
connection askmdb won't start with the URI in the configuration

If the uri in the configuration file carries a password, the file must have mode 0600; otherwise askmdb refuses to start. Also avoid --uri with a password: it stays in your shell history. Prefer ASKMDB_URI or the protected file:

chmod 600 ~/.config/askmdb/config
connection Connecting to MongoDB Atlas

mongodb+srv://, TLS and SCRAM work out of the box: the CA certificates are found in the usual places of each distribution, or with tlsCAFile in the URI. Use a user with the read role:

export ASKMDB_URI='mongodb+srv://reader:<password>@cluster0.example.mongodb.net/shop'
schema It doesn't know a field that does exist

The schema comes from a sample of 200 documents per collection and is cached for 7 days: a field found only in older documents may be missing. Sample again and see exactly what the model is told:

askmdb --refresh "…"askmdb --print-schema
schema "Too many collections"

With more than 50 collections, askmdb asks you to choose. Pass the ones that matter with -c or the collections key of the configuration; the model is also more accurate with less noise:

askmdb -c orders,customers "…"
GPU askmdb doesn't use my GPU

The GPU needs to be dedicated, with at least 4 GiB of free VRAM, its driver and the Vulkan loader (libvulkan.so.1). If the loader is missing, askmdb says so and uses the CPU: install your distribution's package and detect again. Integrated GPUs are never chosen.

/sbin/ldconfig -p | grep -q libvulkan.so.1 && echo "Vulkan loader: OK" || echo "Vulkan loader: missing (CPU only)"# Debian, Ubuntusudo apt install libvulkan1# Fedorasudo dnf install vulkan-loader# Arch Linuxsudo pacman -S vulkan-icd-loaderaskmdb --detect
GPU The first run on the GPU is slow

That's expected: the first time, the driver prepares the Vulkan shaders, about 11 s longer, and keeps them in its cache. It happens once per user and driver. After that, on the reference desktop, 1.3 s per question with askmdb-4b and 1.8 s with askmdb-9b.

model Switch models or detect again

askmdb --detect detects the GPU again and asks you. The choice is saved in ~/.local/state/askmdb/choice, and askmdb --version shows it. For a specific GGUF, use --model PATH or the model key of the configuration.

askmdb --detectaskmdb --version
config Always use the CPU

With device = cpu in ~/.config/askmdb/config, every question goes to the CPU and askmdb never touches the GPU.

# ~/.config/askmdb/configdevice = cpu
Windows Using it on Windows

askmdb is for Linux: on Windows, use it inside WSL 2, with the same install steps in your WSL distribution.

llama.cpp Using the models directly with llama.cpp

The 4 GGUF files work with llama-server, on CPU or GPU: see the "Model only" install tab. Always turn reasoning off and follow the model card's prompt contract. Outside askmdb there is no read-only verifier.

llama-server -hf manuelgscom/askmdb-0.8b-GGUF:Q4_K_M -c 4096 --reasoning off --port 8080

Not here? Open an issue on GitHub