MWMartin Wassim
Return to Selected Work
ARCHITECTURAL DOSSIER // 2024—2026
PROJECT 06Natural Language Processing & LLMsVector Search & RAG

RAG DOCUMENT ASSISTANT

Retrieval-Augmented Generation assistant with semantic chunking and grounded citations.

martinx.work/work/rag-document-assistant
RAG DOCUMENT ASSISTANT Architectural Presentation
TIMELINE

2024 — 2026

DISCIPLINE

AI / Retrieval-Augmented Generation

ROLE

Lead Software Architect

AFFILIATION

Systemize EG · Cairo

Core Runtime • Engineering Toolchain
PythonRAGLLMsChromaDBSentence TransformersOllamaFastAPIStreamlit
01 // Operational & Technical Friction

The Problem Space

General LLMs frequently hallucinate facts when queried on proprietary manuals, technical specs, enterprise reports, and dense domain texts.

02 // The Architected Solution

Systemized Implementation

Constructed a deterministic RAG retrieval pipeline where the LLM is constrained to synthesize exclusively from top-k retrieved vectors.

03 // Production Implementation & Workflow

How It Operates in Production

Built with Python, FastAPI, and ChromaDB. Documents are ingested, normalized, and split using recursive character chunking with 15% overlap. Embeddings are generated using Hugging Face Sentence Transformers and queried via approximate nearest neighbor search.

Engineering Depth

Engineered chunk overlap strategies to preserve semantic boundaries, optimized embedding dimensionality for rapid cosine similarity queries, and implemented citation mapping.

04 // Architectural Flow & State MachineBespoke Pipeline
RAG RETRIEVAL

RAG PIPELINE // DETERMINISTIC RETRIEVAL & GROUNDED CITATIONS

ZERO HALLUCINATIONS • PRIVACY-PRESERVING
STEP 01 // INGESTION

Recursive Text Chunking

PDF document parsing with 15% sliding window overlap preserving semantic boundary clauses across complex sections.

NODE 01ONLINE
STEP 02 // EMBEDDING

Dense Vector Generation

Hugging Face Sentence Transformers map normalized clauses into 384-dimensional dense metric vector spaces.

NODE 02ONLINE
STEP 03 // VECTOR INDEX

ChromaDB Persistent Cosine Search

Hierarchical vector collection querying top-k relevant chunks with strict similarity confidence threshold gates.

NODE 03ONLINE
Core Innovation
STEP 04 // SYNTHESIS

Ollama Grounded Generation

Local LLM constrained to generate answers strictly derived from retrieved text, annotating verifiable page references.

NODE 04VERIFIED

Data Flow & Infrastructure

Unstructured documents flow into an ingestion worker that parses text and generates vector embeddings. Vectors are indexed in persistent ChromaDB collections. Query requests trigger semantic vector searches, which feed retrieved text passages into the prompt context of an Ollama LLM.

Architectural Highlight

Pipeline guarantees zero hallucinations by enforcing strict context prompting and returning source page references for every assertion.

05 // Key Engineering Decisions
Recursive semantic chunking: Maintained paragraph integrity and header context to avoid splitting critical clauses across chunk boundaries.
Privacy-preserving local inference: Integrated Ollama (Llama 3 / Mistral) to allow enterprises to query confidential documents without sending data to external APIs.
Strict verification prompt templates: Constrained LLM output to state 'Information not found in provided documents' if cosine similarity falls below safety threshold.
06 // Challenges & Mitigations
Preserving context across complex multi-column PDF layouts and nested tables.
Balancing chunk size between semantic granularity and LLM context window efficiency.
Eliminating hallucinated page numbers by appending metadata hashes to each retrieved chunk.
07 // Verified Capabilities

Core System Features

Automated PDF and text ingestion pipeline
Semantic text chunking with overlap preservation
High-density vector embeddings using Sentence Transformers
ChromaDB persistent collection indexing with cosine distance
Local LLM inference via Ollama integration (privacy-preserving)
Strict citation-backed answers with clickable document references
FastAPI backend with a reactive Streamlit research interface