Views
No views yet
| Model | cMedQA1.0 | cMedQA2.0 | MMarcoReranking | T2Reranking | Avg. |
|---|---|---|---|---|---|
| LdIR-Qwen2-reranker-1.5B | 86.50 | 87.11 | 39.35 | 68.84 | 70.45 |
| zpoint-large-embedding-zh | 91.11 | 90.07 | 38.87 | 69.29 | 72.34 |
| xiaobu-embedding-v2 | 90.96 | 90.41 | 39.91 | 69.03 | 72.58 |
| Conan-embedding-v1 | 91.39 | 89.72 | 41.58 | 68.36 | 72.76 |
| ListConRanker | 90.55 | 89.38 | 43.88 | 69.17 | 73.25 |
| - w/o Iterative Inference | 90.20 | 89.98 | 37.52 | 69.17 | 71.72 |
1from transfoermers import AutoModelForSequenceClassification, AutoTokenizer
2
3reranker = AutoModelForSequenceClassification.from_pretrained('ByteDance/ListConRanker', trust_remote_code=True)
4
5# [query, passages_1, passage_2, ..., passage_n]
6batch = [
7 [
8 '皮蛋是寒性的食物吗', # query
9 '营养医师介绍皮蛋是属于凉性的食物,中医认为皮蛋可治眼疼、牙疼、高血压、耳鸣眩晕等疾病。体虚者要少吃。', # passage_1
10 '皮蛋这种食品是在中国地域才常见的传统食品,它的生长汗青也是非常的悠长。', # passage_2
11 '喜欢皮蛋的人会觉得皮蛋是最美味的食物,不喜欢皮蛋的人则觉得皮蛋是黑暗料理,尤其很多外国朋友都不理解我们吃皮蛋的习惯' # passage_3
12 ],
13 [
14 '月有阴晴圆缺的意义', # query
15 '形容的是月所有的状态,晴朗明媚,阴沉混沌,有月圆时,但多数时总是有缺陷。', # passage_1
16 '人有悲欢离合,月有阴晴圆缺这句话意思是人有悲欢离合的变迁,月有阴晴圆缺的转换。', # passage_2
17 '既然是诗歌,又哪里会有真正含义呢? 大概可以说:人生有太多坎坷,苦难,从容坦荡面对就好。', # passage_3
18 '一零七六年苏轼贬官密州,时年四十一岁的他政治上很不得志,时值中秋佳节,非常想念自己的弟弟子由内心颇感忧郁,情绪低沉,有感而发写了这首词。' # passage_4
19 ]
20]
21
22# for conventional inference, please manage the batch size by yourself
23scores = reranker.multi_passage(batch)
24print(scores)
25# [0.5126814246177673, 0.33125635981559753, 0.3642643094062805, 0.6367220282554626, 0.7166246175765991, 0.4281482696533203, 0.3530198335647583]
26
27# for iterative inferfence, only a batch size of 1 is supported
28# the scores do not carry similarity meaning and are only used for ranking
29scores = reranker.multi_passage_in_iterative_inference(batch[0])
30print(scores)
31# [0.5126813650131226, 0.3312564790248871, 0.3642643094062805]
32
33tokenizer = AutoTokenizer.from_pretrained('ByteDance/ListConRanker')
34inputs = tokenizer(
35 [
36 [
37 "皮蛋是寒性的食物吗",
38 "营养医师介绍皮蛋是属于凉性的食物,中医认为皮蛋可治眼疼、牙疼、高血压、耳鸣眩晕等疾病。体虚者要少吃。",
39 ],
40 [
41 "皮蛋是寒性的食物吗",
42 "皮蛋这种食品是在中国地域才常见的传统食品,它的生长汗青也是非常的悠长。",
43 ],
44 [
45 "月有阴晴圆缺的意义",
46 "形容的是月所有的状态,晴朗明媚,阴沉混沌,有月圆时,但多数时总是有缺陷。",
47 ],
48 ],
49 return_tensors="pt",
50 padding=True,
51 truncation=False
52)
53# tensor([[0.5070], [0.3334], [0.6294]], device='cuda:0', dtype=torch.float16, grad_fn=<ViewBackward0>)sentence_transformers library (We do not recommend using sentence_transformers. Because its truncation strategy may not match the model design, which may lead to performance degradation.):1from sentence_transformers import CrossEncoder
2
3model = CrossEncoder('ByteDance/ListConRanker', trust_remote_code=True)
4
5inputs = [
6 [
7 "皮蛋是寒性的食物吗",
8 "营养医师介绍皮蛋是属于凉性的食物,中医认为皮蛋可治眼疼、牙疼、高血压、耳鸣眩晕等疾病。体虚者要少吃。",
9 ],
10 [
11 "皮蛋是寒性的食物吗",
12 "皮蛋这种食品是在中国地域才常见的传统食品,它的生长汗青也是非常的悠长。",
13 ],
14 [
15 "月有阴晴圆缺的意义",
16 "形容的是月所有的状态,晴朗明媚,阴沉混沌,有月圆时,但多数时总是有缺陷。",
17 ],
18]
19scores = model.predict(inputs)
20print(scores)python3 eval_listconranker_iterative_inference.pypython3 eval_listconranker.py