A Python library for Retrieval-Augmented Generation (RAG) capabilities in LLM applications.
Project description
fabricatio-rag
A Python library for Retrieval-Augmented Generation (RAG) capabilities in LLM applications.
📦 Installation
This package is part of the fabricatio monorepo and can be installed as an optional dependency using either pip or uv:
pip install fabricatio[rag]
# or
uv pip install fabricatio[rag]
For a full installation that includes this package and all other components of fabricatio:
pip install fabricatio[full]
# or
uv pip install fabricatio[full]
🔍 Overview
Provides tools for:
- Document embedding and vector storage using LanceDB This feature uses the LanceDB vector database to store document embeddings. Document embeddings are numerical representations of text documents that capture their semantic meaning. The library stores embeddings in LanceDB, which provides efficient storage and retrieval with automatic indexing.
- Semantic search and context retrieval The semantic search and context retrieval feature allows users to search for relevant documents based on the meaning of their queries. It uses nearest-neighbor search on stored embeddings to find documents that are semantically similar to the query.
- Reranking with TEI (Text Embeddings Inference) services The TEI integration enables document reranking. TEI services provide pre-trained models that can rerank texts based on relevance to a query. This allows for state-of-the-art reranking without managing model training locally.
- Database injection workflows The database injection workflows handle inserting documents into LanceDB, including vector conversion, collection/table creation, data indexing, and error handling.
- Asynchronous RAG execution patterns The asynchronous RAG execution patterns allow the library to perform multiple RAG tasks concurrently without blocking the main thread.
Built on top of Fabricatio's agent framework with support for asynchronous execution and Rust extensions.
🧩 Usage Example
from fabricatio_rag import VectorStoreService, VectorStoreTable, StoreDocument
async def search_knowledge():
# Initialize database connection (LanceDB URI, e.g. /tmp/lancedb or s3://bucket/path)
service = await VectorStoreService.connect("data/lancedb")
# Create a table with embedding dimension 1536 (OpenAI text-embedding-3-small)
table = await service.create_table("science_papers", ndim=1536)
# Add documents
docs = [
StoreDocument(content="Climate change severely impacts coral reef ecosystems...", vector=[...]),
StoreDocument(content="Ocean acidification reduces shell thickness in mollusks...", vector=[...]),
]
await table.add_documents(docs)
# Search for relevant documents
results = await table.search_document(embedding=[...], limit=3)
print("Top 3 relevant documents:")
for result in results:
print(f"- {result.content[:80]}...")
📁 Structure
fabricatio-rag/
├── actions/ - Data injection workflows
├── capabilities/ - Core RAG functionality
├── models/ - Document models
└── rust.pyi - Rust extension interfaces
🔗 Dependencies
Core dependencies:
lancedb- Vector database integrationfabricatio-core- Core interfaces and utilities
Rust extensions:
- LanceDB table management via PyO3 bindings
- TEI reranking via thryd router
📄 License
MIT – see LICENSE
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 Distributions
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 fabricatio_rag-0.4.0-py3-none-any.whl.
File metadata
- Download URL: fabricatio_rag-0.4.0-py3-none-any.whl
- Upload date:
- Size: 7.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.11.15 {"installer":{"name":"uv","version":"0.11.15","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
eb4dc35556ba722a8c9b296b999bfe793ba91d24f550909bd651e86195246434
|
|
| MD5 |
07698043638019f8139789e08cc60afd
|
|
| BLAKE2b-256 |
3357abc02819163918a28e7b89068b5077ea790e5bcf8fb90efa7bbf86b6157a
|