How dinas33/egyptian-civil-code-rag works
This is a bilingual Egyptian Civil Code RAG application. Its main workflow is PDF extraction into legal-article records, corpus preparation and indexing, then API question handling through semantic retrieval, context construction, and locally hosted answer generation with sources. Separate evaluation and observability workflows assess retrieval and answers and record runs or traces. The graph includes documented preparation stages whose script internals were not sampled; those links rely on the README, not inspected implementations.
Main entry points: pipeline.py RAG pipeline · api.py FastAPI interface · evaluate_ragas_observability.py RAGAS evaluation · extraction.py Article extraction
Components 23
Corpus preparation
- Article extraction
src/egyptian_civil_code_rag/extraction.py - Article records
data/processed - Chunk building
scripts/build_chunks.py - Embedding build
scripts/build_embedding.py - FAISS index build
scripts/build_faiss.py - Chunks and index
data/processed
Query serving
- RAG pipeline
src/rag/pipeline.py - RAG configuration
src/rag/config.py - Query embedding
src/rag/embeddings.py - Article retrieval
src/rag/retriever.py - Answer generation
src/rag/generator.py
Evaluation and tracking
- RAG evaluation
scripts/evaluate_rag.py - RAGAS evaluation
scripts/evaluate_ragas_observability.py
Service interfaces
- FastAPI interface
src/rag/api.py - BentoML service
src/rag/bento_service.py
Other components
- Civil Code PDF
data/raw/egyption-low.pdf.dvc - Legal questioner
- Ollama local LLM
- Grounded answer
- RAGAS metrics
- MLflow tracking
- Langfuse tracing
- DVC reproducibility
Connections 24
- Civil Code PDF → Article extraction: extracts text
README.md - Article extraction → Article records: writes records
README.md - Article records → Chunk building: chunks articles
README.md - Chunk building → Embedding build: embeds chunks
README.md - Embedding build → FAISS index build: builds index
README.md - FAISS index build → Chunks and index: writes index
README.md - Legal questioner → FastAPI interface: submits question
README.md - Legal questioner → BentoML service: submits question
README.md - FastAPI interface → RAG pipeline: initializes pipeline
src/rag/api.py - BentoML service → RAG pipeline: initializes pipeline
src/rag/bento_service.py - RAG pipeline → RAG configuration: loads settings
src/rag/pipeline.py - RAG pipeline → Query embedding: loads model
src/rag/pipeline.py - RAG pipeline → Chunks and index: loads chunks and index
src/rag/pipeline.py - RAG pipeline → Article retrieval: retrieves articles
src/rag/pipeline.py - RAG pipeline → Answer generation: generates answer
src/rag/pipeline.py - Answer generation → Ollama local LLM: requests completion
src/rag/generator.py - RAG pipeline → Grounded answer: returns answer
src/rag/pipeline.py - RAG evaluation → RAGAS metrics: evaluates quality
README.md - RAGAS evaluation → RAGAS metrics: scores responses
scripts/evaluate_ragas_observability.py - RAGAS evaluation → MLflow tracking: logs metrics
scripts/evaluate_ragas_observability.py - RAGAS evaluation → Langfuse tracing: records traces
scripts/evaluate_ragas_observability.py - FastAPI interface → MLflow tracking: logs query metrics
src/rag/api.py - FastAPI interface → Langfuse tracing: traces requests
src/rag/api.py - DVC reproducibility → Article extraction: versions pipeline
README.md