System Architecture & Technical Specifications

Intelligent Knowledge Assistant for Technical Books

A grounded, sub-80ms hybrid retrieval engine built over 11 dense computer science volumes (2,810 chunks) combining dense vector embeddings, BM25 Okapi lexical scoring, Reciprocal Rank Fusion, and strict citation verification.

Embedding Model
BAAI/bge-small-en-v1.5 (384d)
Vector Storage
Qdrant ANN (HNSW Cosine)
Lexical Search
BM25 Okapi (2,810 chunks)
Re-Ranking Engine
Reciprocal Rank Fusion (k=60)
Warm Retrieval SLA
< 80 ms (Tested ~68 ms)
Total End-to-End SLA
1.2 – 2.8 s (OpenAI gpt-4o-mini)
⚑ Interactive Query Tokenizer & Vector Dispersal Streamer
Benchmarks:
Dynamic Token Breakdown (WordPiece / Byte-Pair Tokenization):
BAAI/bge-small 384d: ||v||β‚‚ = 1.0000

01 Why These Architectural Choices?

Building production RAG over dense technical literature requires deliberate trade-offs across chunking granularity, vector dimensions, memory footprint, and retrieval fusion.

Decision 1 β€’ Vectorization & Embeddings
Why did we choose BAAI/bge-small-en-v1.5 instead of larger alternatives?

We chose BAAI/bge-small-en-v1.5 to satisfy our 2–5s SLA on commodity hardware without requiring expensive NVIDIA CUDA GPUs or burning paid API tokens per search query:

Model Parameters Dimensions CPU Inference RAM / Storage Footprint Fit for This Project
BAAI/bge-small-en-v1.5 33.3M 384 15 – 25 ms ~150 MB RAM (1.5 KB / vector) Optimal (Chosen)
BAAI/bge-large-en-v1.5 335M 1,024 180 – 350 ms ~1.4 GB RAM (4.1 KB / vector) Too slow on CPU
OpenAI text-embedding-3-small API hosted 1,536 120 – 250 ms (Network) Paid API cost per query Violates offline OSS rule

Vector Storage Economics: 384 dimensions require 4x less memory in Qdrant HNSW graphs than 1536-dimensional OpenAI embeddings, allowing the entire 2,810-chunk index to execute inside sub-millisecond RAM caches.

Decision 2 β€’ Chunking Architecture
Why 700 tokens with 15% overlap?

Chunking technical books requires solving the Context Truncation Dilemma:

  • If chunks are too small (200–300 tokens): Multi-line SQL CTE queries, recursive Python functions, and mathematical proofs are cut in half, destroying syntactic integrity.
  • If chunks are too large (1,500+ tokens): Embeddings suffer from semantic dilution, making specific concepts harder to isolate in ANN vector space.
  • The 700-token sweet spot: Perfectly captures 2 to 3 cohesive textbook paragraphs or a complete code block alongside its explanatory commentary.

15% Overlap (105 tokens): Implemented via token-aware sentence boundary snapping. If an essential algorithmic definition lands across a chunk break, it is guaranteed to appear in full in both adjacent chunks.

Decision 3 β€’ Hybrid Search & RRF Fusion
Why Reciprocal Rank Fusion (k=60) instead of Weighted Sum?

Dense embeddings produce cosine similarity scores bounded in $[0, 1]$, whereas BM25 Okapi produces unbounded frequency scores in $[0, \infty)$. Linear weighted sum ($\alpha \cdot \text{Dense} + (1-\alpha) \cdot \text{BM25}$) fails because score scales shift wildly between short and long queries.

RRF eliminates score normalization vulnerabilities: It operates strictly over ordinal positions: $\text{RRF}(d) = \sum \frac{1}{60 + \text{Rank}_m(d)}$. As demonstrated below in our interactive sandbox, this allows BM25 to rescue exact terminology matches (like Chunk #4, promoted +16 ranks into the context window) while preventing single-keyword spam from overwhelming semantic relevance.

02 The 11 Technical Books Corpus

Our ingestion pipeline processed, cleaned, and indexed 11 authoritative technical textbooks into 2,810 searchable passages. Hover to tilt in 3D perspective or click any tome to inspect its chunk profile:

Deep Learning from Scratch
Deep Learning 268 pages β€’ 205 chunks
Packt SQL Query Design Patterns and Best Practices
SQL & Databases 270 pages β€’ 169 chunks
Boost Asio C++ Network Programming Cookbook
Systems & C++ 248 pages β€’ 200 chunks
Financial Theory with Python: A Gentle Introduction
Python 204 pages β€’ 145 chunks
Hands-On Machine Learning with C++
Systems & ML Packt β€’ 292 chunks
Linear Algebra for Data Science
Mathematics Vector Calculus
AI as a Service: Serverless Machine Learning on AWS
Cloud Architecture Manning β€’ 218 chunks
CRC Data Science: A First Introduction with Python
Data Science CRC Press β€’ 312 chunks
Cryptography and Embedded Systems Security
Security Springer β€’ 198 chunks
Graph-Powered Analytics and Machine Learning
Graph Databases TigerGraph β€’ 185 chunks
Python in Finance: Practical Numerical Algorithms
Python & Finance O'Reilly β€’ 224 chunks

03 Dynamic Circuit Architecture & 2D Vector Nebula

Watch data packets pulse through the dual-branch hybrid retrieval circuit. Below, interactively navigate the 2D vector projection space with live nearest neighbor raycasting:

⚑ Dual-Branch Signal Highway
Parallel Execution: Active
User Query Natural Text JEV Pre-Gate System 1 Filter BGE 384d Qdrant HNSW BM25 Okapi 2,810 Chunks RRF Fusion k = 60 Matrix JEV Valuation Joint Utility gpt-4o-mini Synthesis Verified Ans pp. Citations
Interactive 2D Semantic Vector Embedding Projection (Draggable Query Vector Q)

Drag node Q with your mouse across the vector field to observe real-time cosine distance raycasting and dynamic nearest neighbor discovery across 2,810 book chunks.

Q Vector: [0.65, 0.45] β€’ Nearest: Deep Learning
Deep Learning SQL Python Systems

04 Interactive RRF Fusion Physics Sandbox

Directly test the mathematical mechanics of Reciprocal Rank Fusion: RRF Score = 1/(k + DenseRank) + 1/(k + LexicalRank). Drag the k parameter slider to observe how rank smoothing dynamically swaps and reorders candidate passages in real-time.

Smoothing Constant k: k = 60
Presets:
Rank & Evidence Passage Dense ANN β€’ BM25 Lexical β€’ Reciprocal Fusion Score
Key Insight: At $k=60$, Chunk #4 (Promoted +16) securely enters the LLM prompt window, while keyword spam is prevented from dethroning semantic match #1.

05 Interactive Backend Pipeline Simulation

Experience what happens step-by-step when a query enters the FastAPI server. Click "Run End-to-End Simulation" to trace the exact execution path across all 8 micro-stages with live latency meters.

Active Benchmark Scenario
"What is a forward pass in a neural network?"
01 JEV Pre-Gate
02 BGE Embed
03 Hybrid ANN
04 RRF Re-Rank
05 JEV Valuation
06 Context Pack
07 LLM Gen
08
Stage 1: Input Sanitization & Domain Guardrail Defense
Latency: 14 ms
Validates user query against prompt injection patterns and domain boundaries. Non-technical queries (e.g. medical advice like headaches) are intercepted and rejected immediately in under 15ms without invoking OpenAI.
is_allowed, category, msg = domain_guardrail.check_query_safety(query) # Status: ALLOWED (Category: Technical / Deep Learning) # Sanitized Query: "What is a forward pass in a neural network?"
Deep Learning

Deep Learning from Scratch

Author: Seth Weidman β€’ Publisher: O'Reilly Media

Indexed Chunks
205 chunks
Total Pages
268 pages
Token Density
684 tok / chunk
Sample Extracted Passage:
"Figure 6-6. Another order in which data could flow through the same RNN during its forward pass. This all covers how the forward pass through an RNN would work. What about the backward pass?"