E2Rank: Your Text Embedding can Also be an Effective and Efficient Listwise Reranker
📌 Introduction
We introduce E2Rank,
meaning Efficient Embedding-based Ranking
(also meaning Embedding-to-Rank),
which extends a single text embedding model
to perform both high-quality retrieval and listwise reranking,
thereby achieving strong effectiveness with remarkable efficiency.
By applying cosine similarity between the query and
document embeddings as a unified ranking function, the listwise ranking prompt,
which is constructed from the original query and its candidate documents, serves
as an enhanced query enriched with signals from the top-K documents, akin to
pseudo-relevance feedback (PRF) in traditional retrieval models. This design
preserves the efficiency and representational quality of the base embedding model
while significantly improving its reranking performance.
Empirically, E2Rank achieves state-of-the-art results on the BEIR reranking benchmark
and demonstrates competitive performance on the reasoning-intensive BRIGHT benchmark,
with very low reranking latency. We also show that the ranking training process
improves embedding performance on the MTEB benchmark.
Our findings indicate that a single embedding model can effectively unify retrieval and reranking,
offering both computational efficiency and competitive ranking accuracy.
Our work highlights the potential of single embedding models to serve as unified retrieval-reranking engines, offering a practical, efficient, and accurate alternative to complex multi-stage ranking systems.
🚀 Quick Start
Model List
Note:
Embedding Only indicates that the model is trained only with the constrative learning and support embedding tasks, while Embedding + Reranking indicates the full E2Rank model trained with both embedding and reranking objectives (for more detals, please refer to the paper).
Instruction Aware notes whether the model supports customizing the input instruction according to different tasks.
Usage
Embedding Model
The usage of E2Rank as an embedding model is similar to
Qwen3-Embedding. The only difference is that Qwen3-Embedding will automatically append an EOS token, while E2Rank requires users to manully append the special token
<|endoftext|> at the end of each input text.
vLLM Usage (recommended)
1# Requires vllm>=0.8.5
2import torch
3import vllm
4from vllm import LLM
5from vllm.config import PoolerConfig
6
7def get_detailed_instruct(task_description: str, query: str) -> str:
8 return f'Instruct: {task_description}\nQuery:{query}'
9
10# Each query must come with a one-sentence instruction that describes the task
11task = 'Given a web search query, retrieve relevant passages that answer the query'
12
13queries = [
14 get_detailed_instruct(task, 'What is the capital of China?'),
15 get_detailed_instruct(task, 'Explain gravity')
16]
17# No need to add instruction for retrieval documents
18documents = [
19 "The capital of China is Beijing.",
20 "Gravity is a force that attracts two bodies towards each other. It gives weight to physical objects and is responsible for the movement of planets around the sun."
21]
22input_texts = queries + documents
23input_texts = [t + "<|endoftext|>" for t in input_texts]
24
25model = LLM(
26 model="Alibaba-NLP/E2Rank-8B",
27 task="embed",
28 override_pooler_config=PoolerConfig(pooling_type="LAST", normalize=True)
29)
30
31outputs = model.embed(input_texts)
32embeddings = torch.tensor([o.outputs.embedding for o in outputs])
33scores = (embeddings[:2] @ embeddings[2:].T)
34print(scores.tolist())
Transformers Usage
1# Requires transformers>=4.51.0
2import torch
3import torch.nn.functional as F
4
5from torch import Tensor
6from transformers import AutoTokenizer, AutoModel
7
8
9def last_token_pool(last_hidden_states: Tensor, attention_mask: Tensor) -> Tensor:
10 left_padding = (attention_mask[:, -1].sum() == attention_mask.shape[0])
11 if left_padding:
12 return last_hidden_states[:, -1]
13 else:
14 sequence_lengths = attention_mask.sum(dim=1) - 1
15 batch_size = last_hidden_states.shape[0]
16 return last_hidden_states[torch.arange(batch_size, device=last_hidden_states.device), sequence_lengths]
17
18
19def get_detailed_instruct(task_description: str, query: str) -> str:
20 return f'Instruct: {task_description}\nQuery:{query}'
21
22# Each query must come with a one-sentence instruction that describes the task
23task = 'Given a web search query, retrieve relevant passages that answer the query'
24
25queries = [
26 get_detailed_instruct(task, 'What is the capital of China?'),
27 get_detailed_instruct(task, 'Explain gravity')
28]
29# No need to add instruction for retrieval documents
30documents = [
31 "The capital of China is Beijing.",
32 "Gravity is a force that attracts two bodies towards each other. It gives weight to physical objects and is responsible for the movement of planets around the sun."
33]
34input_texts = queries + documents
35input_texts = [t + "<|endoftext|>" for t in input_texts]
36
37tokenizer = AutoTokenizer.from_pretrained('Alibaba-NLP/E2Rank-8B', padding_side='left')
38model = AutoModel.from_pretrained('Alibaba-NLP/E2Rank-8B')
39
40max_length = 8192
41
42# Tokenize the input texts
43batch_dict = tokenizer(
44 input_texts,
45 padding=True,
46 truncation=True,
47 max_length=max_length,
48 return_tensors="pt",
49)
50batch_dict.to(model.device)
51with torch.no_grad():
52 outputs = model(**batch_dict)
53 embeddings = last_token_pool(outputs.last_hidden_state, batch_dict['attention_mask'])
54
55 # normalize embeddings
56 embeddings = F.normalize(embeddings, p=2, dim=1)
57 scores = (embeddings[:2] @ embeddings[2:].T)
58
59print(scores.tolist())
Reranking
For using E2Rank as a reranker, you only need to perform additional processing on the query by adding (part of) the docs that needs to be reranked to the listwise prompt, while the rest is the same as using the embedding model.
vLLM Usage (recommended)
1# Requires vllm>=0.8.5
2import torch
3import vllm
4from vllm import LLM
5from vllm.config import PoolerConfig
6
7model = LLM(
8 model="./checkpoints/E2Rank-8B",
9 task="embed",
10 override_pooler_config=PoolerConfig(pooling_type="LAST", normalize=True)
11)
12tokenizer = model.get_tokenizer()
13
14def get_listwise_prompt(task_description: str, query: str, documents: list[str], num_input_docs: int = 20) -> str:
15 input_docs = documents[:num_input_docs]
16 input_docs = "\n".join([f"[{i}] {doc}" for i, doc in enumerate(input_docs, start=1)])
17 messages = [{
18 "role": "user",
19 "content": f'{task_description}\nDocuments:\n{input_docs}Search Query:{query}'
20 }]
21 text = tokenizer.apply_chat_template(
22 messages,
23 tokenize=False,
24 add_generation_prompt=True,
25 enable_thinking=False,
26 )
27 return text
28
29task = 'Given a web search query and some relevant documents, rerank the documents that answer the query:'
30
31queries = [
32 'What is the capital of China?',
33 'Explain gravity'
34]
35
36# No need to add instruction for retrieval documents
37documents = [
38 "The capital of China is Beijing.",
39 "Gravity is a force that attracts two bodies towards each other. It gives weight to physical objects and is responsible for the movement of planets around the sun."
40]
41documents = [doc + "<|endoftext|>" for doc in documents]
42
43pseudo_queries = [
44 get_listwise_prompt(task, queries[0], documents),
45 get_listwise_prompt(task, queries[1], documents)
46] # no need to add the EOS token here
47
48input_texts = pseudo_queries + documents
49
50outputs = model.embed(input_texts)
51embeddings = torch.tensor([o.outputs.embedding for o in outputs])
52scores = (embeddings[:2] @ embeddings[2:].T)
53print(scores.tolist())
Transformers Usage
1# Requires transformers>=4.51.0
2import torch
3import torch.nn.functional as F
4
5from torch import Tensor
6from transformers import AutoTokenizer, AutoModel
7
8
9tokenizer = AutoTokenizer.from_pretrained('./checkpoints/E2Rank-8B', padding_side='left')
10model = AutoModel.from_pretrained('./checkpoints/E2Rank-8B')
11
12
13def last_token_pool(last_hidden_states: Tensor, attention_mask: Tensor) -> Tensor:
14 left_padding = (attention_mask[:, -1].sum() == attention_mask.shape[0])
15 if left_padding:
16 return last_hidden_states[:, -1]
17 else:
18 sequence_lengths = attention_mask.sum(dim=1) - 1
19 batch_size = last_hidden_states.shape[0]
20 return last_hidden_states[torch.arange(batch_size, device=last_hidden_states.device), sequence_lengths]
21
22
23def get_listwise_prompt(task_description: str, query: str, documents: list[str], num_input_docs: int = 20) -> str:
24 input_docs = documents[:num_input_docs]
25 input_docs = "\n".join([f"[{i}] {doc}" for i, doc in enumerate(input_docs, start=1)])
26 messages = [{
27 "role": "user",
28 "content": f'{task_description}\nDocuments:\n{input_docs}Search Query:{query}'
29 }]
30 text = tokenizer.apply_chat_template(
31 messages,
32 tokenize=False,
33 add_generation_prompt=True,
34 enable_thinking=False,
35 )
36 return text
37
38task = 'Given a web search query and some relevant documents, rerank the documents that answer the query:'
39
40queries = [
41 'What is the capital of China?',
42 'Explain gravity'
43]
44
45# No need to add instruction for retrieval documents
46documents = [
47 "The capital of China is Beijing.",
48 "Gravity is a force that attracts two bodies towards each other. It gives weight to physical objects and is responsible for the movement of planets around the sun."
49]
50documents = [doc + "<|endoftext|>" for doc in documents]
51
52pseudo_queries = [
53 get_listwise_prompt(task, queries[0], documents),
54 get_listwise_prompt(task, queries[1], documents)
55] # no need to add the EOS token here
56
57input_texts = pseudo_queries + documents
58
59
60max_length = 8192
61# Tokenize the input texts
62batch_dict = tokenizer(
63 input_texts,
64 padding=True,
65 truncation=True,
66 max_length=max_length,
67 return_tensors="pt",
68)
69batch_dict.to(model.device)
70with torch.no_grad():
71 outputs = model(**batch_dict)
72 embeddings = last_token_pool(outputs.last_hidden_state, batch_dict['attention_mask'])
73
74 # normalize embeddings
75 embeddings = F.normalize(embeddings, p=2, dim=1)
76 scores = (embeddings[:2] @ embeddings[2:].T)
77
78print(scores.tolist())
End-to-end search
Since E2Rank extends a single text embedding model to perform both high-quality retrieval and listwise reranking, you can directly use it to build an end-to-end search system. By reusing the embeddings computed during the retrieval stage, E2Rank only need to compute the pseudo query's embedding and can efficiently rerank the retrieved documents with minimal additional computational overhead.
Example code is coming soon.
📊 Evaluation
Reranking Benchmark
BEIR
| Covid | NFCorpus | Touche | DBPedia | SciFact | Signal | News | Robust | Avg. |
|---|
| BM25 | 59.47 | 30.75 | 44.22 | 31.80 | 67.89 | 33.05 | 39.52 | 40.70 | 43.43 |
| Zero-shot Listwise Reranker | | | | | | | | | |
| RankGPT-4o | 83.41 | 39.67 | 32.26 | 45.56 | 77.41 | 34.20 | 51.92 | 60.25 | 53.09 |
| RankGPT-4o-mini | 80.03 | 38.73 | 30.91 | 44.54 | 73.14 | 33.64 | 50.91 | 57.41 | 51.16 |
| RankQwen3-14B | 84.45 | 38.94 | 38.30 | 44.52 | 78.64 | 33.58 | 51.24 | 59.66 | 53.67 |
| RankQwen3-32B | 83.48 | 39.22 | 37.13 | 45.00 | 78.22 | 32.12 | 51.08 | 60.74 | 53.37 |
| Fine-tuned Listwise Reranker based on Qwen3 | | | | | | | | | |
| RankQwen3-0.6B | 78.35 | 36.41 | 37.54 | 39.19 | 71.01 | 30.96 | 44.43 | 46.31 | 48.03 |
| RankQwen3-4B | 83.91 | 39.88 | 32.66 | 43.91 | 76.37 | 32.15 | 50.81 | 59.36 | 52.38 |
| RankQwen3-8B | 85.37 | 40.05 | 31.73 | 45.44 | 78.96 | 32.48 | 52.36 | 60.72 | 53.39 |
| Ours | | | | | | | | | |
| E2Rank-0.6B | 79.17 | 38.60 | 41.91 | 41.96 | 73.43 | 35.26 | 52.75 | 53.67 | 52.09 |
| E2Rank-4B | 83.30 | 39.20 | 43.16 | 42.95 | 77.19 | 34.48 | 52.71 | 60.16 | 54.14 |
| E2Rank-8B | 84.09 | 39.08 | 42.06 | 43.44 | 77.49 | 34.01 | 54.25 | 60.34 | 54.35 |
Embedding Benchmark
MTEB (Eng, v1)
| Models | Retr. | Rerank. | Clust. | PairClass. | Class. | STS | Summ. | Avg. |
|---|
| Instructor-xl | 49.26 | 57.29 | 44.74 | 86.62 | 73.12 | 83.06 | 32.32 | 61.79 |
| BGE-large-en-v1.5 | 54.29 | 60.03 | 46.08 | 87.12 | 75.97 | 83.11 | 31.61 | 64.23 |
| GritLM-7B | 53.10 | 61.30 | 48.90 | 86.90 | 77.00 | 82.80 | 29.40 | 64.70 |
| E5-Mistral-7b-v1 | 52.78 | 60.38 | 47.78 | 88.47 | 76.80 | 83.77 | 31.90 | 64.56 |
| Echo-Mistral-7b-v1 | 55.52 | 58.14 | 46.32 | 87.34 | 77.43 | 82.56 | 30.73 | 64.68 |
| LLM2Vec-Mistral-7B | 55.99 | 58.42 | 45.54 | 87.99 | 76.63 | 84.09 | 29.96 | 64.80 |
| LLM2Vec-Meta-LLaMA-3-8B | 56.63 | 59.68 | 46.45 | 87.80 | 75.92 | 83.58 | 30.94 | 65.01 |
| E2Rank-0.6B | 51.74 | 55.97 | 40.85 | 83.93 | 73.66 | 81.41 | 30.90 | 61.25 |
| E2Rank-4B | 55.33 | 59.10 | 44.27 | 87.14 | 77.08 | 84.03 | 30.06 | 64.47 |
| E2Rank-8B | 56.89 | 59.58 | 44.75 | 86.96 | 76.81 | 84.52 | 30.23 | 65.03 |
Note: For baselines, we only compared with models that are trained using public datasets.
🚩 Citation
If this work is helpful, please kindly cite as:
1@misc{liu2025e2rank,
2 title={E2Rank: Your Text Embedding can Also be an Effective and Efficient Listwise Reranker},
3 author={Qi Liu and Yanzhao Zhang and Mingxin Li and Dingkun Long and Pengjun Xie and Jiaxin Mao},
4 year={2025},
5 eprint={2510.22733},
6 archivePrefix={arXiv},
7 primaryClass={cs.CL},
8 url={https://arxiv.org/abs/2510.22733},
9}
If you have any questions, feel free to contact us via qiliu6777[AT]gmail.com or create an issue.