Cross Canon: Implementing the Bible as a RAG Database
Cross Canon is a tool that transforms the Bible into a RAG (Retrieval-Augmented Generation) database, enabling users to perform semantic searches across scripture rather than relying on simple keyword matching. By indexing biblical texts, the system allows for the discovery of conceptually related passages across different books of the Bible.
Semantic Retrieval Capabilities
Cross Canon provides semantic search functionality that allows users to find verses based on meaning and context. Unlike traditional keyword search, this approach identifies passages that are conceptually linked to a a specific topic.
- Cross-Book Discovery: Users can search for a term like "giants" and discover references to characters beyond the well-known Nephilim and Goliath.
- Conceptual Mapping: A search for "government" retrieves not only direct mentions of governance in Romans 13 but also historical decrees by government officials in Daniel and Ezra, demonstrating the system's ability to retrieve conceptually relevant data.
Technical Considerations and RAG Limitations
While semantic retrieval improves discovery, the implementation reveals common challenges associated with RAG systems, particularly regarding context windows and retrieval latency.
Context Fragmentation
One significant limitation noted by users is the loss of immediate context. For example, a search for "slavery" may retrieve a specific verse (e.g., Leviticus 25:46-49) while missing the critical introductory context located in the preceding verses (e.g., verse 44). This highlights the challenge of determining the optimal "chunk size" when indexing text for RAG.
Performance and Latency
Some users reported that the system is slow, with some searches taking up to 15 seconds. This suggests a need for optimization in the vector database or the embedding model used. Community suggestions for improving performance include:
- In-process Vector DBs: Using tools like
zvec(an in-process vector database) to reduce the need for a separate server and improve query latency. - Hybrid Retrieval: Combining full-text search with vector embeddings to improve both speed and precision.
- Local Embedding Models: Utilizing models like GTR-T5 for fast, free, and local embedding generation.
Community Perspectives and Alternative Implementations
The community has discussed the project as a starting point for similar religious text indexing projects.
"I did the same for the Quran to see how RAG works. I also indexed related works called 'Hadith' and the names of Allah."
Users have also suggested expanding the scope of the library to include a broader range of canonical versions, including Catholic, Orthodox, and Ethiopian books, to ensure comprehensive coverage across different denominations.
Comparison with Standard LLMs
There is a debate regarding the utility of a RAG-based approach versus a standard Large Language Model (LLM) workflow. While some argue that basic LLM workflows can produce results in seconds, RAG is specifically designed to ground the model's responses in a specific, verifiable source (the indexed scripture), reducing the risk of "hallucinations" and ensuring that the results are directly quoted from the text.
Sources
Related
- Project
- Project
- Dispatch
- Project
- Project