Farid Zahran Logo
All projects

Contexure - RAG AI Chatbot

Enterprise-grade RAG platform for industrial technical datasheets using a deterministic 5-stage pipeline and strict confidence guardrails.

Role
Software & AI Engineer
Timeline
2026
Next.jsFastAPIQdrantGeminiGroq
Contexure Enterprise Industrial RAG Platform interface

Industrial documentation & hallucination risks

Industrial automation equipment—such as AC motors, variable frequency drives, PLCs, and inductive sensors—operates under strict physical, electrical, and thermal tolerances. When automation engineers and field technicians query technical documentation, hallucinated ratings lead to burnt drive modules, incorrect wiring schematics, and costly factory downtime.

Generic conversational AI systems fail in industrial domains: they flatten dense multi-column electrical tables into scrambled text strings, guess unlisted parameters rather than acknowledging absent data, lack verifiable page-level citations linked to source PDFs, and suffer from single-provider API rate limits. Contexure solves these failure points through structure-aware document parsing, local CPU embeddings, cross-encoder reranking, and a strict confidence guardrail gate.

Production telemetry & system benchmarks

768
Vector Dimensionality

FastEmbed nomic-embed-text-v1.5 local ONNX embeddings.

8,192
Max Context Window

Token capacity per document chunk with structural tree mapping.

θ ≥ 0.65
Guardrail Cutoff Gate

Deterministic cross-encoder score required before invoking LLM.

< 200ms
Retrieval Latency

End-to-end local CPU vectorization and FlashRank reranking.

100%
Citation Fidelity

Verifiable chunk-level source citations and page mappings.

0 ms
PDF Server Load

Zero server overhead via client-side jsPDF report generation.

Contexure editorial landing page and specimen catalog
01. Editorial landing page & specimen catalog — public discovery, backend health probing, and interactive 5-stage pipeline visualizer.
Contexure grounded multi-turn chat workspace
02. Grounded chat workspace — real-time SSE token streaming, client-side conversation memory, and specimen query presets.

Deterministic 5-stage RAG lifecycle

From raw multi-page PDF ingestion to real-time streaming answer delivery, each query flows through a deterministic, observable sequence designed to eliminate hallucination risks.

Stage 1 (Structure-Aware Ingestion): Parses industrial datasheets with PyMuPDF and Docling into markdown trees that strictly retain heading depth (#, ##, ###) and table grids. This guarantees table row associations (e.g. Frame size → Current → Torque) do not collapse into disorganized flat strings.

Stage 2 (Hierarchical Chunking): Documents are segmented along structural boundaries into large Parent Chunks (~1,500 tokens) and small Child Chunks (~300 tokens). Child chunks provide high-precision vector matches, while the reconstructed Parent Chunk provides the full surrounding context to the generation prompt.

Stage 3 (Local CPU FastEmbed Inference): Generates normalized 768-dimensional embeddings using nomic-embed-text-v1.5 locally on CPU via ONNX Runtime in ~18ms with zero third-party API latency or recurring token fees, then indexes vectors into Qdrant Cloud with rich metadata payloads.

Stage 4 (FlashRank Cross-Encoder & Guardrail Gate): Initial top-20 vector candidates are re-scored locally by FlashRank cross-encoder. If the top candidate fails the calibrated confidence threshold (score < 0.65), the system immediately halts LLM synthesis and outputs a deterministic refusal banner, eliminating 100% of LLM token spend on out-of-scope queries.

Stage 5 (Resilient Dual-Provider LLM Synthesis): Synthesizes grounded responses with XML-tagged context chunks via Server-Sent Events (SSE). If Google Gemini 2.5 Flash encounters rate limits (HTTP 429) or transient errors, the request automatically fails over to Groq Llama 3.3 70B Versatile in under 50ms with zero user disruption.

Footnote citation drawer with verbatim text snippets
03. Footnote citation drawer — reveals exact source document title, page number, confidence rating, and verbatim datasheet excerpts.
Multi-document specification comparison matrix
04. Spec matrix — balanced multi-document vector retrieval for side-by-side industrial motor comparisons.

Decoupled architecture & failover resilience

The system enforces a clean separation of concerns across three distinct operational tiers to maintain high availability and predictable inference latency.

Tier 1 (Client Application): Built with Next.js 16 App Router, TypeScript, and Tailwind CSS. Features Vercel AI SDK Server-Sent Events integration, client-side jsPDF single-answer technical reporting, citation popover drawers, and localStorage conversation memory.

Tier 2 (Core Ingestion & Evaluation Engine): Asynchronous FastAPI service running Python 3.11, responsible for structure-aware parsing, hierarchical chunking, local CPU FastEmbed ONNX vectorization, FlashRank cross-encoder reranking, and confidence guardrail validation.

Tier 3 (Managed Storage & LLM Providers): Qdrant Cloud 768-dimensional vector store with rich structured payload filters, primary Google Gemini 2.5 Flash generation, and Groq Llama 3.3 70B zero-downtime failover orchestration.

Administrative PDF ingestion portal and vector stepper
05. Ingestion portal — administrative drag-and-drop PDF upload with real-time 4-step vector processing stepper.
RAG observability and telemetry dashboard
06. Observability dashboard — full RAG telemetry tracking pass rates (94.8%), latency distributions, and rejected query gap triage.

Production rigor & architectural decisions

Contexure demonstrates engineering maturity by treating AI integration as a disciplined systems problem rather than a simple prompt wrapper.

By enforcing deterministic guardrails, layout-preserving PDF extraction, dual-provider failover, and local CPU embedding generation, the platform delivers verifiable accuracy, high availability, and significant API cost reductions for mission-critical industrial applications.

Keep exploring the work.