Sanad — Arabic Source-Grounded RAG Assistant

End-to-end RAG system over ~80K Arabic passages in 10 knowledge categories. Every answer cites book, author, and page; the assistant refuses when no relevant source is retrieved. FastAPI, PostgreSQL + pgvector, Celery + Redis.

Overview

Sanad is an Arabic question-answering assistant grounded in a curated library of ~80K passages across 10 knowledge categories. Instead of answering from model memory, it retrieves relevant passages, generates an answer in Arabic, and cites the exact book, author, and page — and it declines to answer when nothing relevant is retrieved.

Challenge

General-purpose LLMs hallucinate and rarely cite sources, which is unacceptable for Arabic religious and scholarly content. The challenge was to make every answer traceable to a real source, keep retrieval precise across a large Arabic corpus, and refuse gracefully when the corpus has no answer.

Solution

A retrieval layer on PostgreSQL + pgvector with tunable top-k and similarity thresholds, category-filtered search, and Arabic prompt templates; a pluggable LLM provider factory (OpenAI, Gemini, OpenRouter, local LLMs); and Celery + Redis workers for asynchronous chunking, embedding, and indexing.

Architecture

Async FastAPI · SQLAlchemy 2 + Alembic · PostgreSQL + pgvector · Celery + Redis workers · pluggable LLM providers · Docker Compose

Results

  • Corpus: ~80K passages
  • Categories: 10
  • Citations: Book · author · page
  • Source-cited answers with refusal when no relevant source is found
  • Tunable top-k and similarity thresholds to balance precision and recall
  • Pluggable LLM providers (OpenAI, Gemini, OpenRouter, local)
  • JWT auth with admin approval and audit log, rate limiting, multi-turn conversations
  • pytest unit + integration tests, Docker Compose deployment

Technologies

  • Python
  • FastAPI
  • PostgreSQL
  • pgvector
  • Celery
  • Redis
  • SQLAlchemy
  • Docker
  • pytest
  • RAG

All projects · Contact

Loading project…