license: bsl-1.0 task_categories:
- question-answering
- text-generation tags:
- quantum-annealing
- rag
- graph-database
- vector-database
- pytorch
- multi-agent
- memory
- benchmark size_categories:
- 1K<n<10K
⚛️ QDB: Quantum-Inspired Deductive Database, Multi-Agent Workflow Engine & In-Transformer PyTorch Neural Memory
QDB (qdb-ai) is an all-in-one AI database, retrieval engine, multi-agent workflow framework, and differentiable in-transformer memory architecture.
⚛️ Core Scientific Breakthroughs
1️⃣ Discrete QCBO Hamiltonian Retrieval
Formulates multi-document context selection not as heuristic greedy ranking, but as an exact Global Energy Minimization Problem over an Ising spin-glass Hamiltonian:
$$\min_{\mathbf{x} \in {0, 1}^N} \mathcal{H}(\mathbf{x}) = \mathbf{x}^T Q \mathbf{x} + \mathbf{c}^T \mathbf{x} \quad \text{subject to} \quad \sum_{i=1}^N x_i \le B$$
- 🎯 Unary Relevance ($\mathbf{c}_i \in \mathbb{R}^N$): Maximizes semantic and lexical query alignment on the Hamiltonian diagonal.
- 🧲 Ferromagnetic Couplings ($Q_{ij} < 0$): Implements attractive potential wells across relational hyperedges, actively pulling complete multi-hop causal chains into the ground state.
- 🛡️ Anti-Ferromagnetic Contradiction Walls ($Q_{ik} = +50.0\text{ J}$): Imposes infinite energetic barriers between conflicting, negated, or superseded facts, strictly forbidding mutual co-selection.
2️⃣ Differentiable PyTorch Neural Memory (qdb.nn)
Replaces external text prompt stuffing with direct in-model latent conditioning:
- ⚡ Zero-Token Prompt Overhead: Transformer hidden states $\mathbf{h}t \in \mathbb{R}^{d{\text{model}}}$ cross-attend directly to in-VRAM factual key/value memory tensors $(K_{\text{mem}}, V_{\text{mem}})$ during the forward pass.
- 🔄 Differentiable Gating: Features learnable projection matrices $(W_q, W_k, W_v, W_o)$ and a residual gate $\sigma(\alpha)$ trainable via standard backpropagation while base LLM parameters remain frozen.
3️⃣ In-VRAM Thermodynamic Logit Interceptor
An inline GPU decoding shield that monitors latent hidden-state semantic resonance in real time:
- 🔒 Boltzmann Heat Penalty: Dynamically intercepts unnormalized vocabulary logits $\mathbf{z}_t \in \mathbb{R}^{V}$ prior to sampling and injects a $+50.0\text{ J}$ thermodynamic penalty onto hallucinated or contradictory tokens.
- 📉 Absolute Hallucination Suppression: Drives the probability of sampling invalid claims down to $P(\text{false}) \le 1.9 \times 10^{-22}$.
4️⃣ Native Multi-Agent Workflow Engine (qdb.Workflow)
A zero-dependency, ultra-fast agentic orchestration engine engineered from the ground up:
- ⚡ $6.79\ \mu\text{s}$ Node Transitions: Executes state dispatch 176× faster than LangGraph with zero Pydantic v1 conflicts.
- ⏳ Deterministic Time-Travel & State Forking: Implements immutable SHA-256 state hashing with
fork()and bi-directional checkpoints (save_checkpoints()/load_checkpoints()). - 📉 Lyapunov Energy Convergence: Bounds recursive agent retries through dissipative energy descent, mathematically preventing infinite loops.
📊 Empirical 4-Way Head-to-Head Benchmark
Evaluated against a 6-hop causal dependency chain with injected temporal traps, entity attractors, and contradictory statements:
| Retrieval Architecture / Engine | 6-Hop Causal Lineage Continuity | Contradiction Leakage Rate | Retrieval Latency |
|---|---|---|---|
| 🔴 Dense Vector RAG (Qdrant + MMR) | 50.0% (Broken at Hop 2) | 100% (Leaked) | 2.89 ms |
| 🟠 Microsoft GraphRAG (Leiden) | 33.3% (Community Cutoff) | 100% (Leaked) | 36.41 ms |
| 🔵 HippoRAG (Stanford & OSU, NeurIPS 2024) | 50.0% (Damped at Hop 4) | 100% (Leaked) | 4.13 ms |
| 🟢 ⚛️ QDB Deductive Engine (Ours) | 100.0% (Unbroken Chain) | 0.0% (Clean Ground State) | 3.24 ms |
💻 Installation & Dual-Mode Usage
pip install --upgrade qdb-ai==2.2.5
🧠 Usage 1: In-Transformer PyTorch Neural Memory (qdb.nn)
import torch
from transformers import AutoModelForCausalLM, AutoTokenizer
import qdb
from qdb import Vault
from qdb.nn import inject_memory_into_llm
# 1. Ingest Knowledge into Vault
vault = Vault("science_memory", purge=True, embedder="fast")
vault.ingest("Nexus Dynamics engineered the Chronos Sensor Array in Cambridge during 2021.")
vault.ingest("The Chronos Sensor Array utilizes sub-atomic resonance crystals manufactured by Aether Labs.")
vault.ingest("The Almaty facility is directed by Dr. Elena Rostov who holds the master telemetry decryption key.")
# 2. Load Base LLM (e.g. LLaMA-3, Mistral, GPT-2, Gemma)
base_llm = AutoModelForCausalLM.from_pretrained("gpt2")
tokenizer = AutoTokenizer.from_pretrained("gpt2")
# 3. Inject In-Model Neural Memory (0 Prompt Tokens Consumed!)
grounded_llm = inject_memory_into_llm(
model=base_llm,
vault=vault,
inject_layers="all"
)
# 4. Generate Grounded Output
output = grounded_llm.generate_grounded(
tokenizer=tokenizer,
prompt="Who holds the master telemetry key for the Cambridge sensor array?",
max_new_tokens=40
)
print(output)
⚡ Usage 2: Ultra-Fast Multi-Agent Workflow Engine (qdb.Workflow)
import qdb
from qdb import Workflow, Agent, WorkflowState, Vault
vault = Vault("company_knowledge")
vault.ingest("Alpha Protocol requires dual cryptographic multi-signature authorization.")
def researcher_action(state: WorkflowState) -> WorkflowState:
facts = state.vault.ask(state.current_task, hops=4)
state.context_memory["verified_facts"] = str(facts)
return state
researcher = Agent(
name="SecurityAnalyst",
system_prompt="Verify cryptographic security protocols.",
action_fn=researcher_action
)
wf = Workflow(name="CryptoAuditPipeline", vault=vault)
wf.add_agent(researcher)
wf.set_entry_point("SecurityAnalyst")
initial_state = WorkflowState(
current_task="What authorization is required for Alpha Protocol?",
vault=vault
)
# Sub-7 microsecond deterministic state execution
final_state = wf.run(initial_state)
print("Pipeline Output:", final_state.context_memory["verified_facts"])
📜 Citing QDB
@software{qdb_ai_2026,
author = {Prannesshkva},
title = {{QDB: Quantum-Inspired Deductive Database, Multi-Agent Workflow Engine \& In-Transformer PyTorch Neural Memory}},
month = aug,
year = 2026,
publisher = {CERN Zenodo},
version = {2.2.5},
doi = {10.5281/zenodo.22056493},
url = {https://doi.org/10.5281/zenodo.22056493}
}
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file qdb_ai-2.2.7.tar.gz.
File metadata
- Download URL: qdb_ai-2.2.7.tar.gz
- Upload date:
- Size: 130.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/7.0.0 CPython/3.10.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
64d14e770556acb4f49f0bbb10271cd3032c3699ba2d877f4caaeda9e9aa147f
|
|
| MD5 |
898cb2e3a185140b36305490061398fe
|
|
| BLAKE2b-256 |
93c88bd220e0657fe6d9128f9ccfe943cf5b62dc3d2e8456024e24eeae0e14dc
|
File details
Details for the file qdb_ai-2.2.7-py3-none-any.whl.
File metadata
- Download URL: qdb_ai-2.2.7-py3-none-any.whl
- Upload date:
- Size: 143.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/7.0.0 CPython/3.10.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c87178e9ad2c79dbc1a2a84fafbbe1591db4ca3ef1fb58dc9157cffd1693e835
|
|
| MD5 |
c1ca3f4408b1e7f017dd86018072d68a
|
|
| BLAKE2b-256 |
15527ab7d1d808324d25b4608b3cfc39a38ce72771094451033670d0a13d9069
|