A lightweight RAG pipeline toolkit powered by HuggingFace
Project description
ragkitpy ๐ค
A lightweight, beginner-friendly RAG (Retrieval-Augmented Generation) pipeline toolkit powered by HuggingFace ๐ค โ no OpenAI key required.
๐ Why ragkitpy?
Setting up a RAG pipeline from scratch is painful. LangChain and LlamaIndex are powerful but heavy and complex for beginners. ragkitpy gives you a working RAG pipeline in 5 lines of code using only open-source models.
- โ No OpenAI API key needed โ runs fully local with HuggingFace
- โ Supports PDF and TXT files
- โ Built on FAISS for fast vector search
- โ Beginner-friendly API
- โ Lightweight โ minimal dependencies
๐ฆ Installation
pip install ragkitpy
โก Quick Start
from ragkitpy import RAGPipeline
# Initialize
rag = RAGPipeline()
# Load your document (PDF or TXT)
rag.load_document("my_document.pdf")
# Query it
results = rag.query("What is this document about?")
for i, chunk in enumerate(results, 1):
print(f"Result {i}: {chunk}")
That's it. 5 lines to a working RAG pipeline. ๐ฏ
๐ง How It Works
Your Document (PDF/TXT)
โ
[loader.py] โ Extract raw text
โ
[chunker.py] โ Split into overlapping chunks
โ
[embedder.py] โ HuggingFace embeddings (all-MiniLM-L6-v2)
โ
[vectorstore.py]โ Store in FAISS index
โ
Your Query โ Embed query โ Search FAISS โ Return top-k chunks
๐ Full API Reference
RAGPipeline
from ragkitpy import RAGPipeline
rag = RAGPipeline(
model_name="all-MiniLM-L6-v2", # Any SentenceTransformer model
chunk_size=500, # Characters per chunk
overlap=50 # Overlap between chunks
)
| Method | Description |
|---|---|
rag.load_document(path) |
Load a PDF or TXT file |
rag.query(question, top_k=3) |
Get top-k relevant chunks |
rag.query_with_scores(question, top_k=3) |
Get chunks with similarity scores |
rag.is_ready |
Check if document is loaded |
rag.source |
Path of loaded document |
Use a different HuggingFace model
# Larger model, better quality
rag = RAGPipeline(model_name="all-mpnet-base-v2")
Get similarity scores
results = rag.query_with_scores("What is machine learning?", top_k=3)
for chunk, score in results:
print(f"Score: {score:.4f} | {chunk[:100]}")
Use individual modules
from ragkitpy import load_file, chunk_text, HFEmbedder, VectorStore
# Use just the loader
text = load_file("document.pdf")
# Use just the chunker
chunks = chunk_text(text, chunk_size=300, overlap=30)
# Use sentence chunker instead
from ragkitpy.chunker import chunk_by_sentences
chunks = chunk_by_sentences(text, sentences_per_chunk=3)
๐๏ธ Project Structure
ragkitpy/
โโโ ragkitpy/
โ โโโ __init__.py # Public API
โ โโโ loader.py # PDF & TXT file loading
โ โโโ chunker.py # Text chunking strategies
โ โโโ embedder.py # HuggingFace embeddings wrapper
โ โโโ vectorstore.py # FAISS vector store
โ โโโ pipeline.py # End-to-end RAG pipeline
โโโ tests/ # 24 unit tests
โโโ examples/ # Working examples
โโโ pyproject.toml
๐ง Dependencies
| Package | Purpose |
|---|---|
sentence-transformers |
HuggingFace text embeddings |
faiss-cpu |
Vector similarity search |
pypdf |
PDF text extraction |
numpy |
Array operations |
๐ค Contributing
Contributions are welcome! Please read CONTRIBUTING.md first.
git clone https://github.com/SRINATH-GITHU/ragkitpy.git
cd ragkitpy
pip install -e ".[dev]"
pytest tests/ -v
๐ License
MIT License โ see LICENSE for details.
๐จโ๐ป Author
Built by Srinath Dhumnor as an open-source contribution to the GenAI community.
โญ Star this repo if it helped you!
---
Built by Srinath Dhumnoor as an open-source contribution to the GenAI community.
If this project helped you build something cool, โญ star the repo โ it really helps others discover it!
Questions, ideas or feedback? Feel free to open an issue. ๐
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file ragkitpy-0.1.1.tar.gz.
File metadata
- Download URL: ragkitpy-0.1.1.tar.gz
- Upload date:
- Size: 12.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
743ca2ce06781f1dde1f1b2aeab4cfcfe40184884d3632c55623a2a6d6a47a3d
|
|
| MD5 |
bbca30dbcc63838be8d239a7168afbf8
|
|
| BLAKE2b-256 |
9f325c7b8b4796b64a817103fa9b23a5e318ae110586c0c001f0871fb683dffa
|
File details
Details for the file ragkitpy-0.1.1-py3-none-any.whl.
File metadata
- Download URL: ragkitpy-0.1.1-py3-none-any.whl
- Upload date:
- Size: 10.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
706f74d6f6560736420da9fd9b5b9ebf065ea75eb39571d43ba20740da3cff1e
|
|
| MD5 |
0b2b7ec3600e1920b90bd2ba43ca1751
|
|
| BLAKE2b-256 |
afc3046826395979c50649da839c1305d7d0175234c215fcc01914e1dfa0ec2a
|