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.4.tar.gz (151.1 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.4-py3-none-any.whl (220.4 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for indoxarcg-0.0.4.tar.gz
Algorithm Hash digest
SHA256 41e6ff6d353ed4f80543cf7ead69bfe19472e4844302d71303b03b60926b14c3
MD5 376e05ebac828bff08abe15f0e6906d1
BLAKE2b-256 f22da83e757bd2deac664d066d3d7a302dc6f64ed7b74941eccec4ad97d6e6f8

See more details on using hashes here.

File details

Details for the file indoxArcg-0.0.4-py3-none-any.whl.

File metadata

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

File hashes

Hashes for indoxArcg-0.0.4-py3-none-any.whl
Algorithm Hash digest
SHA256 c0132e176512796410536fa711432f7cfc07d95842b2e45751ecbc777f2fa1fb
MD5 2c20ffd60bf89c5d20e5d20b6718aab6
BLAKE2b-256 5acbf9325abc600cc4d03c88a97c8225017d16a71889376b22185f8201ba5a04

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