nielsr HF Staff commited on
Commit
f04af83
·
verified ·
1 Parent(s): 25c03d1

Improve model card: Add pipeline tag, library name, and project page

Browse files

This PR enhances the model card for the ReasonRank model by:
- Adding the `pipeline_tag: text-ranking` for better discoverability on the Hugging Face Hub.
- Specifying `library_name: transformers` to indicate compatibility and enable the "how to use" widget.
- Including a link to the project page: https://brightbenchmark.github.io/.
- Providing a concise Python code snippet for basic inference, enabling users to quickly get started with the model.

Files changed (1) hide show
  1. README.md +123 -5
README.md CHANGED
@@ -1,21 +1,139 @@
1
  ---
2
- license: mit
 
3
  datasets:
4
  - liuwenhan/reasonrank_data_sft
5
  - liuwenhan/reasonrank_data_rl
6
  - liuwenhan/reasonrank_data_13k
7
  language:
8
  - en
9
- base_model:
10
- - Qwen/Qwen2.5-32B-Instruct
 
 
 
 
 
11
  ---
12
 
 
 
13
  ## Introduction
14
- This is the model trained in our paper: ReasonRank: Empowering Passage Ranking with Strong Reasoning Ability ([📝arXiv](https://arxiv.org/abs/2508.07050)). Please refer our [🧩github repository](https://github.com/8421BCD/ReasonRank) for the usage of reasonrank-32B.
 
 
 
 
 
 
15
 
16
  ## Model Performance
17
  <p align="center">
18
  <img width="90%" alt="image" src="https://8421bcd.oss-cn-beijing.aliyuncs.com/img/image-20250810163757771.png" />
19
  </p>
20
 
21
- 🌹 If you use this model, please ✨star our <a href="https://github.com/8421BCD/reasonrank" target="_blank">GitHub repository</a> to support us. Your star means a lot!
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  ---
2
+ base_model:
3
+ - Qwen/Qwen2.5-32B-Instruct
4
  datasets:
5
  - liuwenhan/reasonrank_data_sft
6
  - liuwenhan/reasonrank_data_rl
7
  - liuwenhan/reasonrank_data_13k
8
  language:
9
  - en
10
+ license: mit
11
+ pipeline_tag: text-ranking
12
+ library_name: transformers
13
+ tags:
14
+ - reranking
15
+ - reasoning
16
+ - qwen
17
  ---
18
 
19
+ # ReasonRank: Empowering Passage Ranking with Strong Reasoning Ability
20
+
21
  ## Introduction
22
+ This is the model trained in our paper: **ReasonRank: Empowering Passage Ranking with Strong Reasoning Ability** ([📝arXiv](https://arxiv.org/abs/2508.07050)).
23
+
24
+ Large Language Model (LLM) based listwise ranking has shown superior performance in many passage ranking tasks. With the development of Large Reasoning Models, many studies have demonstrated that step-by-step reasoning during test-time helps improve listwise ranking performance. ReasonRank addresses the scarcity of reasoning-intensive training data by proposing an automated reasoning-intensive training data synthesis framework. To empower the listwise reranker with strong reasoning ability, we further propose a two-stage post-training approach, which includes a cold-start supervised fine-tuning (SFT) stage for reasoning pattern learning and a reinforcement learning (RL) stage for further ranking ability enhancement.
25
+
26
+ Please refer to our [🧩GitHub repository](https://github.com/8421BCD/ReasonRank) for detailed usage instructions and code.
27
+
28
+ Project page: [https://brightbenchmark.github.io/](https://brightbenchmark.github.io/)
29
 
30
  ## Model Performance
31
  <p align="center">
32
  <img width="90%" alt="image" src="https://8421bcd.oss-cn-beijing.aliyuncs.com/img/image-20250810163757771.png" />
33
  </p>
34
 
35
+ ## Sample Usage
36
+
37
+ You can use this model with the `transformers` library. Here is a basic example to perform inference. Note that the exact prompt construction for ReasonRank is critical for performance and should ideally follow the `create_prompt` function in the original [GitHub repository's `rerank/rank_listwise_os_llm.py` file](https://github.com/8421BCD/ReasonRank/blob/main/rerank/rank_listwise_os_llm.py). The example below provides a simplified structure for demonstration.
38
+
39
+ ```python
40
+ from transformers import AutoModelForCausalLM, AutoTokenizer, GenerationConfig
41
+ import torch
42
+
43
+ # Load the model and tokenizer
44
+ model_id = "liuwenhan/reasonrank-32B" # Assuming this is the model being documented
45
+ model = AutoModelForCausalLM.from_pretrained(
46
+ model_id,
47
+ torch_dtype=torch.bfloat16, # or torch.float16 depending on your GPU and needs
48
+ device_map="auto",
49
+ trust_remote_code=True # Required for custom modeling files (Qwen components)
50
+ ).eval()
51
+ tokenizer = AutoTokenizer.from_pretrained(model_id, trust_remote_code=True)
52
+
53
+ # Example query and passages
54
+ query = "What is the capital of France?"
55
+ passages = [
56
+ "Paris is the capital and most populous city of France.",
57
+ "London is the capital of England and the United Kingdom.",
58
+ "The Eiffel Tower is a famous landmark in Paris.",
59
+ "France is a country in Western Europe."
60
+ ]
61
+
62
+ # Construct the input messages for Qwen's chat template.
63
+ # For ReasonRank's specific prompt structure, refer to the original GitHub repository's
64
+ # `rerank/rank_listwise_os_llm.py` file and `add_prefix_prompt`/`add_post_prompt` functions.
65
+ # This example uses a general Qwen-like structure for demonstration.
66
+ system_prompt = "You are a helpful and intelligent assistant."
67
+ user_prefix = f"For the query: '{query}', please rank the following passages from most relevant to least relevant.\
68
+ "
69
+ passage_list_str = "\
70
+ ".join([f"[{i+1}] {p}" for i, p in enumerate(passages)])
71
+ user_suffix = "\
72
+ Now, please generate the reasoning process and the ranked list of passages."
73
+
74
+ messages = [
75
+ {"role": "system", "content": system_prompt},
76
+ {"role": "user", "content": f"{user_prefix}{passage_list_str}{user_suffix}"}
77
+ ]
78
+
79
+ # Apply the chat template to get the final prompt string
80
+ prompt = tokenizer.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
81
+
82
+ # Tokenize the input
83
+ inputs = tokenizer(prompt, return_tensors="pt", padding=True).to(model.device)
84
+
85
+ # Generate response
86
+ # Use generation_config from the model if available, otherwise define
87
+ generation_config = model.generation_config if model.generation_config else GenerationConfig()
88
+ generation_config.max_new_tokens = 512
89
+ generation_config.do_sample = False # For greedy decoding
90
+ generation_config.temperature = 0.1 # Keep temperature low for ranking tasks
91
+ generation_config.top_p = 0.95
92
+
93
+
94
+ with torch.no_grad():
95
+ outputs = model.generate(
96
+ **inputs,
97
+ generation_config=generation_config
98
+ )
99
+
100
+ # Decode the output
101
+ response = tokenizer.decode(outputs[0][inputs["input_ids"].shape[1]:], skip_special_tokens=True)
102
+ print(f"Query: {query}\
103
+ Response:\
104
+ {response}")
105
+
106
+ # Expected (simplified) output might look like:
107
+ # Response:
108
+ # Reasoning: The query asks for the capital of France. Passage [1] directly states "Paris is the capital and most populous city of France."
109
+ # This makes it the most relevant. Other passages are less direct or irrelevant.
110
+ # Ranked List:
111
+ # 1. [1] Paris is the capital and most populous city of France.
112
+ # 2. [3] The Eiffel Tower is a famous landmark in Paris.
113
+ # 3. [4] France is a country in Western Europe.
114
+ # 4. [2] London is the capital of England and the United Kingdom.
115
+ ```
116
+
117
+ ## Citation
118
+
119
+ If you find this work helpful, please cite our papers:
120
+
121
+ ```bibtex
122
+ @misc{liu2025reasonrankempoweringpassageranking,
123
+ title={ReasonRank: Empowering Passage Ranking with Strong Reasoning Ability},
124
+ author={Wenhan Liu and Xinyu Ma and Weiwei Sun and Yutao Zhu and Yuchen Li and Dawei Yin and Zhicheng Dou},
125
+ year={2025},
126
+ eprint={2508.07050},
127
+ archivePrefix={arXiv},
128
+ primaryClass={cs.IR},
129
+ url={https://arxiv.org/abs/2508.07050},
130
+ }
131
+ ```
132
+
133
+ ## License
134
+
135
+ This project is released under the [MIT License](https://opensource.org/licenses/MIT).
136
+
137
+ ## Acknowledgement
138
+
139
+ The inference codes and training implementation build upon [RankLLM](https://github.com/castorini/rank_llm), [Llama Factory](https://github.com/hiyouga/LLaMA-Factory) and [verl](https://github.com/volcengine/verl). Our work is based on the [Qwen2.5](https://huggingface.co/Qwen/Qwen2.5-7B-Instruct) model series, and we sincerely thank the Qwen team for their outstanding contributions to the open-source community.