Git Product home page Git Product logo

rag-pipelines's Introduction

RAG Pipelines

Retrieval Augmented Generation (RAG) is a method for generating text using additional information fetched from an external data source. Providing relevant documents to the model can greatly increase the accuracy of the generated response.

A RAG pipeline can be tuned in many ways to give more relevant answers. One important way is to improve the relevance of the retrieved context which is input to the LLM. This ensures that the generated answers are coherent and consistent with the context in the original documents.

We have done a detailed analysis of RAG pipelines for Dense and Hybrid Retrieval. For dense retrieval the INSTRUCTOR-XL and all-mpnet-base-v2 models were used. The BM25 retrieval was used for sparse retrieval in the hybrid pipelines.

RAG Pipelines Taxonomy

Performance Evaluation of Rankers and RRF Techniques for Retrieval Pipelines

Paper: Performance Evaluation of Rankers and RRF Techniques for Retrieval Pipelines

In the intricate world of LFQA and RAG, making the most of the LLM’s context window is paramount. Any wasted space or repetitive content limits the depth and breadth of the answers we can extract and generate. It’s a delicate balancing act to lay out the content of the context window appropriately.

With the addition of three rankers, viz., DiversityRanker, LostInTheMiddleRanker, Similarity rankers and RRF techniques, we aim to address these challenges and improve the answers generated by the LFQA/RAG pipelines. We have done a comparative study of adding different combinations of rankers in a Retrieval pipeline and evaluated the results on four metrics, viz., Normalized Discounted Cumulative Gain (NDCG), Mean Average Precision (MAP), Recall and Precision .

The following rankers were used:

  • Diversity Ranker: The Diversity Ranker enhances the diversity of the paragraphs selected for the context window.

  • Lost In The Middle Ranker: The Lost In The Middle Ranker optimizes the layout of the selected documents in the LLM’s context window.

  • Transformers Similarity Ranker: The Transformers Similarity Ranker ranks Documents based on how similar they are to the query. It uses a pre-trained cross-encoder model to embed both the query and the Documents. It then compares the embeddings to determine how similar they are.

In our study, we consider the following cases of retrieval:

  • Dense Retrieval

Dense Pipeline with Rankers

  • Hybrid Retrieval

To combine the results for Hybrid retrieval, Reciprocal Rank Fusion (RRF) was used.

Hybrid Pipeline with Rankers

Usage

To run the retreival pipelines, you will need to clone this repository and install the required libraries.

  1. Install the rag-pipelines package:
git clone https://github.com/avnlp/rag-pipelines
cd rag-pipelines
pip install -e .
  1. To add the data to an index in Pinecone using the INSTRUCTOR-XL embedding model:
cd src/rag_pipelines/indexing_pipeline/fiqa
python pinecone_instructor_index.py
  1. To run a specific pipeline you will have to go that file path and then run the file. For example, running the dense retreival pipeline using the INSTRUCTOR-XL embedding model:
cd src/rag_pipelines/rankers/instructor_xl/fiqa/
python dense.py

License

The source files are distributed under the MIT License.

rag-pipelines's People

Contributors

awinml avatar vrunm avatar

Stargazers

Nur Arifin Akbar avatar  avatar  avatar Mike Oller avatar

Watchers

Kostas Georgiou avatar

Forkers

loken14

rag-pipelines's Issues

Update Pipelines to conform with new API

Describe the Issue:

The new Haystack version introduced changes in the API for the document stores and embedders. The pipelines need to be updated to reflect the new changes.

The version of Haystack will be bumped the latest release and unpinned.

Changes required:

  • Update Pipelines with Rankers
  • Update RAG Pipelines with Rankers

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.