Skip to content

Repository files navigation

Coptic Knowledge Assistant

CI

A multilingual, citation-first RAG assistant for Coptic Orthodox liturgical, theological, canonical, and pastoral questions.

Why this project

In specialist domains such as Coptic Orthodox liturgy, theology, canon law, and tradition, a plausible answer is not enough: the information must come from authoritative and verifiable sources.

General-purpose AI assistants may hallucinate when asked about rare subjects that are poorly represented in their training data. This project addresses that risk by connecting an LLM to a curated corpus of Coptic Orthodox sources. The system retrieves relevant evidence before generating an answer, provides citations and links to the original material, and clearly states when the indexed sources do not contain enough information to answer responsibly.

The goal is not to make the LLM sound more confident. It is to make its answers more grounded, transparent, and verifiable.

Features

  • English, Italian, and Arabic query support
  • Query rewriting for short and multilingual questions
  • OpenAI embeddings with text-embedding-3-small
  • GPT-5.6 Luna for grounded answer generation
  • PostgreSQL with pgvector
  • Hybrid semantic and lexical retrieval
  • Source-diverse reranking with candidate balancing
  • Citations with source URLs and similarity scores
  • Explicit acknowledgement when the retrieved evidence is insufficient
  • FastAPI API
  • Streamlit web interface
  • Docker Compose development environment

Architecture

User question
    ↓
Query rewriting
    ↓
Original + rewritten hybrid retrieval
    ↓
PostgreSQL / pgvector
    ↓
Source-diverse reranking
    ↓
GPT-5.6 Luna
    ↓
Grounded answer + citations

Data sources

The current corpus contains sources from:

The indexed corpus currently contains 13 sources and 3,135 chunks.

Running locally

Create a .env file from .env.example, then start the services:

docker compose up --build

On a fresh Docker volume, the bundled PostgreSQL dump is restored automatically. The dump contains the currently indexed sources, chunks, and embeddings, so the demo can be used without rerunning the ingestion pipeline.

The API is available at:

The Streamlit demo is available at http://127.0.0.1:8501.

Example request

{
  "question": "What is the purpose of fasting?",
  "limit": 3
}

The response contains a grounded answer, the retrieval queries used, and compact citations with source URLs and similarity scores.

To rebuild the corpus from the source files instead of using the bundled dump, run the ingestion, chunking, and indexing commands described in the project CLI.

Evaluation

Current retrieval benchmark on 20 questions:

Precision@5: 0.35
Recall@5:    0.82
Hit@5:       0.95

The evaluation set contains representative questions in English, Italian, and Arabic. Metrics are calculated at source level after hybrid retrieval, candidate balancing, and source-diverse reranking.

Limitations

  • Query rewriting adds an additional model call.
  • The corpus is still relatively small.
  • Retrieval quality can vary by language and question specificity.
  • The system is an informational assistant, not an authoritative replacement for clergy or official pastoral guidance.

Roadmap

  • Add more sources
  • Improve language-aware reranking
  • Deploy the API publicly
  • Expand the evaluation dataset

License and attribution

This project is for educational and portfolio purposes. Sources remain the property of their respective authors and publishers.

About

Multilingual citation-first RAG assistant grounded in authoritative Coptic Orthodox sources, designed to reduce LLM hallucinations.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages