File size: 20,106 Bytes
d638293
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
279c87c
d638293
279c87c
d638293
279c87c
d638293
279c87c
d638293
279c87c
d638293
279c87c
d638293
279c87c
d638293
279c87c
d638293
279c87c
d638293
279c87c
d638293
279c87c
d638293
279c87c
d638293
279c87c
d638293
279c87c
d638293
279c87c
d638293
279c87c
d638293
279c87c
d638293
279c87c
d638293
279c87c
d638293
279c87c
d638293
279c87c
d638293
 
 
279c87c
d638293
279c87c
d638293
279c87c
d638293
279c87c
d638293
279c87c
d638293
279c87c
d638293
279c87c
d638293
279c87c
d638293
 
 
 
 
 
 
 
 
 
279c87c
d638293
279c87c
d638293
279c87c
d638293
279c87c
d638293
279c87c
d638293
279c87c
d638293
279c87c
d638293
279c87c
d638293
279c87c
d638293
279c87c
d638293
279c87c
d638293
279c87c
d638293
279c87c
d638293
279c87c
d638293
279c87c
d638293
279c87c
d638293
279c87c
d638293
279c87c
d638293
279c87c
d638293
279c87c
d638293
 
 
 
 
279c87c
d638293
279c87c
d638293
279c87c
d638293
279c87c
d638293
 
 
 
 
279c87c
d638293
279c87c
d638293
 
 
 
 
 
 
 
 
 
279c87c
d638293
279c87c
d638293
279c87c
d638293
279c87c
d638293
279c87c
d638293
279c87c
d638293
279c87c
d638293
279c87c
d638293
279c87c
d638293
279c87c
d638293
279c87c
d638293
279c87c
d638293
279c87c
d638293
279c87c
d638293
279c87c
d638293
279c87c
d638293
279c87c
d638293
279c87c
d638293
279c87c
d638293
279c87c
d638293
279c87c
d638293
 
 
279c87c
d638293
279c87c
d638293
279c87c
d638293
279c87c
d638293
279c87c
d638293
279c87c
d638293
279c87c
d638293
279c87c
d638293
 
 
 
 
 
 
 
 
 
279c87c
d638293
279c87c
d638293
279c87c
d638293
279c87c
d638293
279c87c
d638293
279c87c
d638293
279c87c
d638293
279c87c
d638293
279c87c
d638293
279c87c
d638293
279c87c
d638293
279c87c
d638293
279c87c
d638293
279c87c
d638293
279c87c
d638293
279c87c
d638293
279c87c
d638293
279c87c
d638293
279c87c
d638293
279c87c
d638293
279c87c
d638293
 
 
279c87c
d638293
279c87c
d638293
279c87c
d638293
279c87c
d638293
279c87c
d638293
279c87c
d638293
279c87c
d638293
279c87c
d638293
 
 
 
 
 
 
 
 
 
279c87c
d638293
279c87c
d638293
279c87c
d638293
279c87c
d638293
279c87c
d638293
279c87c
d638293
279c87c
d638293
279c87c
d638293
279c87c
d638293
279c87c
d638293
279c87c
d638293
279c87c
d638293
279c87c
d638293
279c87c
d638293
279c87c
d638293
279c87c
d638293
279c87c
d638293
279c87c
d638293
279c87c
d638293
279c87c
d638293
279c87c
d638293
 
 
279c87c
d638293
279c87c
d638293
279c87c
d638293
279c87c
d638293
279c87c
d638293
279c87c
d638293
279c87c
d638293
279c87c
d638293
 
 
 
 
 
 
 
 
 
279c87c
d638293
279c87c
d638293
279c87c
d638293
279c87c
d638293
279c87c
d638293
279c87c
d638293
 
 
279c87c
d638293
279c87c
d638293
279c87c
d638293
279c87c
d638293
279c87c
d638293
279c87c
d638293
279c87c
d638293
279c87c
d638293
279c87c
d638293
279c87c
d638293
279c87c
d638293
279c87c
d638293
279c87c
d638293
279c87c
d638293
 
 
279c87c
d638293
279c87c
d638293
279c87c
d638293
279c87c
d638293
279c87c
d638293
279c87c
d638293
279c87c
d638293
279c87c
d638293
 
 
 
 
 
 
 
 
 
279c87c
d638293
279c87c
d638293
279c87c
d638293
279c87c
d638293
279c87c
d638293
279c87c
d638293
279c87c
d638293
279c87c
d638293
279c87c
d638293
279c87c
d638293
279c87c
d638293
279c87c
d638293
279c87c
d638293
279c87c
d638293
279c87c
d638293
279c87c
d638293
279c87c
d638293
279c87c
d638293
279c87c
d638293
279c87c
d638293
279c87c
d638293
 
 
279c87c
d638293
279c87c
d638293
279c87c
d638293
279c87c
d638293
279c87c
d638293
279c87c
d638293
279c87c
d638293
279c87c
d638293
 
 
 
 
 
 
 
 
 
279c87c
d638293
279c87c
d638293
279c87c
d638293
279c87c
d638293
279c87c
d638293
279c87c
d638293
279c87c
d638293
279c87c
d638293
279c87c
d638293
279c87c
d638293
279c87c
d638293
279c87c
d638293
279c87c
d638293
279c87c
d638293
279c87c
d638293
279c87c
d638293
279c87c
d638293
279c87c
d638293
279c87c
d638293
279c87c
d638293
279c87c
d638293
279c87c
d638293
 
 
279c87c
d638293
279c87c
d638293
279c87c
d638293
279c87c
d638293
279c87c
d638293
 
 
279c87c
f0e7821
d638293
 
279c87c
d638293
 
f0e7821
5df70ea
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
056ca5e
 
5df70ea
 
 
 
 
 
d638293
5df70ea
 
 
 
 
 
f0e7821
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
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
---
tags:
- mteb
model-index:
- name: Zhihui_LLM_Embedding
  results:
  - task:
      type: Retrieval
    dataset:
      type: C-MTEB/CmedqaRetrieval
      name: MTEB CmedqaRetrieval
      config: default
      split: dev
      revision: None
    metrics:
    - type: map_at_1
      value: 29.012
    - type: map_at_10
      value: 41.998000000000005
    - type: map_at_100
      value: 43.821
    - type: map_at_1000
      value: 43.924
    - type: map_at_3
      value: 37.804
    - type: map_at_5
      value: 40.025
    - type: mrr_at_1
      value: 43.536
    - type: mrr_at_10
      value: 51.413
    - type: mrr_at_100
      value: 52.329
    - type: mrr_at_1000
      value: 52.366
    - type: mrr_at_3
      value: 49.058
    - type: mrr_at_5
      value: 50.291
    - type: ndcg_at_1
      value: 43.536
    - type: ndcg_at_10
      value: 48.693
    - type: ndcg_at_100
      value: 55.644000000000005
    - type: ndcg_at_1000
      value: 57.354000000000006
    - type: ndcg_at_3
      value: 43.627
    - type: ndcg_at_5
      value: 45.462
    - type: precision_at_1
      value: 43.536
    - type: precision_at_10
      value: 10.552999999999999
    - type: precision_at_100
      value: 1.624
    - type: precision_at_1000
      value: 0.184
    - type: precision_at_3
      value: 24.314
    - type: precision_at_5
      value: 17.299
    - type: recall_at_1
      value: 29.012
    - type: recall_at_10
      value: 59.123000000000005
    - type: recall_at_100
      value: 87.783
    - type: recall_at_1000
      value: 99.078
    - type: recall_at_3
      value: 43.474000000000004
    - type: recall_at_5
      value: 49.557
  - task:
      type: Retrieval
    dataset:
      type: C-MTEB/CovidRetrieval
      name: MTEB CovidRetrieval
      config: default
      split: dev
      revision: None
    metrics:
    - type: map_at_1
      value: 73.235
    - type: map_at_10
      value: 80.87100000000001
    - type: map_at_100
      value: 81.10300000000001
    - type: map_at_1000
      value: 81.105
    - type: map_at_3
      value: 79.171
    - type: map_at_5
      value: 80.163
    - type: mrr_at_1
      value: 73.235
    - type: mrr_at_10
      value: 80.80000000000001
    - type: mrr_at_100
      value: 81.024
    - type: mrr_at_1000
      value: 81.026
    - type: mrr_at_3
      value: 79.15299999999999
    - type: mrr_at_5
      value: 80.133
    - type: ndcg_at_1
      value: 73.34
    - type: ndcg_at_10
      value: 84.387
    - type: ndcg_at_100
      value: 85.348
    - type: ndcg_at_1000
      value: 85.411
    - type: ndcg_at_3
      value: 80.97
    - type: ndcg_at_5
      value: 82.757
    - type: precision_at_1
      value: 73.34
    - type: precision_at_10
      value: 9.631
    - type: precision_at_100
      value: 1.005
    - type: precision_at_1000
      value: 0.101
    - type: precision_at_3
      value: 28.837000000000003
    - type: precision_at_5
      value: 18.209
    - type: recall_at_1
      value: 73.235
    - type: recall_at_10
      value: 95.311
    - type: recall_at_100
      value: 99.473
    - type: recall_at_1000
      value: 100
    - type: recall_at_3
      value: 86.091
    - type: recall_at_5
      value: 90.411
  - task:
      type: Retrieval
    dataset:
      type: C-MTEB/DuRetrieval
      name: MTEB DuRetrieval
      config: default
      split: dev
      revision: None
    metrics:
    - type: map_at_1
      value: 28.059
    - type: map_at_10
      value: 85.309
    - type: map_at_100
      value: 87.926
    - type: map_at_1000
      value: 87.945
    - type: map_at_3
      value: 59.862
    - type: map_at_5
      value: 75.345
    - type: mrr_at_1
      value: 93.30000000000001
    - type: mrr_at_10
      value: 95.624
    - type: mrr_at_100
      value: 95.647
    - type: mrr_at_1000
      value: 95.649
    - type: mrr_at_3
      value: 95.42500000000001
    - type: mrr_at_5
      value: 95.572
    - type: ndcg_at_1
      value: 93.30000000000001
    - type: ndcg_at_10
      value: 91.338
    - type: ndcg_at_100
      value: 93.38
    - type: ndcg_at_1000
      value: 93.57
    - type: ndcg_at_3
      value: 90.512
    - type: ndcg_at_5
      value: 89.617
    - type: precision_at_1
      value: 93.30000000000001
    - type: precision_at_10
      value: 43.169999999999995
    - type: precision_at_100
      value: 4.868
    - type: precision_at_1000
      value: 0.49100000000000005
    - type: precision_at_3
      value: 80.7
    - type: precision_at_5
      value: 68.12
    - type: recall_at_1
      value: 28.059
    - type: recall_at_10
      value: 91.949
    - type: recall_at_100
      value: 98.777
    - type: recall_at_1000
      value: 99.816
    - type: recall_at_3
      value: 61.699000000000005
    - type: recall_at_5
      value: 79.134
  - task:
      type: Retrieval
    dataset:
      type: C-MTEB/EcomRetrieval
      name: MTEB EcomRetrieval
      config: default
      split: dev
      revision: None
    metrics:
    - type: map_at_1
      value: 57.599999999999994
    - type: map_at_10
      value: 67.169
    - type: map_at_100
      value: 67.654
    - type: map_at_1000
      value: 67.663
    - type: map_at_3
      value: 64.833
    - type: map_at_5
      value: 66.298
    - type: mrr_at_1
      value: 57.599999999999994
    - type: mrr_at_10
      value: 67.169
    - type: mrr_at_100
      value: 67.654
    - type: mrr_at_1000
      value: 67.663
    - type: mrr_at_3
      value: 64.833
    - type: mrr_at_5
      value: 66.298
    - type: ndcg_at_1
      value: 57.599999999999994
    - type: ndcg_at_10
      value: 71.95899999999999
    - type: ndcg_at_100
      value: 74.092
    - type: ndcg_at_1000
      value: 74.323
    - type: ndcg_at_3
      value: 67.212
    - type: ndcg_at_5
      value: 69.892
    - type: precision_at_1
      value: 57.599999999999994
    - type: precision_at_10
      value: 8.7
    - type: precision_at_100
      value: 0.9650000000000001
    - type: precision_at_1000
      value: 0.098
    - type: precision_at_3
      value: 24.7
    - type: precision_at_5
      value: 16.14
    - type: recall_at_1
      value: 57.599999999999994
    - type: recall_at_10
      value: 87
    - type: recall_at_100
      value: 96.5
    - type: recall_at_1000
      value: 98.3
    - type: recall_at_3
      value: 74.1
    - type: recall_at_5
      value: 80.7
  - task:
      type: Retrieval
    dataset:
      type: C-MTEB/MMarcoRetrieval
      name: MTEB MMarcoRetrieval
      config: default
      split: dev
      revision: None
    metrics:
    - type: map_at_1
      value: 72.858
    - type: map_at_10
      value: 81.559
    - type: map_at_100
      value: 81.808
    - type: map_at_1000
      value: 81.813
    - type: map_at_3
      value: 80.018
    - type: map_at_5
      value: 81.04299999999999
    - type: mrr_at_1
      value: 75.27199999999999
    - type: mrr_at_10
      value: 81.989
    - type: mrr_at_100
      value: 82.202
    - type: mrr_at_1000
      value: 82.206
    - type: mrr_at_3
      value: 80.647
    - type: mrr_at_5
      value: 81.53399999999999
    - type: ndcg_at_1
      value: 75.27199999999999
    - type: ndcg_at_10
      value: 84.772
    - type: ndcg_at_100
      value: 85.79599999999999
    - type: ndcg_at_1000
      value: 85.925
    - type: ndcg_at_3
      value: 81.884
    - type: ndcg_at_5
      value: 83.60300000000001
    - type: precision_at_1
      value: 75.27199999999999
    - type: precision_at_10
      value: 10.017
    - type: precision_at_100
      value: 1.051
    - type: precision_at_1000
      value: 0.106
    - type: precision_at_3
      value: 30.578
    - type: precision_at_5
      value: 19.261
    - type: recall_at_1
      value: 72.858
    - type: recall_at_10
      value: 94.197
    - type: recall_at_100
      value: 98.634
    - type: recall_at_1000
      value: 99.63499999999999
    - type: recall_at_3
      value: 86.6
    - type: recall_at_5
      value: 90.692
  - task:
      type: Retrieval
    dataset:
      type: C-MTEB/MedicalRetrieval
      name: MTEB MedicalRetrieval
      config: default
      split: dev
      revision: None
    metrics:
    - type: map_at_1
      value: 56.2
    - type: map_at_10
      value: 62.198
    - type: map_at_100
      value: 62.794000000000004
    - type: map_at_1000
      value: 62.829
    - type: map_at_3
      value: 60.699999999999996
    - type: map_at_5
      value: 61.660000000000004
    - type: mrr_at_1
      value: 56.49999999999999
    - type: mrr_at_10
      value: 62.348000000000006
    - type: mrr_at_100
      value: 62.944
    - type: mrr_at_1000
      value: 62.979
    - type: mrr_at_3
      value: 60.85
    - type: mrr_at_5
      value: 61.809999999999995
    - type: ndcg_at_1
      value: 56.2
    - type: ndcg_at_10
      value: 65.19200000000001
    - type: ndcg_at_100
      value: 68.341
    - type: ndcg_at_1000
      value: 69.392
    - type: ndcg_at_3
      value: 62.163999999999994
    - type: ndcg_at_5
      value: 63.894
    - type: precision_at_1
      value: 56.2
    - type: precision_at_10
      value: 7.46
    - type: precision_at_100
      value: 0.899
    - type: precision_at_1000
      value: 0.098
    - type: precision_at_3
      value: 22.133
    - type: precision_at_5
      value: 14.12
    - type: recall_at_1
      value: 56.2
    - type: recall_at_10
      value: 74.6
    - type: recall_at_100
      value: 89.9
    - type: recall_at_1000
      value: 98.4
    - type: recall_at_3
      value: 66.4
    - type: recall_at_5
      value: 70.6
  - task:
      type: Retrieval
    dataset:
      type: C-MTEB/T2Retrieval
      name: MTEB T2Retrieval
      config: default
      split: dev
      revision: None
    metrics:
    - type: map_at_1
      value: 28.79
    - type: map_at_10
      value: 81.687
    - type: map_at_100
      value: 85.19200000000001
    - type: map_at_1000
      value: 85.232
    - type: map_at_3
      value: 57.145999999999994
    - type: map_at_5
      value: 70.491
    - type: mrr_at_1
      value: 92.21000000000001
    - type: mrr_at_10
      value: 94.303
    - type: mrr_at_100
      value: 94.368
    - type: mrr_at_1000
      value: 94.37
    - type: mrr_at_3
      value: 93.94500000000001
    - type: mrr_at_5
      value: 94.175
    - type: ndcg_at_1
      value: 92.21000000000001
    - type: ndcg_at_10
      value: 88.29599999999999
    - type: ndcg_at_100
      value: 91.268
    - type: ndcg_at_1000
      value: 91.645
    - type: ndcg_at_3
      value: 89.031
    - type: ndcg_at_5
      value: 88.075
    - type: precision_at_1
      value: 92.21000000000001
    - type: precision_at_10
      value: 43.775
    - type: precision_at_100
      value: 5.097
    - type: precision_at_1000
      value: 0.518
    - type: precision_at_3
      value: 77.708
    - type: precision_at_5
      value: 65.473
    - type: recall_at_1
      value: 28.79
    - type: recall_at_10
      value: 87.457
    - type: recall_at_100
      value: 97.21499999999999
    - type: recall_at_1000
      value: 99.14
    - type: recall_at_3
      value: 58.606
    - type: recall_at_5
      value: 73.52300000000001
  - task:
      type: Retrieval
    dataset:
      type: C-MTEB/VideoRetrieval
      name: MTEB VideoRetrieval
      config: default
      split: dev
      revision: None
    metrics:
    - type: map_at_1
      value: 67
    - type: map_at_10
      value: 75.44999999999999
    - type: map_at_100
      value: 75.771
    - type: map_at_1000
      value: 75.776
    - type: map_at_3
      value: 73.867
    - type: map_at_5
      value: 74.837
    - type: mrr_at_1
      value: 67
    - type: mrr_at_10
      value: 75.44999999999999
    - type: mrr_at_100
      value: 75.771
    - type: mrr_at_1000
      value: 75.776
    - type: mrr_at_3
      value: 73.867
    - type: mrr_at_5
      value: 74.837
    - type: ndcg_at_1
      value: 67
    - type: ndcg_at_10
      value: 79.313
    - type: ndcg_at_100
      value: 80.894
    - type: ndcg_at_1000
      value: 80.989
    - type: ndcg_at_3
      value: 76.08500000000001
    - type: ndcg_at_5
      value: 77.845
    - type: precision_at_1
      value: 67
    - type: precision_at_10
      value: 9.13
    - type: precision_at_100
      value: 0.987
    - type: precision_at_1000
      value: 0.099
    - type: precision_at_3
      value: 27.500000000000004
    - type: precision_at_5
      value: 17.36
    - type: recall_at_1
      value: 67
    - type: recall_at_10
      value: 91.3
    - type: recall_at_100
      value: 98.7
    - type: recall_at_1000
      value: 99.4
    - type: recall_at_3
      value: 82.5
    - type: recall_at_5
      value: 86.8
license: cc-by-nc-4.0
language:
- zh
library_name: transformers
---



## Zhihui_LLM_Embedding

### Model Introduction

**Zhihui_LLM_Embedding** is an embedding model specifically designed to enhance Chinese text retrieval capabilities. It is built on a 7B LLM and enhanced bidirectional attention mechanism to improved contextual understanding. The model is trained on an extensive corpus from various fields within an extremely large batch. **Zhihui_LLM_Embedding** excels in retrieval tasks, ranking **1st position** on the C-MTEB leaderboard with a leading performance score of **76.74** as of June 25, 2024.

### Optimization points
* Data source enhancement: Leverages the knowledge of LLMs through three types of distillation methods.(GPT3.5 & GPT4)
    * Data Refinement: LLM scores candidate positive passages to select the most relevant examples.
    * Query Rewriting: LLM generates queries that can be answered by positive documents but are unrelated to negatives, thus enhancing the query's quality and diversity.
    * Query Expansion: Queries are expanded based on multiple topics for long documents.
* Negative example mining: Use multiple methods and different ranges of negative selection to mine hard negative examples. 
* Improved Contrastive Loss: Design a novel InfoNCE loss assigns higher weights to the harder negative examples to improve the fine-grained feature representation of the model.
* Bidirectional-attention: Remove the causal attention of LLMs during contrastive training of decoder-only LLM to produce rich contextualized representations.
* Training efficiency: Using Gradient Cache to scale contrastive learning batches beyond GPU memory constraints allows the model to learn from more challenging negative examples.
* Others: Dataset-Homogenous Batching、cross-batch negative sampling

### Model Details
* Base Decoder-only LLM: [gte-Qwen2-7B-instruct](https://huggingface.co./Alibaba-NLP/gte-Qwen2-7B-instruct) 
* Pooling Methods: Last token
* Embedding Dimension: 3584

### Usage
##### Requirements
```
transformers>=4.40.2
flash_attn>=2.5.8
sentence-transformers>=2.7.0
```
##### How to use
Here is an example of how to encode queries and passages using Huggingface-transformer and Sentence-transformer.
##### Usage (HuggingFace Transformers)
```python
import torch
import torch.nn.functional as F

from torch import Tensor
from transformers import AutoTokenizer, AutoModel


def last_token_pool(last_hidden_states: Tensor, attention_mask: Tensor) -> Tensor:
    left_padding = (attention_mask[:, -1].sum() == attention_mask.shape[0])
    if left_padding:
        return last_hidden_states[:, -1]
    else:
        sequence_lengths = attention_mask.sum(dim=1) - 1
        batch_size = last_hidden_states.shape[0]
        return last_hidden_states[torch.arange(batch_size, device=last_hidden_states.device), sequence_lengths]


def get_detailed_instruct(task_description: str, query: str) -> str:
    return f'Instruct: {task_description}\nQuery: {query}'



task = 'Given a web search query, retrieve relevant passages that answer the query'
queries = [
    get_detailed_instruct(task, "国家法定节假日共多少天"),
    get_detailed_instruct(task, "如何查看好友申请")
]

documents = [
    "一年国家法定节假日为11天。根据公布的国家法定节假日调整方案,调整的主要内容包括:元旦放假1天不变;春节放假3天,放假时间为农历正月初一、初二、初三;“五一”国际劳动节1天不变;“十一”国庆节放假3天;清明节、端午节、中秋节增设为国家法定节假日,各放假1天(农历节日如遇闰月,以第一个月为休假日)。3、允许周末上移下错,与法定节假日形成连休。",
    "这个直接去我的QQ中心不就好了么那里可以查到 我的好友单向好友好友恢复、 以及好友申请 啊可以是你加别人的 或 别人加你的都可以查得到QQ空间里 这个没注意 要有的话也会在你进空间的时候会提示你的QQ 空间里 上面消息 就可以看见了!望采纳!谢谢这个直接去我的QQ中心不就好了么那里可以查到 我的好友单向好友好友恢复、 以及好友申请 啊可以是你加别人的 或 别人加你的都可以查得到",
]
input_texts = queries + documents

tokenizer = AutoTokenizer.from_pretrained('Lenovo-Zhihui/Zhihui_LLM_Embedding', trust_remote_code=True)
model = AutoModel.from_pretrained('Lenovo-Zhihui/Zhihui_LLM_Embedding', trust_remote_code=True)

max_length = 512

# Tokenize the input texts
batch_dict = tokenizer(input_texts, max_length=max_length, padding=True, truncation=True, return_tensors='pt')
outputs = model(**batch_dict)
embeddings = last_token_pool(outputs.last_hidden_state, batch_dict['attention_mask'])

# normalize embeddings
embeddings = F.normalize(embeddings, p=2, dim=1)
scores = (embeddings[:2] @ embeddings[2:].T)
print(scores.tolist())

```
##### Usage (Sentence-Transformers)
```python
from sentence_transformers import SentenceTransformer
model = SentenceTransformer("Lenovo-Zhihui/Zhihui_LLM_Embedding", trust_remote_code=True)
model.max_seq_length = 512
# 数据来源DuRetrieval https://huggingface.co./datasets/C-MTEB/DuRetrieval
queries = [
    "国家法定节假日共多少天",
    "如何查看好友申请",
]
documents = [
    "一年国家法定节假日为11天。根据公布的国家法定节假日调整方案,调整的主要内容包括:元旦放假1天不变;春节放假3天,放假时间为农历正月初一、初二、初三;“五一”国际劳动节1天不变;“十一”国庆节放假3天;清明节、端午节、中秋节增设为国家法定节假日,各放假1天(农历节日如遇闰月,以第一个月为休假日)。3、允许周末上移下错,与法定节假日形成连休。",
    "这个直接去我的QQ中心不就好了么那里可以查到 我的好友单向好友好友恢复、 以及好友申请 啊可以是你加别人的 或 别人加你的都可以查得到QQ空间里 这个没注意 要有的话也会在你进空间的时候会提示你的QQ 空间里 上面消息 就可以看见了!望采纳!谢谢这个直接去我的QQ中心不就好了么那里可以查到 我的好友单向好友好友恢复、 以及好友申请 啊可以是你加别人的 或 别人加你的都可以查得到",
]

query_embeddings = model.encode(queries, prompt_name="query", normalize_embeddings=True)
document_embeddings = model.encode(documents, normalize_embeddings=True)

scores = (query_embeddings @ document_embeddings.T)
print(scores.tolist())
```
### Reproduce our results(C-MTEB):
Check out scripts/eval_mteb.py to reproduce evaluation results on C-MTEB benchmark.

| Model | T2Retrieval | MMarcoRetrieval | DuRetrieval | CovidRetrieval | CmedqaRetrieval | EcomRetrieval | MedicalRetrieval | VideoRetrieval | Avg |  
|:-------------------------------|:--------:|:--------:|:--------:|:--------:|:--------:|:--------:|:--------:|:--------:|:--------:|  
|**Zhihui_LLM_Embedding** | 88.30 | 84.77 | 91.34 | 84.39 | 48.69 | 71.96 | 65.19 | 79.31 | **76.74** |
|zpoint_large_embedding_zh | 83.81 | 82.38 | 89.23 | 89.14 | 47.16 | 70.74 | 68.14 | 80.26 | 76.36 |
|gte-Qwen2-7B-instruct | 87.73 | 85.16 | 87.44 | 83.65 | 48.69 | 71.15 | 65.59 | 78.84 | 76.03 |
|360Zhinao-search | 87.12 | 83.32 | 87.57 | 85.02 | 46.73 | 68.9 | 63.69 | 78.09 | 75.06 |
|AGE_Hybrid | 86.88 | 80.65 | 89.28 | 83.66 | 47.26 | 69.28 | 65.94 | 76.79 | 74.97 |