PROTOTYPE · RAG · ISLAMIC FINANCE

Answer built on
found sources.

An educational AI agent takes a question on Islamic finance, finds relevant fragments in a local document corpus and returns an answer with source references, scores and chunk identifiers.

The task

Connect domain expertise with verifiable search

Questions about murabaha, riba or the functions of a Sharia committee require grounding in documents, not just a language model's memory. The prototype separates fact retrieval from answer generation and shows which fragments were used.

Pipeline

From document to answer with sources

01 · INGEST

Documents

TXT, Markdown, PDF, DOCX and XLSX files are loaded from a local corpus and split into overlapping chunks.

02 · INDEX

FAISS + BM25

Semantic search via embeddings is combined with lexical search on exact terms.

03 · RERANK

Context selection

Optional CrossEncoder refines the candidate order before passing to the model.

04 · ANSWER

GigaChat + sources

The model receives the selected fragments; the Gradio interface shows the answer, sources, score and chunk ID.

Implemented system

Not a notebook demo, a reproducible structure

LOADERS

Five formats

A unified ingestion layer for text, documents, tables and PDFs.

INDEX

Persisted FAISS

Index and chunks are built by a separate ingest script and loaded by the application.

UI

Gradio dialogue

Message history, example questions and a dedicated sources block.

SECRETS

Local .env

Keys are not committed and are excluded from Git; only a configuration template is public.

CODE

Modular package

Ingestion, embeddings, storage, retrieval and agent are split into components.

TESTS

Basic checks

The project includes tests and reproducible run instructions.

Status and boundaries

Educational prototype, not a financial opinion

The system demonstrates RAG architecture and information retrieval. Answers require specialist verification, are not investment advice or a fatwa, and do not replace a Sharia board decision or legal expertise.