Skip to main content

Indox Retrieval Augmentation

Project description

inDoxArcg

Typing SVG

License PyPI Python Downloads

Discord GitHub stars

Official WebsiteDocumentationDiscord

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:

  1. Cache-Augmented Generation (CAG): Enhances LLM responses by leveraging local caching, similarity search, and fallback mechanisms.
  2. 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:

  1. Search for relevant articles or documents in the vector store.
  2. Validate the retrieved context for relevance and accuracy.
  3. 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 pip updated to the latest version to avoid dependency issues.

Setting Up Python Environment

  1. Create a virtual environment:

    Windows:

    python -m venv indoxarcg_env
    

    macOS/Linux:

    python3 -m venv indoxarcg_env
    
  2. Activate the virtual environment:

    Windows:

    indoxarcg_env\Scripts\activate
    

    macOS/Linux:

    source indoxarcg_env/bin/activate
    
  3. 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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

indoxraghelper-0.0.1.tar.gz (119.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

indoxRagHelper-0.0.1-py3-none-any.whl (175.4 kB view details)

Uploaded Python 3

File details

Details for the file indoxraghelper-0.0.1.tar.gz.

File metadata

  • Download URL: indoxraghelper-0.0.1.tar.gz
  • Upload date:
  • Size: 119.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.4

File hashes

Hashes for indoxraghelper-0.0.1.tar.gz
Algorithm Hash digest
SHA256 31ffe57c0b7c1c82cac0d3b4a41facc8446efa4ccb42562588d2067135e6d1a9
MD5 4595c244fc215c29e076d7281edbfda3
BLAKE2b-256 34f9de441845cb6235466e599f04821bae153a7a11d1076496791c8eb047c1a4

See more details on using hashes here.

File details

Details for the file indoxRagHelper-0.0.1-py3-none-any.whl.

File metadata

  • Download URL: indoxRagHelper-0.0.1-py3-none-any.whl
  • Upload date:
  • Size: 175.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.4

File hashes

Hashes for indoxRagHelper-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 3765f192e47ac9df7ded2a44cb3de49933bcdd26263623496205962b2254471b
MD5 67585da67dd1fa1a445c9b87d75c3287
BLAKE2b-256 03e3148f89be31edcaa63067751372ae1b6d13abae03ebafe4640345d15978ab

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page