RAGChain Docs
  • Introduction
  • Quick Start
  • Installation
  • RAGchain Structure
    • File Loader
      • Dataset Loader
        • Ko-Strategy-QA Loader
      • Hwp Loader
      • Rust Hwp Loader
      • Win32 Hwp Loader
      • OCR
        • Nougat Loader
        • Mathpix Markdown Loader
        • Deepdoctection Loader
    • Text Spliter
      • Recursive Text Splitter
      • Markdown Header Splitter
      • HTML Header splitter
      • Code splitter
      • Token splitter
    • Retrieval
      • BM25 Retrieval
      • Hybrid Retrieval
      • Hyde Retrieval
      • VectorDB Retrieval
    • LLM
    • DB
      • MongoDB
      • Pickle DB
    • Reranker
      • BM25 Reranker
      • UPR Reranker
      • TART Reranker
      • MonoT5 Reranker
      • LLM Reranker
    • Benchmark
      • Auto Evaluator
      • Dataset Evaluators
        • Qasper
        • Ko-Strategy-QA
        • Strategy-QA
        • ms-marco
  • Utils
    • Query Decomposition
    • Evidence Extractor
    • Embedding
    • Slim Vector Store
      • Pinecone Slim
      • Chroma Slim
    • File Cache
    • Linker
      • Redis Linker
      • Dynamo Linker
      • Json Linker
    • REDE Search Detector
    • Semantic Clustering
  • Pipeline
    • BasicIngestPipeline
    • BasicRunPipeline
    • RerankRunPipeline
    • ViscondeRunPipeline
  • For Advanced RAG
    • Time-Aware RAG
    • Importance-Aware RAG
Powered by GitBook
On this page
  • Overview
  • Usage
  • Initialize
  • Rerank
  1. RAGchain Structure
  2. Reranker

MonoT5 Reranker

MonoT5Reranker Class Documentation

PreviousTART RerankerNextLLM Reranker

Last updated 1 year ago

Overview

The MonoT5Reranker class is a reranker that uses the MonoT5 model. This model rerank passages based on their relevance to a given query.

Usage

Initialize

To use the MonoT5Reranker class, you first need to create an instance of the class. This is done by calling the class constructor, which can take several optional parameters to customize the behavior of the reranker. If no parameters are provided, the reranker will be initialized with default values.

from RAGchain.reranker import MonoT5Reranker

reranker = MonoT5Reranker()

In the test code provided, no parameters are passed to the constructor, which means the reranker will use the default model ''.

You can set whether you use Automatic Mixed Precision (AMP) for model inference, or use any specific tokens to represent True or False when encoding the input using additional parameter. You can check out API spec at .

Rerank

After the MonoT5Reranker instance has been initialized, you can use the rerank method to rerank a list of passages based on a given query. The rerank method takes two parameters: a query (a string), and a list of passages.

query = "What is query decomposition?"
passages =[...list_of_passages...] # Assume we have list_of_passages retrieved earlier

reranked_passages = reranker.rerank(query, test_passages)
print(reranked_passages)

The rerank method returns a new list of the passages, reordered based on the MonoT5 model. The length of the reranked list is the same as the original list of passages, and the order of the passages may be different, indicating that the passages have been reranked.

castorini/monot5-3b-msmarco-10k
here