File size: 5,905 Bytes
19857b7
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
03e2a83
 
 
 
 
 
 
19857b7
 
03e2a83
 
 
19857b7
 
03e2a83
19857b7
03e2a83
19857b7
03e2a83
 
19857b7
03e2a83
 
19857b7
03e2a83
 
 
 
 
 
19857b7
 
03e2a83
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
19857b7
03e2a83
c64f08c
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
---
license: mit
language:
- en
- zh
tags:
- mteb
- text-embeddings-inference
- llama-cpp
- gguf-my-repo
pipeline_tag: text-classification
library_name: sentence-transformers
base_model: BAAI/bge-reranker-base
model-index:
- name: bge-reranker-base
  results:
  - task:
      type: Reranking
    dataset:
      name: MTEB CMedQAv1
      type: C-MTEB/CMedQAv1-reranking
      config: default
      split: test
      revision: None
    metrics:
    - type: map
      value: 81.27206722525007
    - type: mrr
      value: 84.14238095238095
  - task:
      type: Reranking
    dataset:
      name: MTEB CMedQAv2
      type: C-MTEB/CMedQAv2-reranking
      config: default
      split: test
      revision: None
    metrics:
    - type: map
      value: 84.10369934291236
    - type: mrr
      value: 86.79376984126984
  - task:
      type: Reranking
    dataset:
      name: MTEB MMarcoReranking
      type: C-MTEB/Mmarco-reranking
      config: default
      split: dev
      revision: None
    metrics:
    - type: map
      value: 35.4600511272538
    - type: mrr
      value: 34.60238095238095
  - task:
      type: Reranking
    dataset:
      name: MTEB T2Reranking
      type: C-MTEB/T2Reranking
      config: default
      split: dev
      revision: None
    metrics:
    - type: map
      value: 67.27728847727172
    - type: mrr
      value: 77.1315192743764
---

# turingevo/bge-reranker-base-Q4_K_M-GGUF
This model was converted to GGUF format from [`BAAI/bge-reranker-base`](https://huggingface.co/BAAI/bge-reranker-base) using llama.cpp via the ggml.ai's [GGUF-my-repo](https://huggingface.co/spaces/ggml-org/gguf-my-repo) space.
Refer to the [original model card](https://huggingface.co/BAAI/bge-reranker-base) for more details on the model.


|  |  |
|--|--|
| AI学习交流qq群 | 873673497  |  
| 官网 | turingevo.com |
| 邮箱 | [email protected] |
| github | https://github.com/turingevo |
| huggingface | https://huggingface.co/turingevo |


## Use with llama.cpp

Invoke the llama.cpp server

### Server:

```bash
#!/bin/bash

## see if port 8000 in use:
# sudo netstat -lnp |grep 8000

prefix=/media/wmx/soft2/huggingface_cache/BAAI/bge-reranker-base
model_path=$prefix/bge-reranker-base-q4_k_m.gguf

llama_prefix=/media/wmx/ws1/workspace/ai/llama.cpp/bin/cuda/
llama_path=$llama_prefix/bin/llama-server

export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:${llama_prefix}/lib

$llama_path --rerank -m $model_path --host 0.0.0.0 --port 8000

```

### api_cliet.py
```python
import requests

# 配置参数
ENDPOINT = "http://0.0.0.0:8000/reranking"
MODEL_NAME = "bge-reranker-base"  # 替换为实际使用的重排序模型

# 多组测试用例定义
TEST_CASES = [
    {
        "query": "人工智能应用",
        "documents": [
            "机器学习在医疗诊断中的应用",
            "深度学习在自动驾驶中的最新进展",
            "自然语言处理技术发展史",
            "人工智能伦理问题探讨"
        ]
    },
    {
        "query": "量子计算的最新突破",
        "documents": [
            "量子计算在密码学中的应用",
            "超导量子比特的稳定性研究",
            "经典计算机与量子计算机对比分析",
            "量子纠缠现象的实验验证"
        ]
    },
    {
        "query": "糖尿病治疗的新方法",
        "documents": [
            "胰岛素泵治疗糖尿病的优势",
            "干细胞疗法在糖尿病治疗中的潜力",
            "糖尿病患者的饮食管理指南",
            "新型口服降糖药物的临床试验结果"
        ]
    }
]

def rerank_documents(query, documents):
    """调用 server 重排序接口"""
    payload = {
        "model": MODEL_NAME,
        "query": query,
        "documents": documents
    }

    try:
        response = requests.post(ENDPOINT, json=payload)
        response.raise_for_status()  # 检查HTTP错误
        return response.json()
    except requests.exceptions.RequestException as e:
        print(f"API请求失败: {e}")
        return None

# 执行所有测试用例
for i, case in enumerate(TEST_CASES, start=1):
    print(f"\n=== 测试用例 #{i} ===")
    print(f"查询: {case['query']}")
    result = rerank_documents(case["query"], case["documents"])
    
    if result:
        print("重排序结果(按相关性降序):")
        # ✅ 在这里添加排序逻辑
        sorted_results = sorted(result["results"], key=lambda x: x["relevance_score"], reverse=True)
        
        for doc in sorted_results:
            print(f"文档 {doc['index']+1}: 得分={doc['relevance_score']:.4f}, 内容={case['documents'][doc['index']]}")
    else:
        print("未获取到有效结果")

```

output :

```bash
=== 测试用例 #1 ===
查询: 人工智能应用
重排序结果(按相关性降序):
文档 1: 得分=0.5315, 内容=机器学习在医疗诊断中的应用
文档 4: 得分=0.2609, 内容=人工智能伦理问题探讨
文档 2: 得分=-2.3431, 内容=深度学习在自动驾驶中的最新进展
文档 3: 得分=-3.8849, 内容=自然语言处理技术发展史

=== 测试用例 #2 ===
查询: 量子计算的最新突破
重排序结果(按相关性降序):
文档 1: 得分=-0.7904, 内容=量子计算在密码学中的应用
文档 3: 得分=-0.8329, 内容=经典计算机与量子计算机对比分析
文档 4: 得分=-1.4564, 内容=量子纠缠现象的实验验证
文档 2: 得分=-3.1111, 内容=超导量子比特的稳定性研究

=== 测试用例 #3 ===
查询: 糖尿病治疗的新方法
重排序结果(按相关性降序):
文档 2: 得分=2.1797, 内容=干细胞疗法在糖尿病治疗中的潜力
文档 4: 得分=-0.1641, 内容=新型口服降糖药物的临床试验结果
文档 1: 得分=-0.3959, 内容=胰岛素泵治疗糖尿病的优势
文档 3: 得分=-0.5034, 内容=糖尿病患者的饮食管理指南
```