Small-to-Big RAG
A Python package implementing the Small-to-Big RAG approach for more effective retrieval augmented generation.
Installation
pip install small-to-big-rag
Usage
from small_to_big_rag import SmallToBigRAG
import os
# Initialize with Azure OpenAI credentials
rag = SmallToBigRAG(
api_key=os.environ.get("AZURE_OPENAI_API_KEY"),
azure_endpoint=os.environ.get("AZURE_OPENAI_ENDPOINT"),
api_version="2024-10-21",
embedding_model="text-embedding-3-small",
llm_model="gpt-4o-mini"
)
# Load a document
rag.load_file("path/to/document.txt")
# Or load text directly
text = """
Your document text here.
This can be multi-paragraph content.
The system will split this into paragraphs and sentences.
"""
rag.load_text(text)
# Generate a response
response = rag.generate_response(
query="What is the main topic of the document?",
system_prompt="You are a helpful assistant specialized in document analysis."
)
# Print the answer
print(response["answer"])
# Access source information
print("\nSources used:")
for i, sentence in enumerate(response["sources"]["sentences"]):
print(f"Sentence {i+1}: {sentence[:100]}...")
for i, paragraph in enumerate(response["sources"]["paragraphs"]):
print(f"Paragraph {i+1}: {paragraph[:100]}...")
Features
- Small-to-Big RAG approach that retrieves both sentences and their parent paragraphs
- Maintains relationships between sentences and paragraphs for better context
- Uses ChromaDB for vector storage and retrieval
- Supports Azure OpenAI API
- Easy-to-use Python API
Requirements
- Python 3.8+
- langchain-text-splitters
- openai
- chromadb
- python-dotenv
License
MIT
Metadata
Release files for small-to-big-rag 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| small_to_big_rag-0.1.0.tar.gz | 7.4 kB | Without provenance | Details for small_to_big_rag-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| small_to_big_rag-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for small_to_big_rag-0.1.0-py3-none-any.whl |
Total release size: 14.5 kB
Release files / small_to_big_rag-0.1.0.tar.gz
| Download URL | small_to_big_rag-0.1.0.tar.gz |
|---|---|
| Size | 7.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
a8ff585e9902ff5a014a591f70c494d69282f15b41cca572d50ed3c267982a3d
|
|
BLAKE2b-256 checksum How to use checksums |
1daf1c2081722f2cdcf08f21ac9dd6c9de621a310ec453cc726896da124ac7e6
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.1
|
Release files / small_to_big_rag-0.1.0-py3-none-any.whl
| Download URL | small_to_big_rag-0.1.0-py3-none-any.whl |
|---|---|
| Size | 7.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
a2c7839aab388c45e9c735cb8b54cab210929113f4b365db8dabc144ce13c3f1
|
|
BLAKE2b-256 checksum How to use checksums |
44d41113919f60270b9cb1f89395c744d880f4136b1358e76340bf2b4c6f38bc
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.1
|
Security for small-to-big-rag 0.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.