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

indoxarcg-0.0.9.tar.gz (152.4 kB view details)

Uploaded Source

Built Distribution

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

indoxarcg-0.0.9-py3-none-any.whl (224.7 kB view details)

Uploaded Python 3

File details

Details for the file indoxarcg-0.0.9.tar.gz.

File metadata

  • Download URL: indoxarcg-0.0.9.tar.gz
  • Upload date:
  • Size: 152.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.11

File hashes

Hashes for indoxarcg-0.0.9.tar.gz
Algorithm Hash digest
SHA256 749bc468d90346d1d973057022c7d3d87235cf815a29bc577c6caee00b4234ad
MD5 87c189210b09227171480f7f343c5ca0
BLAKE2b-256 d793b02914f4fb16467c5068ec1d068ef9895224430bb8512d264fc348c15b61

See more details on using hashes here.

File details

Details for the file indoxarcg-0.0.9-py3-none-any.whl.

File metadata

  • Download URL: indoxarcg-0.0.9-py3-none-any.whl
  • Upload date:
  • Size: 224.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.11

File hashes

Hashes for indoxarcg-0.0.9-py3-none-any.whl
Algorithm Hash digest
SHA256 4624fbf48769934afcd485dd977e36ebd903071ddda2300714715c6326fdce32
MD5 645de8dc0e69fb11466a9f6b85746d4d
BLAKE2b-256 06df8fe7312a0325eff56f5a2e332fdd84a5b93c447401e0e5e613bc1d937c56

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