Enterprise AI Architecture

Three models.
One pipeline.
Runs locally or Cloud — Your Choice?

A production RAG architecture for deep technical document analysis — built on open-source models, deployed fully on-premise.

Mistral 7B · Router Qwen 2.5-32B · Retrieval DeepSeek-R1 · Inference
Explore the pipeline ↓

Upload documents. Ask them anything.

Drop in one or more documents (PDF, DOCX, TXT, images), let the pipeline index them, then ask questions answered only from their contents — with source passages and a full compliance audit. This is the whole RAG loop, end to end.

Connecting to pipeline…
Drop files here, or click to choose
PDF · DOCX · TXT · Images (PNG, JPG, WEBP…) · 50 MB max

Your conversation will appear here.

Index one or more documents on the left, then ask a question below.

Answers are grounded only in the indexed documents. Full pipeline: NV-EmbedQA-E5-v5 embeddings · BM25 keyword search · RRF fusion · Nemotron reranking · Nemotron-Super deep inference · compliance audit log.

3Models in pipeline
6Pipeline stages
128KMax context tokens
100%On-premise · No cloud

The six-stage pipeline

Each stage is handled by the model best suited for that task. Click any stage to see what happens inside.

Layer 0 — Query Router

Model: Mistral 7B · Always-on · ~5GB VRAM · <50ms latency

Incoming query
Mistral 7B classifies intent
Route decision → Redis Streams
What it decides

Is this a simple lookup, a multi-doc analysis, or a classification task? Each route activates a different pipeline path.

Why Mistral 7B

Runs continuously at under 50ms latency. No chain-of-thought overhead needed for a routing classification — speed is the only priority here.

Output format

{ "type": "deep_analysis", "priority": "high", "pipeline": "full" } — pushed onto Redis Streams queue.

VTech mapping

Sits before Layer 1 (Ingestion). Partially built into your existing Layer 1 health monitor HTTP endpoints.

Mistral never reads the document. It only classifies query intent and decides which pipeline path to activate.

Layer 1 — Ingestion + Embedding

Model: Qwen2.5-32B (embedding mode) · Batch worker · ~18GB VRAM

PDF / spec sheet
Chunk (300–500 tokens)
Qwen embeds each chunk
ChromaDB / FAISS
Chunking strategy

Token-aware splits — not character-based. 300–500 tokens with 50-token overlap. Preserves table and formula boundaries in engineering specs.

Why Qwen2.5 for embedding

Training on multilingual technical text and code means embedding quality is high for engineering specs, tables, schematics, and JSON structures.

Vector store

ChromaDB for development, FAISS for production scale. Metadata stored: doc_id, page, chunk_index, doc_type, timestamp.

VTech mapping

This IS your Layer 1 Ingestion Pipeline — already built with OpenCV + Redis Streams. Add Qwen embedding call after frame capture.

Qwen runs offline in batch mode during ingestion. Embeddings are pre-computed — Qwen doesn't need to be online at query time.

Layer 2 — Hybrid Retrieval

Model: Qwen2.5-32B (query embedding) + BM25 (keyword) · Fused via RRF

Query
Qwen embeds query
Vector top-k=10
+
Query
BM25 keyword search
Keyword candidates
RRF Fusion → Top 10 chunks
Why hybrid search

Semantic search finds meaning. Keyword search finds exact part numbers, spec codes, and model IDs. Engineering documents need both simultaneously.

RRF fusion formula

Score(D) = Σ 1/(k + rᵢ(D)) across all retrievers. A chunk ranking 1st in both vector and keyword gets the highest fused score.

k value

Retrieve top 10 total, pass top 5 to inference. More chunks = richer context but higher token cost for R1's reasoning trace output.

VTech mapping

Layer 2 (Classification) — retrieval feeds the classification decision that was previously just a rule-based system in your pipeline.

Layer 3 — Reranking + Context Assembly

Model: Mistral 7B (cross-encoder) · Fast precision pass · Same Ollama instance

Top 10 chunks
Mistral scores each chunk vs query
Top 5 reranked
Context window assembled
What reranking does

Initial retrieval is recall-focused (cast wide). Reranking is precision-focused — scores each candidate against the specific query and drops noise before R1 sees it.

Why Mistral here (not Qwen)

Reranking is 10 fast single-passage comparisons. Mistral's speed advantage matters. Qwen's size advantage is wasted on this shallow task.

Context assembly

Top 5 chunks + original query + system prompt = the augmented prompt passed to DeepSeek-R1. Target: fits within 8K–16K tokens.

VTech mapping

New sub-layer inside your Layer 2/3 boundary. Protects R1's context window from low-relevance chunks that inflate token cost and degrade reasoning.

Reranking is optional but strongly recommended. Without it, R1 receives noisy context — reasoning quality degrades significantly when chunks are irrelevant.

Layer 4 — Deep Inference (Generation)

Model: DeepSeek-R1 70B · ~40GB VRAM Q4 · Chain-of-thought reasoning · RLVR-trained

Assembled context
<think> R1 reasons step-by-step </think>
R1 generates final answer
Structured JSON response
The thinking trace

R1 outputs a hidden <think> block first. It cross-references chunks, flags contradictions, then produces a grounded, sourced answer. Visible for audit.

Output format

{ "finding": "...", "confidence": 0.92, "source_chunks": [...], "reasoning_summary": "..." } — parse-ready for Layer 5 audit log.

Token cost reality

R1 produces 2–4× more tokens per query than a standard model due to the reasoning trace. Budget ~2K–4K output tokens per engineering document query.

VTech mapping

Layer 3 (Inference) in the 5-layer spec. Video anomaly + retrieved context → engineering judgment → structured output lives entirely in this stage.

DeepSeek-R1 is the only model trained with RLVR — rewarded only when its reasoning chain produces a verifiable correct answer. This is what separates it from Qwen and Mistral for this task.

Layer 5 — Audit + Response Aggregation

No model needed · SurrealDB structured logging · API response layer

R1 JSON output
Parse + validate
SurrealDB audit log
API response to client
What gets logged

query · route decision · retrieved_chunks[] · reranked_chunks[] · r1_thinking_trace · final_answer · confidence · latency_ms · timestamp

Why this matters

Enterprise clients require explainability. The audit log lets engineers trace exactly why a finding was flagged — chunk by chunk, step by step.

Confidence threshold

If R1 confidence < 0.70, flag for human review. High-stakes findings (safety alerts) always route to human queue regardless of confidence score.

VTech mapping

Layer 4 (Response Aggregation) + Layer 5 (Audit) in your spec. SurrealDB is already in your planned stack — zero additional tooling needed.

Full pipeline data flow
0 · Mistral routes 1 · Qwen ingests 2 · Hybrid retrieves 3 · Mistral reranks 4 · R1 reasons 5 · Audit logs

Why these three models

Each model is ranked #1 for its specific role — not because it's universally "best," but because it's optimised for that exact moment in the pipeline.

#3 overall · #1 for routing & reranking

Mistral 7B

7B params · ~5GB VRAM · <50ms latency
  • Sliding window attention for efficient long-context handling
  • Speed-optimised training — ideal for classification tasks
  • Already running in your Ollama stack — zero deployment cost
  • Used at Layer 0 (routing) and Layer 3 (reranking)
Weakness: 7B parameter ceiling limits deep reasoning on complex engineering specs.
#2 overall · #1 for retrieval & embedding

Qwen2.5-32B

32B params · ~18GB VRAM · Batch mode
  • Trained on multilingual technical text, code, and math
  • Optimal VRAM footprint for always-on embedding workloads
  • Strong on structured data: tables, JSON, YAML, schematics
  • Used at Layer 1 (ingestion embedding) and Layer 2 (query embedding)
Weakness: No native CoT training — single-pass inference without self-verification loop.

Production-ready building blocks

Each product is a self-contained reference architecture we deploy at client sites. Click a tab to dive into the design.

10xLab Product

KnowledgeVault AI

Combining private on-premise documents with public real-time data — without leaking either way.

100% On-Premise Public + Private RAG PII Boundary Guard
Architecture

The pattern in one diagram

Stays on-premise (private) Leaves the perimeter (public, sanitised) Critical boundary Orchestration
CLIENT PERIMETER · on-premise · Docker Compose PUBLIC INTERNET User Query natural language ⚠ 1. PII Classifier & Query Router decides what is safe to send outside; redacts names, IDs, account numbers, $ amounts 2a. Private Retriever SurrealDB (vector index) nomic-embed-text top-k chunks from client documents 2b. Public Retriever Tavily / Brave Search API News, weather, stocks, regulations, real-time feeds sanitised sub-query only Tavily / Brave / Bing API NOAA, Bloomberg, Reuters SEC EDGAR, gov.uk, etc. 3. Context Fusion dedupe · rerank · tag each chunk [PRIVATE] vs [PUBLIC] · token budget 4. Local LLM (Ollama) Mistral 7B / Llama 3.1 generates answer + citations from both sources
Threat model

The boundary risks — and how each one is closed

Boundary What can leak Mitigation
Documents → embeddings Embedding vectors can be inverted back to source text via known attacks. Run nomic-embed-text locally inside the Docker network. Never call cloud embedding APIs (OpenAI /embeddings, etc.) on private data.
Vector DB → retriever Retrieval patterns reveal what users are investigating. Keep SurrealDB on-prem. For high-threat workloads, add Gumbel noise to similarity scores (differentially private retrieval).
Query → public API The query itself — "our AR exposure to ACME Corp" sent to a search API leaks the relationship. PII classifier rewrites the public sub-query as an abstract question ("current weather in Houston") before egress. The proper-noun + the figure stay home.
LLM inference Cloud LLMs see the entire fused context, including private chunks. Local Ollama inference. The only model that sees both worlds runs inside the client perimeter.
Reference implementation

The minimum viable code

This is the orchestration layer in plain Python. It sits between Open Notebook and Ollama. Anyone with basic Python can read it.

def hybrid_rag(user_query: str) -> str:
    # 1. Decide what is safe to send outside.
    public_query, redactions = pii_classifier.sanitise(user_query)

    # 2. Run both retrievers in parallel.
    private_chunks = private_retriever.search(user_query,  k=5)   # stays local
    public_chunks  = public_retriever.search(public_query, k=3)   # web/API

    # 3. Tag each chunk so the LLM and the user can tell them apart.
    context = (
        [f"[PRIVATE] {c.text}  (source: {c.source})" for c in private_chunks] +
        [f"[PUBLIC]  {c.text}  (source: {c.url})"    for c in public_chunks]
    )

    # 4. Build the prompt with explicit citation rules.
    prompt = PROMPT_TEMPLATE.format(
        question = user_query,
        context  = "\n\n".join(context),
    )

    # 5. Local LLM generates the answer.
    return ollama.generate(model="mistral:7b", prompt=prompt)
Why this is enough. The full system has more layers — caching, rerankers, fallback logic, audit logs — but the core is just these five steps. Everything else is engineering polish.
Don't skip step 1. A naive implementation ships the raw user query to a public search API. That single mistake leaks more than the documents would have. The PII classifier is not optional.
Build vs reuse

How this maps to KnowledgeVault AI

Component Already in stack? What to add
Private retriever✓ Open Notebook + SurrealDB + nomic-embed-textnothing
Local LLM✓ Ollama (Mistral 7B)nothing
Public retrieverThin wrapper around Tavily or Brave API ($5–20/month for low volume)
PII classifierPresidio (open-source, runs locally) or a small fine-tuned classifier
Orchestrator~150 lines of Python; LangChain's MultiRetriever works, or hand-roll for fewer moving parts

Compare the open-source models

Send one prompt to three open-weight models side by side. Watch how a fast router model, a deep reasoner, and a lightweight Google model each handle the same question.

Demo mode — showing simulated responses. Connect a backend for live model output (see setup below).
Try:
Qwen 3 Alibaba · router / generalist
idle
Response will appear here.
DeepSeek-R1 DeepSeek · deep reasoner
idle
Response will appear here.
Gemma 3 Google · lightweight
idle
Response will appear here.

Outputs are generated independently per model with no shared context. In demo mode, responses are pre-written illustrations of each model's characteristic style — not live inference.

Build this for your enterprise

We design and implement on-premise RAG pipelines tailored to your engineering domain. Full data sovereignty. No cloud dependency.

james@10xlab.org →
100%
On-premise — your data never leaves your infrastructure
5-layer
Modular architecture — deploy incrementally, layer by layer
Open
Built entirely on open-source models — no vendor lock-in