QuickRag is an open-source toolkit for Retrieval-Augmented Generation (RAG).
It combines document indexing, retrieval, optional reranking, and querying large language models (LLMs) like Gemini.
git clone https://github.com/ton_compte/QuickRag.git
cd QuickRag
# optional: create a virtual environment
python -m venv .venv
source .venv/bin/activate # Linux / Mac
.venv\Scripts\activate # Windows
# install dependencies
pip install -r requirements.txt
pip install -e . # editable install for developmentThe project is structured around four main layers:
Handles document indexing and retrieval with ColBERT.
Key features:
create_index_from_docs(doc_path, index_name): index documents from PDFs.retrieve_docs(query, index_path, top_k): fetch top-k documents.query(query, index_path, reranker=None, top_k=5): retrieves documents, optionally reranks, and queries Gemini.
Example usage:
colbert = ColbertRAG()
index_path = colbert.create_index_from_docs("docs/", index_name="my_index")
retrieved_docs = colbert.retrieve_docs("What is neural search?", index_path)Abstract class for document reranking:
from Reranker import Reranker
reranker = Reranker(top_k=5)
ranked_docs = reranker.rank_docs(query="Neural search?", docs=retrieved_docs)Built-in implementations:
- Reranker: CrossEncoder-based ranking.
- ColbertReranker: Uses ColBERT for reranking.
Persistent storage for embeddings using ChromaDB. Supports multiple collections and provides methods to:
-
create_collection(name, embedding_model): create or retrieve a collection. -
add_doc_to_collection(docs, collection): add new documents. -
retrieve_docs(query, collection, top_k): retrieve top-k relevant documents. -
delete_collection(name)andlist_collection().
db = VectorStore(db_name="my_db")
collection = db.create_collection("my_collection", embedding_model_name="intfloat/multilingual-e5-small")
db.add_doc_to_collection(chunks, collection)
docs = db.retrieve_docs("What is neural search?", collection)High-level wrapper to create a full RAG pipeline:
- Loads and chunks documents.
- Stores embeddings in a vector store.
- Retrieves top-k documents.
- Optionally reranks documents.
- Queries Gemini LLM for answers
Example:
qr = QuickRag()
answer = qr.create_naive_gemini(
path_documents="docs/",
query="What is neural search?",
gemini_model="gemini-2.5-flash",
reranker=reranker
)
print(answer)