A FastAPI service that serves specialized domain experts as one typed contract, built on DSPy 3.2. Each domain is a real dspy.Module; a router dispatches the question; LiteLLM handles provider routing; MLflow traces every run; and a dspy.Evaluate harness drives MIPROv2/GEPA prompt optimization. A 1-bit bitnet.cpp local provider is an optional fallback for offline / PII / air-gapped workloads. (Renamed from “BitNet SME Expert v2.0” — v2 was string stubs with no DSPy or BitNet code; v3 rebuilt the expert layer for real.)
What runs today
- Per-domain
dspy.Moduleexperts underapp/dspy_modules/— a math module (dspy.ReActover seven SymPy tools plus a deterministic arithmetic fast-path), a code module, and a general module (dspy.ChainOfThought, with an opt-indspy.ReActhybrid-RAG path over LanceDB with a BGE-family embedder + bge-reranker-v2-m3 whenRAG_ENABLED). A router module dispatches by domain. - Provider routing via LiteLLM — per-role LM specs (router / math / code / general) with
DSPY_LM_<ROLE>env overrides, so any provider (or the localbitnet.cppserver) can back any role. - A substrate-agnostic deployment playbook — the specialization layer is the constant and the model underneath is a config flip: the same
DSPY_LM_<ROLE>vars point router / math / code / general at HF Inference Providers, a Modal-hosted vLLM (modal deploy scripts/modal_serve.py), a localbitnet.cppserver, or a frontier API.docs/deployment-modal-hf.mdis the written playbook;scripts/modal_serve.pyandscripts/modal_finetune.pyship with it, covered bytests/test_modal_scripts.py. No substrate is hosted anywhere today — this is the recipe, not a running deployment. - MLflow tracing — autolog wired into the DSPy configuration.
- An optimization loop and an eval harness —
scripts/optimize.pycompiles each domain with MIPROv2/GEPA;scripts/run_eval.pyrunsdspy.Evaluateper domain against per-domain thresholds. A committed receipt (eval/receipts/math-miprov2.json) records a real MIPROv2 win on math: baseline 0.62 → 0.80 (+0.18) on a held-out split (50-row train / 50-row holdout per domain). - A CI eval gate, wired but never exercised —
.github/workflows/eval.ymldoes run on every pull request tomain, and it holds the per-domain thresholds, the Wilson 95% CI score table and the PR-comment step. But the eval step is gated on anOPENAI_API_KEYsecret and the repository has no secrets set, so the step has been skipped on every run that reached it and no eval has ever actually run: the job passes green without evaluating anything, and no PR has ever received the score table.branch-protection.ymlholds the intended required-check configuration; it isworkflow_dispatch-only, has never been run, andmaincurrently has neither branch protection nor a ruleset, so the check is not required either. Treat this as a harness that exists, not a bar that has been enforced. - An MCP server —
app/mcp_server.py(officialmcpSDK,dspy-sme-mcpconsole script) exposes the math/code/general experts as Model Context Protocol tools over the same DSPy programs. - One typed FastAPI contract with the usual plumbing (Pydantic v2 schemas, SlowAPI rate limiting, CORS, Docker multi-stage build).
- A refusal guard on the math tools — the SymPy tools previously capped expression length and evaluation time, which bounded latency but not work:
9^9^9^9is seven characters, sails past the length cap, and allocates until the process dies.app/dspy_modules/math_module.pynow parses the expression withastfirst and refuses unbounded exponentiation (literal exponents are capped at 5,000) before anything reaches SymPy, with the old caps kept as backstops. Shipped 2026-08-03. It closes the sympify-DoS item of the six-item audit issue #19; the issue itself is still open, and the /query auth item was explicitly out of scope for that commit. - A local pre-push gate —
lefthook.ymlrunsmake linton pre-commit andmake lint && make teston pre-push, mirroring the CI gate on the developer’s machine. It is inert until someone runslefthook install.
The air-gapped thesis
The defensible niche isn’t “we run BitNet” — the model is open-weight. It’s the corpus + a distillation/eval pipeline packaged to run fully offline on a CPU, for sovereignty/regulated buyers (legal, finance, defense, HIPAA) where the data never leaves the enclave. Paired with SUM (verifiable, citeable answers offline) and InfiniteContext (on-device retrieval without a cloud vector DB), it forms an offline expert stack that cloud incumbents structurally can’t ship.
What’s next (honest gaps)
- Eval receipts beyond math. The committed receipt covers the math domain (+0.18 MIPROv2 win on a 50-row held-out split); code and general have train/holdout gold sets but no committed baseline-vs-compiled win yet. Scaling the splits past 50/domain would tighten the Wilson CIs further.
- A measured BitNet receipt.
scripts/bitnet_demo.shmeasures real tok/s through the DSPy path and writes a datedeval/receipts/bitnet-<date>.txt, but it needs real hardware to run, so no measured figure is committed yet (the README deliberately ships none until the demo produces one). - A published/installable artifact. No GitHub release, package, or hosted demo yet — the prerequisite for promoting this past in-development.
Technical Stack
- Framework: Python ≥3.12 (
uv-managed) / FastAPI / Pydantic v2 - Optimization: DSPy 3.2 (
dspy.Module/dspy.ReAct/dspy.ChainOfThought,dspy.Evaluate, MIPROv2 / GEPA) - Provider routing: LiteLLM (per-role LM specs, env overrides)
- Tracing: MLflow autolog
- Retrieval (opt-in): LanceDB + a BGE-family embedder & bge-reranker-v2-m3 (hybrid RAG) for the general expert
- Local/offline:
bitnet.cpp1-bit server (OpenAI-compatible) - Domain tools: SymPy (math)
- Deployment substrates (config, not hosted): HF Inference Providers, Modal-hosted vLLM, local
bitnet.cpp, frontier APIs - Ops: Docker multi-stage build, Makefile, pytest, ruff, Lefthook local pre-commit/pre-push gate
Repository README
We couldn't load this repository's README from GitHub right now. You can view it directly on GitHub instead.
View README on GitHubRelated work
-
in-development
AgentXAgent — Agent Team Arena
A platform for running competitive matches between AI agent teams. Configure teams, pit them against the same challenge, score outputs, build leaderboards.
-
beta
SUM — Verifiable Bidirectional Knowledge Distillation
Cryptographic provenance for AI knowledge transforms. Every transform — render, extract, compose, slider — emits a signed receipt anyone can verify offline. Six-regime compliance validators (EU AI Act, GDPR, HIPAA, SOC 2, ISO 27001, PCI DSS) and a layered sum verify --explain output landed in v0.7.0; the current PyPI release is v0.12.0. Same bytes verify identically in Python, Node, and modern browsers.
-
in-development
InfiniteContext — Tiered Memory for AI
An extensible memory layer that pushes past model context limits: a hierarchical bucket store with exact-flat persistence and approximate (HNSW) retrieval at scale, automatic categorization, multi-level summarization, and pluggable storage tiers from local disk to cloud. Public, MIT-licensed TypeScript library + CLI.