[Paper Review] Fine-Tuning LLaMA for Multi-Stage Text Retrieval
This paper proposes fine-tuning the LLaMA-2 large language model as a dense retriever (RepLLaMA) and a pointwise reranker (RankLLaMA) for multi-stage text retrieval, achieving state-of-the-art performance on MS MARCO and BEIR benchmarks. The approach leverages LLMs' long-context capabilities to represent entire documents holistically, eliminating traditional segmentation and pooling, and demonstrates strong zero-shot effectiveness with open-source model checkpoints.
The effectiveness of multi-stage text retrieval has been solidly demonstrated since before the era of pre-trained language models. However, most existing studies utilize models that predate recent advances in large language models (LLMs). This study seeks to explore potential improvements that state-of-the-art LLMs can bring. We conduct a comprehensive study, fine-tuning the latest LLaMA model both as a dense retriever (RepLLaMA) and as a pointwise reranker (RankLLaMA) for both passage retrieval and document retrieval using the MS MARCO datasets. Our findings demonstrate that the effectiveness of large language models indeed surpasses that of smaller models. Additionally, since LLMs can inherently handle longer contexts, they can represent entire documents holistically, obviating the need for traditional segmenting and pooling strategies. Furthermore, evaluations on BEIR demonstrate that our RepLLaMA-RankLLaMA pipeline exhibits strong zero-shot effectiveness. Model checkpoints from this study are available on HuggingFace.
Motivation & Objective
- To investigate whether state-of-the-art large language models (LLMs) like LLaMA-2 can outperform smaller pre-trained models in multi-stage text retrieval.
- To address limitations of prompt-based LLM reranking, such as non-parallel inference and lack of labeled data utilization, by fine-tuning LLMs as end-to-end retrievers and rerankers.
- To explore the potential of LLMs to represent full documents holistically due to their long-context capacity, removing the need for document segmentation and pooling strategies.
- To establish a fully open-source, optimized pipeline for multi-stage retrieval using LLaMA-2 as a backbone, enabling better effectiveness and inference efficiency.
- To evaluate the zero-shot generalization capability of the proposed RepLLaMA–RankLLaMA pipeline across diverse retrieval benchmarks.
Proposed method
- Fine-tuning LLaMA-2 as a bi-encoder dense retriever (RepLLaMA) using contrastive loss to learn query-document similarity in dense vector space.
- Fine-tuning LLaMA-2 as a pointwise reranker (RankLLaMA) using labeled relevance judgments to directly predict relevance scores for query-document pairs.
- Using the MS MARCO dataset for in-domain fine-tuning on both passage and document retrieval tasks with standard evaluation metrics.
- Leveraging LLaMA-2’s long-context attention to encode entire documents without segmentation, enabling holistic document representation.
- Training both models with a standard supervised fine-tuning regime using contrastive and pointwise ranking losses, respectively.
- Releasing model checkpoints on HuggingFace for open access and reproducibility.

Experimental results
Research questions
- RQ1Can fine-tuned LLaMA-2 models outperform smaller pre-trained models in multi-stage text retrieval?
- RQ2Can LLaMA-2 serve as an effective dense retriever and pointwise reranker when fine-tuned with labeled data?
- RQ3Does the long-context capability of LLaMA-2 eliminate the need for document segmentation and pooling in document retrieval?
- RQ4How effective is the RepLLaMA–RankLLaMA pipeline in zero-shot retrieval across diverse BEIR benchmarks?
- RQ5Can end-to-end fine-tuning of LLMs improve retrieval effectiveness compared to prompt-based generation approaches?
Key findings
- RepLLaMA and RankLLaMA achieve state-of-the-art performance on both passage and document retrieval tasks using the MS MARCO dataset, surpassing previous smaller models.
- The RepLLaMA–RankLLaMA pipeline demonstrates strong zero-shot effectiveness on the BEIR benchmark, indicating robust generalization across diverse domains.
- LLaMA-2’s long-context attention allows holistic document encoding, eliminating the need for traditional segmentation and pooling strategies in document retrieval.
- Fine-tuning LLaMA-2 as a retriever and reranker enables efficient, parallel scoring, overcoming the non-parallelizable, multi-pass decoding of prompt-based LLM reranking.
- The approach effectively utilizes labeled data (e.g., from MS MARCO), enabling better performance than zero-shot prompting methods that ignore such annotations.
- Open-sourced model checkpoints on HuggingFace enable reproducibility and further research on LLM-based retrieval systems.

Read this paper
Open the full text in the Nubint reader and ask about any passage as you read.
Read this paper on NubintThis review was generated by AI from the original paper. Please check the paper before citing it.