---
title: Diver-GroupRank-7B
canonical_url: "https://www.modelscope.cn/models/AQ-MedAI/Diver-GroupRank-7B"
md_url: "https://www.modelscope.cn/models/AQ-MedAI/Diver-GroupRank-7B.md"
repository: AQ-MedAI/Diver-GroupRank-7B
chinese_name: Diver-GroupRank-7B
last_updated: 2025-11-19
license: "Apache License 2.0"
model_type:
  - qwen2
architectures:
  - Qwen2ForCausalLM
base_model:
  - Qwen/Qwen2.5-7B-Instruct
base_model_relation: finetune
parameters: 7.6B
tensor_type:
  - BF16
library_name:
  - pytorch
  - transformer
  - safetensors
language:
  - en
  - zh
inference_backends:
  - "deploy_task text/emb"
  - "lmdeploy 0.9.1"
  - "lmdeploy_turbomind 0.9.1"
  - "sglang 0.5.2"
  - "vllm 0.9.2"
downloads: 125
stars: 1
---

# Diver-GroupRank-7B

> Diver-GroupRank-7B - AQ-MedAI 在 ModelScope 开源的模型。GroupRank模型 是我们提出的一种由强化学习驱动的、全新的组级别（Groupwise）重排范式，旨在解决当前检索增强生成（RAG）系统中重排环节的核心困境。现有的重排方法普遍面临一个两难选择：逐点法 (Pointwise): 虽然简单灵活，但因独立评估每个文档而陷入“评价短视陷阱”，无法感知文档间的相对重要性。列表法 (Listwise):…

AQ-MedAI/Diver-GroupRank-7B 是 ModelScope 魔搭社区上的 7.6B 参数机器学习模型，采用 Apache License 2.0 许可，基于 Qwen/Qwen2.5-7B-Instruct 构建，可用 deploy_task text/emb、lmdeploy 0.9.1、lmdeploy_turbomind 0.9.1 部署。

- **Repository**: AQ-MedAI/Diver-GroupRank-7B
- **License**: Apache License 2.0
- **Parameters**: 7.6B
- **Base model**: Qwen/Qwen2.5-7B-Instruct
- **Inference backends**: deploy_task text/emb, lmdeploy 0.9.1, lmdeploy_turbomind 0.9.1, sglang 0.5.2, vllm 0.9.2
- **Downloads**: 125
- **Stars**: 1
- **Last updated**: 2025-11-19

Source: https://www.modelscope.cn/models/AQ-MedAI/Diver-GroupRank-7B

---

### GroupRank 7B 模型简介
GroupRank是一种面向RAG系统的全新LLM重排序范式**Groupwise ranking**，专为解决传统Pointwise与Listwise方法的“两难”而设计。它将查询与一组候选文档共同输入模型，在组内进行对比评估，为每篇文档打出独立相关性分数：既保留了Pointwise的灵活与可扩展性，又引入Listwise的相对比较能力，有效避免“排名近视”和“列表僵化”。
在训练上，GroupRank采用GRPO并引入**异质奖励**：融合NDCG、Recall等排名指标与分布对齐奖励，统一不同组之间的打分标度，提升稳定性与一致性。为缓解高质量标注数据稀缺，我们构建了**高质量检索与重排序数据的合成管线**，既可用于训练重排序模型，也可反哺检索器。

实验显示，GroupRank在BRIGHT与R2MED两大推理型检索基准上取得NDCG@10新SOTA（46.8与52.3），并在传统检索任务上展现良好泛化。

代码、模型与提示词已开源：https://github.com/AQ-MedAI/Diver.git

论文：https://arxiv.org/pdf/2511.11653

相关榜单Bright：https://brightbenchmark.github.io/ 

#### 您可以通过如下git clone命令，或者ModelScope SDK来下载模型

SDK下载
```bash
#安装ModelScope
pip install modelscope
```
```python
#SDK模型下载
from modelscope import snapshot_download
model_dir = snapshot_download('AQ-MedAI/Diver-GroupRank-7B')
```
Git下载
```
#Git模型下载
git clone https://www.modelscope.cn/AQ-MedAI/Diver-GroupRank-7B.git
```

### inference

```python
from vllm import LLM, SamplingParams
from collections import defaultdict
from transformers import AutoTokenizer
import random
import torch

random.seed(666)

sys_prompt = '''Your task is to evaluate and rank documents based on how well they help answer the given query. Follow this evaluation priority:
1. PRIMARY: Usefulness & Helpfulness - Does the document provide actionable information, solutions, or direct answers that help address the user's needs?
2. SECONDARY: Relevance - Does the document contain information related to the query topic?

Evaluation Process:
1. First, identify the user's core intent and what kind of help they need from the query
2. For each document, assess:
   - How directly it addresses the user's intent
   - What actionable information or answers it provides
   - How much it helps solve the user's problem or need
3. Compare documents against each other to ensure proper ranking
4. Assign scores that reflect the relative usefulness ranking

Scoring Scale (0-10):
- 9-10: Extremely helpful, directly answers the query with actionable information
- 7-8: Very helpful, provides substantial useful information for the query
- 5-6: Moderately helpful, contains some useful information but incomplete
- 3-4: Minimally helpful, limited useful information despite topic relevance
- 1-2: Barely helpful, mentions related topics but provides little useful information
- 0: Not helpful at all, cannot assist with answering the query
'''

user_prompt = '''I will provide you {TOPK} documents, each indicated by a numerical identifier []. Score these documents based on their Usefulness and Relevance to the query.
Query:
{QUERY}

Documents:
{PASSAGES}

## Final Output Format
You must structure your response in exactly two parts: provide your brief reasoning process first, then output final scores in JSON format like below, with document IDs as string keys and integer scores as values for all {TOPK} documents. 
The reasoning process and answer are enclosed within <reason> </reason> and <answer> </answer> tags, respectively. Do NOT output anything outside the specified tags. Follow this exact format:
<reason> 
[Analyze each document's usefulness and relevance to the query, explaining your scoring rationale]
</reason>
<answer> 
\```json
{{"[1]": 5, "[2]": 3, "[3]": 8}}
\``` 
</answer>
'''

class GroupReranker:
    def __init__(self, model_path, sys_prompt, user_prompt) -> None:
        # vllm offline inference
        self.llm = LLM(model=model_path, dtype="bfloat16", gpu_memory_utilization=0.9, tensor_parallel_size=torch.cuda.device_count(), max_model_len=32000)
        self.tokenizer = AutoTokenizer.from_pretrained(model_path)
        self.sampling_params = SamplingParams(temperature=0.3, top_p=0.8, max_tokens=8000, logprobs=10)

        self.group_system_prompt = sys_prompt
        self.group_user_prompt = user_prompt

    def rerank(self, query, doc_list):
        docs_str = ''.join(["[{}]. {}\n\n".format(idx+1, doc_text) for idx, doc_text in enumerate(doc_list)])

        group_texts = self.group_user_prompt.format(QUERY=query, PASSAGES=docs_str, TOPK=len(doc_list))

        message = self.tokenizer.apply_chat_template(
            [{'role': 'system', 'content': self.group_system_prompt}, 
            {'role': 'user', 'content': group_texts}], tokenize=False, add_generation_prompt=True)

        output = self.llm.generate(message, self.sampling_params, use_tqdm=True)

        return output

```

<p style="color: lightgrey;">如果您是本模型的贡献者，我们邀请您根据<a href="https://modelscope.cn/docs/ModelScope%E6%A8%A1%E5%9E%8B%E6%8E%A5%E5%85%A5%E6%B5%81%E7%A8%8B%E6%A6%82%E8%A7%88" style="color: lightgrey; text-decoration: underline;">模型贡献文档</a>，及时完善模型卡片内容。</p>
