Indox Retrieval Augmentation
Project description
Official Website • Documentation • Discord
NEW: Subscribe to our mailing list for updates and news!
Overview
inDoxArcg is a next-generation application designed for advanced document processing and retrieval augmentation. It offers two powerful pipelines:
- Cache-Augmented Generation (CAG): Enhances LLM responses by leveraging local caching, similarity search, and fallback mechanisms.
- Retrieval-Augmented Generation (RAG): Provides context-aware answers by retrieving relevant information from vector stores.
Key features include multi-query retrieval, smart validation, web search fallback, and customizable similarity search algorithms.
Features
The inDoxArcg application offers two powerful pipelines designed to optimize the use of large language models (LLMs) and enhance document retrieval capabilities. These pipelines provide flexibility and adaptability to meet diverse use cases:
Cache-Augmented Generation (CAG) Pipeline
- Multi-query retrieval: Expands single queries into multiple related queries.
- Smart retrieval: Validates context for relevance and hallucination.
- Web search fallback: Uses DuckDuckGo when local cache is insufficient.
- Customizable similarity search: Supports TF-IDF, BM25, and Jaccard similarity algorithms.
Retrieval-Augmented Generation (RAG) Pipeline
The Retrieval-Augmented Generation (RAG) Pipeline is designed to provide highly accurate and contextually aware answers by retrieving relevant documents from a vector store. For example, if you want to answer the question, "What are the health benefits of green tea?", the pipeline will:
- Search for relevant articles or documents in the vector store.
- Validate the retrieved context for relevance and accuracy.
- Generate a detailed answer using the Large Language Model (LLM) based on the retrieved context.
This makes RAG particularly suitable for scenarios requiring:
- Research and Academia: Retrieving specific scientific studies or historical data.
- Customer Support: Answering customer queries by extracting relevant data from a knowledge base.
- Legal and Compliance: Providing precise answers using legal documents or compliance guidelines.
- Standard retrieval: Uses vector similarity search.
- Context clustering: Organizes retrieved context for enhanced usability.
- Advanced querying: Offers options like multi-query expansion and smart validation.
- Web fallback: Ensures high-quality results with external web searches when needed.
Roadmap
| Feature | Implemented | Description |
|---|---|---|
| Model Support | ||
| Ollama (e.g., Llama3) | ✅ | Local Embedding and LLM Models powered by Ollama |
| HuggingFace | ✅ | Local Embedding and LLM Models powered by HuggingFace |
| Google (e.g., Gemini) | ✅ | Embedding and Generation Models by Google |
| OpenAI (e.g., GPT4) | ✅ | Embedding and Generation Models by OpenAI |
| API Model Support | ||
| OpenAI | ✅ | Embedding and LLM Models from Indox API |
| Mistral | ✅ | Embedding and LLM Models from Indox API |
| Anthropic | ✅ | Embedding and LLM Models from Indox API |
| Loader and Splitter | Implemented | Description |
|---|---|---|
| Simple PDF | ✅ | Import PDF files |
| UnstructuredIO | ✅ | Import data through Unstructured |
| Clustered Load And Split | ✅ | Adds a clustering layer to PDFs and text files |
| RAG Features | Implemented | Description |
|---|---|---|
| Hybrid Search | ✅ | Combines Semantic Search with Keyword Search |
| Semantic Caching | ✅ | Saves and retrieves results based on semantic meaning |
| Clustered Prompt | ✅ | Retrieves smaller chunks and clusters for summarization |
| Agentic RAG | ✅ | Ranks context and performs web searches for reliable answers |
| Advanced Querying | ✅ | Delegates tasks based on LLM evaluation |
| Reranking | ✅ | Improves results by ranking based on context |
| Customizable Metadata | ❌ | Offers flexible control over metadata |
| Bonus Features | Implemented | Description |
|---|---|---|
| Docker Support | ❌ | Deployable via Docker |
| Customizable Frontend | ❌ | Fully customizable frontend |
Installation
Install the latest stable version:
pip install inDoxArcg
Note: This package requires Python 3.9 or later. Please ensure you have the appropriate version installed before proceeding. Additionally, verify that you have
pipupdated to the latest version to avoid dependency issues.
Setting Up Python Environment
-
Create a virtual environment:
Windows:
python -m venv indoxarcg_env
macOS/Linux:
python3 -m venv indoxarcg_env
-
Activate the virtual environment:
Windows:
indoxarcg_env\Scripts\activate
macOS/Linux:
source indoxarcg_env/bin/activate
-
Install dependencies:
pip install -r requirements.txt
Usage Examples
Cache-Augmented Generation (CAG)
The indoxArcg package emphasizes a modular design to provide flexibility and ease of use. The imports are structured to clearly separate functionalities such as LLMs, vector stores, data loaders, and pipelines. Below is an example of using the Cache-Augmented Generation (CAG) pipeline:
Initialization:
from indoxArcg.llms import OpenAi
from indoxArcg.data_loaders import Txt, DoclingReader
from indoxArcg.splitter import RecursiveCharacterTextSplitter, SemanticTextSplitter
from indoxArcg.pipelines.cag import CAG, KVCache
llm = OpenAi(api_key="your_openai_api_key")
embedding_model = DeepSeek()
cache = KVCache()
cag = CAG(llm, embedding_model, cache)
Preload Documents:
documents = ["Document 1 text...", "Document 2 text..."]
cag.preload_documents(documents, cache_key="my_cache")
Inference:
query = "What is the capital of France?"
response = cag.infer(
query=query,
cache_key="my_cache",
context_strategy="recent",
context_turns=5,
top_k=5,
similarity_threshold=0.5,
web_search=True,
smart_retrieval=True,
)
print(response)
Initialization:
from indoxarcg import CAG, KVCache
llm = YourLLM()
embedding_model = YourEmbeddingModel()
cache = KVCache()
cag = CAG(llm, embedding_model, cache)
Preload Documents:
documents = ["Document 1 text...", "Document 2 text..."]
cag.preload_documents(documents, cache_key="my_cache")
Inference:
query = "What is the capital of France?"
response = cag.infer(
query=query,
cache_key="my_cache",
context_strategy="recent",
context_turns=5,
top_k=5,
similarity_threshold=0.5,
web_search=True,
smart_retrieval=True,
)
print(response)
Retrieval-Augmented Generation (RAG)
Initialization:
from indoxArcg.pipelines.rag import RAG
from indoxArcg.llms import OpenAi
from indoxArcg.vector_stores import Chroma
from indoxArcg.embeddings import OpenAiEmbedding
llm = OpenAi(api_key="your_openai_api_key",model="gpt-3.5-turbo")
embedding = OpenAiEmbedding(api_key="your_openai_api_key")
db = Chroma(collection_name="your_collection_name",embedding)
rag = RAG(llm, vector_store)
Inference:
question = "What is the capital of France?"
response = rag.infer(
question=question,
top_k=5,
use_clustering=True,
use_multi_query=False,
smart_retrieval=True,
)
print(response)
Contribution
We welcome contributions to improve inDoxArcg. Please refer to our Contribution Guidelines for detailed instructions on how to get started. The guide includes information on setting up your development environment, submitting pull requests, and adhering to our code of conduct. Please refer to our Contribution Guidelines.
License
This project is licensed under the AGPL-3.0 License. See the LICENSE file for details.
Support
For questions, support, or feedback, join our Discord or contact us via our website.
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 indoxraghelper-0.0.3.tar.gz.
File metadata
- Download URL: indoxraghelper-0.0.3.tar.gz
- Upload date:
- Size: 119.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5a169e5df4aee3d8f02d3f694516eed9d4549b614a5bd406cdc65e3591e1d3ea
|
|
| MD5 |
0a00192d4bb4ad407c43798bd312b1ad
|
|
| BLAKE2b-256 |
8041aa20e5275adc0857d8df6d33406454a57c14ba8649a9dc55ab9df054babf
|
File details
Details for the file indoxRagHelper-0.0.3-py3-none-any.whl.
File metadata
- Download URL: indoxRagHelper-0.0.3-py3-none-any.whl
- Upload date:
- Size: 175.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
51c5dca58d30fd15bf00fb711eafd123d069a59c10f5a36a70967fa9806cf046
|
|
| MD5 |
cd9cc0fc81c466ae48942c46c042572a
|
|
| BLAKE2b-256 |
6c24a5fb4bd6f43a7d4d92d0689357ef4b331bc06d779744668fd31bdd2072a9
|