INDEX
#09
SYSTEM INDEX09
TIMELINE2025 - 2026
ENGINEERING ROLEAI Systems Engineer

Multi-Stage RAG System

Document Ingestion & Semantic Vector Retrieval Engine

ARTIFACT SPECIFICATION // 09
Multi-Stage RAG System
PythonPyMuPDFBGE-large-en-v1.5Vector Mathpython-docxpython-pptx
ENDPOINT: https://github.com/bilalshemsu1/multi-stage-rag-system
01 // THE PROBLEM

Standard LLMs hallucinate when asked domain-specific questions about private documents, while naive keyword search fails to capture semantic meaning when queries and texts do not share identical vocabulary.

02 // LOCAL CONSTRAINTS

Must ingest heterogeneous document formats (PDF, DOCX, PPTX), preserve semantic context across chunk boundaries, and retrieve relevant passages with high-dimensional vector precision without hallucinating.

03 // ENGINEERED SOLUTION

Built a production-grade Retrieval-Augmented Generation (RAG) system with a multi-stage pipeline: automated document parsing with metadata extraction, semantic text chunking (~2200 chars with 350-char overlap), and instruction-based high-dimensional vector search using the BGE-large-en-v1.5 embedding model.

SYSTEMS DESIGN TOPOLOGY // VISUAL ARCHITECTURE

Addis Entrance Hub: Dual-Channel Delivery Topology

High-concurrency web and Telegram MTProto microservices over MySQL transactional persistence

Client Inbound
Web + Telegram
01
Ingress Gateway
Nginx / cPanel SSL
02
Core Service
Custom PHP & Fastify
03
AI Gateway Layer
Multi-Model Proxy
04
MySQL Persistence
Normalized Schema
05
REQUEST LIFECYCLE & EXECUTION PATH

Student requests from low-bandwidth mobile devices ingress through either the web interface or lightweight Fastify Telegram bot. Requests route through custom PHP controllers, querying an in-house AI Gateway for instant tutoring explanations and persisting test session attempts into normalized MySQL tables.

SYSTEM REACH6,000+ Active Students
RESILIENCE STRATEGYGraceful Offline Fallback & Telegram Channel Redundancy
[ARCHITECTURAL DECISIONS & ENGINEERING TRADEOFFS]
Multi-Format Parsing Engine (ingest.py)

Extracted clean normalized text, subjects, and page metadata across PDFs (PyMuPDF), DOCX (python-docx), and PPTX (python-pptx).

Boundary-Preserving Semantic Chunking

Chunked text into ~2200-character segments with a 350-character sliding overlap, guaranteeing continuous context preservation across document sections.

Instruction-Based Embeddings (BGE-large-en-v1.5)

Employed the state-of-the-art BGE-large-en-v1.5 model with query instruction prefixing ('Represent this sentence for searching relevant passages:') for high-accuracy semantic retrieval.

[DEPLOYMENT MATRIX & STACK]
PythonPyMuPDFBGE-large-en-v1.5Vector Mathpython-docxpython-pptx