Skip to content

askmdb 1.0.1

Latest

Choose a tag to compare

@manuelgscom manuelgscom released this 29 Oct 21:32

askmdb 1.0.1

Ask your MongoDB in plain language. 100% local. One native binary, for CPU and GPU.

askmdb turns a question in English or Spanish into a MongoDB aggregate pipeline, explains it, checks with deterministic rules that it only reads, and runs it only if you confirm. A small model fine-tuned for this single task runs on your machine, inside the binary, with llama.cpp and the official MongoDB C driver built in. No accounts, no API keys, no telemetry: the only connection it makes is to your own MongoDB.

$ askmdb "top 5 customers by spending this year"

  ❯ db.orders.aggregate([
      { $match: { $expr: { $gte: ["$created_at", { $dateTrunc: { date: "$$NOW", unit: "year" } }] } } },
      { $group: { _id: "$customer_id", total: { $sum: "$total" } } },
      { $sort: { total: -1 } },
      { $limit: 5 }
    ])
    Adds up this year's order totals per customer and shows the top 5.

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

What's new in 1.0.1

A small update of the binary; the models are the same 1.0.0 files, at the same pinned revisions.

  • Download sizes are now shown in decimal megabytes, like everywhere else (the 0.8B model shows as 529 MB; 1.0.0 showed 505 "MB", which were MiB).
  • The message about the missing Vulkan loader names the right Arch package (vulkan-icd-loader).
  • --help explains -c better: without it every collection is used, and above 50 collections you must choose.

Highlights

  • Read-only, decided by code. A deterministic verifier in C++ walks the whole pipeline, sub-pipelines included, and gives it a level: read only, warning (asks, Enter = no) or blocked (never runs, in any mode). Only aggregate is ever called, always with maxTimeMS, allowDiskUse: false and a row cap.
  • Aware of your data. It samples each collection and gives the model its fields, types and frequent values; relative dates ("last month") are resolved by the server with $$NOW. Credentials never reach the model, the errors or the JSON output.
  • Honest when unsure. A request to change data gets "I can't"; a question the schema cannot answer gets "I don't know".
  • Three modes (suggest, confirm, auto), results as a table or as JSON (--json), and the query in mongosh syntax to copy.
  • CPU and GPU in one binary. On the first run askmdb detects a dedicated GPU through Vulkan and offers a larger model if it fits; otherwise it uses the CPU. The binary does not link the Vulkan library, so it starts on any machine.
  • Connects anywhere MongoDB runs: mongodb:// and mongodb+srv:// (MongoDB Atlas included), TLS with the system's CA certificates, SCRAM authentication.

Install

curl -LO https://github.com/manuelgscom/askmdb/releases/download/v1.0.1/askmdb-linux-x86_64
curl -LO https://github.com/manuelgscom/askmdb/releases/download/v1.0.1/SHA256SUMS
sha256sum -c --ignore-missing SHA256SUMS     # must print: askmdb-linux-x86_64: OK
chmod +x askmdb-linux-x86_64 && mkdir -p ~/.local/bin && mv askmdb-linux-x86_64 ~/.local/bin/askmdb
export ASKMDB_URI='mongodb://localhost:27017/shop'
askmdb "how many orders were cancelled last month?"

If you get askmdb: command not found, open a new terminal, or add ~/.local/bin to your PATH. Connect with a read-only database user: the verifier is one layer, the database's access control is the real guarantee. The README has step-by-step instructions, the configuration file and how to build from source.

Requirements

  • Linux on x86_64 with AVX2 (on Windows, through WSL 2).
  • glibc 2.29 or later.
  • curl or wget for the first model download.
  • MongoDB 5.0 or later.
  • For the GPU (optional): a dedicated GPU with at least 4 GiB of free VRAM, its driver and the Vulkan loader libvulkan.so.1 (libvulkan1 on Debian and Ubuntu, vulkan-loader on Fedora, vulkan-icd-loader on Arch). If it is missing, askmdb uses the CPU and tells you what to install.

The models

Four fine-tunes of Qwen3.5, quantized to Q4_K_M and published on Hugging Face in the askmdb collection. The CLI uses three of them:

first run ─► dedicated GPU, free VRAM?
               ├─ 8 GiB or more ─► choose: 1) askmdb-4b (Enter)  2) askmdb-9b  n) CPU
               ├─ 4 GiB or more ─► offer askmdb-4b                  [Y/n]
               └─ less, or no GPU ─► offer askmdb-0.8b on the CPU   [Y/n]
Model Used by askmdb Download Test accuracy Next question / first against a database (reference desktop)
askmdb-0.8b CPU (default) 529 MB 83.6 % (418/500) 1.18 s / 3.02 s on the CPU
askmdb-2b not used; for llama.cpp directly 1.3 GB 86.8 % (434/500) —
askmdb-4b GPU, ≥ 4 GiB free 2.7 GB 89.6 % (448/500) 1.34 s / 1.54 s, 3.3 GiB of VRAM
askmdb-9b GPU, ≥ 8 GiB free, if you choose it 5.6 GB 91.6 % (458/500) 1.85 s / 2.14 s, 5.5 GiB of VRAM
  • Accuracy is measured by execution on the public test set manuelgscom/askmdb-test: 500 questions in English and Spanish over synthetic databases the training never saw. A question counts as right when the predicted pipeline returns the same result as the reference one. For comparison, the best general model without fine-tuning, Qwen3.5-9B, gets 47.8 % with worked examples in its prompt.
  • Speed was measured on one reference desktop with a 16 GB GPU and a CPU with 8 threads: one askmdb process per question, model loading included, median of 30 questions. The first question against a database reads the whole schema; the next ones reuse its saved state. On the GPU, the very first run also takes about 11 s longer while the driver prepares the GPU (once).
  • askmdb asks before downloading a model, verifies its SHA-256 and stores it in ~/.local/share/askmdb/models/ (or $XDG_DATA_HOME/askmdb/models/). The download URLs are pinned to a fixed revision and compiled into the binary, with the sizes and SHA-256 of the files:
    • askmdb-0.8b-1.0.0-Q4_K_M.gguf (revision 87315ab706b7): 856c3502c6fe4061a77d9a4940a5e36670f35dded1d32cecc298af978cb3509c
    • askmdb-4b-1.0.0-Q4_K_M.gguf (revision 9f1611ef5bfc): 2d0a5241e22a772863467530e00afa8be7e78a519559dc77b185c9606db2da14
    • askmdb-9b-1.0.0-Q4_K_M.gguf (revision a26b3449ac44): bd2c49de8cb07b93b4b6b961c45e351901426bf6bf96e5d97c18602d2336cba7
    • askmdb-2b-1.0.0-Q4_K_M.gguf (revision 248e7921fbd5, not downloaded by the CLI): 25b290a7fb50af8897cf9922c39e364e2850019dee85012c3209a06feee9c894
  • To use a local GGUF file instead: askmdb --model PATH <question…>.

The model cards describe the evaluation, the prompt contract and how to use each model with llama-server.

Release assets

File Description
askmdb-linux-x86_64 The binary, for CPU and GPU (with the Vulkan shaders inside). Static C++ runtime, OpenSSL and MongoDB driver; depends only on glibc. SHA-256 040d7bc064809bc06b8ece280680ec7a6515e0a3f706896379c36fbb9fffa306
SHA256SUMS Checksum of the binary (the models have theirs above)
THIRD_PARTY_NOTICES Licenses of the code built into the binary

Limitations

  • Only aggregate: no writes, indexes or administration, by design. No Atlas Search or vector search. MongoDB 5.0 or later.
  • Linux on x86_64 only (WSL 2 works). No macOS or ARM for now.
  • The models can be wrong, in about 1 of 6 questions on the test set with askmdb-0.8b and 1 of 12 with askmdb-9b, and a wrong pipeline can look plausible. Read the pipeline and its explanation before trusting the result.
  • The schema comes from a sample of 200 documents per collection; use --refresh after the data changes shape.
  • The GPU is used only through Vulkan, one GPU at a time. It has been tested on NVIDIA; AMD and Intel GPUs have not been tested yet.
  • askmdb is not a security tool. Its safety comes from the deterministic verifier, the confirmations and, above all, a read-only database user.

License

  • Code: MIT.
  • Models: Apache-2.0, the same license as their base models.
  • llama.cpp/ggml (with its Vulkan backend), the MongoDB C driver (libmongoc and libbson), OpenSSL, utf8proc, nlohmann/json, the Khronos Vulkan and SPIR-V headers and the GCC runtime (under the GCC Runtime Library Exception) are built into the binary; see THIRD_PARTY_NOTICES.

MongoDB is a trademark of MongoDB, Inc. askmdb is an independent project, not affiliated with or endorsed by MongoDB, Inc.


Author: Manuel García