Skip to content

About

Adaptive chunking & model-aware retrieval for Multi-Hop RAG — hybrid dense+BM25 retrieval on OpenSearch (research implementation)

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

Adaptive Chunking and Model-Aware Retrieval for Multi-Hop RAG

This repository contains the implementation for the research paper "Adaptive Chunking and Model-Aware Retrieval Strategies for Multi-Hop Retrieval-Augmented Generation".

It implements a Model-Aware RAG pipeline that dynamically adjusts chunk sizes to optimize retrieval for both token-constrained and large-context embedding models.

📄 Abstract

Existing RAG systems often rely on fixed chunking strategies that fail to account for model-specific constraints. This project introduces an adaptive pipeline that:

  • Token-Constrained Models: Uses 1500-character chunks for models like BERT/BGE to prevent truncation.
  • Large-Context Models: Uses 5000-character chunks for models like Qwen/Snowflake to maximize semantic coherence.
  • Structure Preservation: Converts JSON corpora to PDF to retain layout and hierarchy before segmentation.

🚀 Key Features

  • Adaptive Chunking: Logic to switch between chunk sizes based on the selected embedding model.
  • Hybrid Retrieval: Combines dense vector retrieval (OpenSearch) with sparse retrieval (BM25).
  • Multi-Hop Reasoning: Optimized for questions requiring evidence from multiple documents (MultiHop-RAG benchmark).
  • Hallucination Reduction: Larger context windows reduce evidence fragmentation, leading to lower hallucination rates.

📂 Repository Structure

  • app.py: Main application entry point (Streamlit interface).
  • JsonToPdf.py: Preprocessing script to convert JSON datasets into structure-preserving PDFs.
  • split.py: Core logic for the adaptive chunking strategy (sentence-aware segmentation).
  • docker-compose-opensearch.yml: Docker setup for the OpenSearch vector database.
  • MultiHop-Rag/: Dataset and core processing modules.

🛠️ Getting Started

Prerequisites

  • Python 3.8+
  • Docker (for OpenSearch)

Installation

  1. Clone the repository:

    git clone [https://github.com/DS-ProjectRepo/rag.git](https://github.com/DS-ProjectRepo/rag.git)
    cd rag
  2. Start the Vector Database (OpenSearch):

    docker-compose -f docker-compose-opensearch.yml up -d
  3. Run the Application:

    python app.py

📊 Performance Highlights

Based on the paper's evaluation:

  • Retrieval: Significant improvements in Hits@10 and MAP@10 using adaptive chunking.
  • Generation: Reduced hallucination rates for inference-heavy queries when using 5000-character chunks with large-context models.

For more details, please refer to the associated research paper.

About

Adaptive chunking & model-aware retrieval for Multi-Hop RAG — hybrid dense+BM25 retrieval on OpenSearch (research implementation)

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages