File size: 9,541 Bytes
4356376
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
8b2d153
 
4356376
 
 
 
 
 
088716c
4356376
 
 
 
 
 
 
 
 
 
 
 
 
 
088716c
 
4356376
088716c
4356376
 
 
 
 
 
 
 
 
 
 
 
 
 
 
088716c
4356376
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
5f633fe
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
d3c4487
5f633fe
 
 
4356376
 
 
 
5f633fe
 
 
 
 
bc7058c
 
 
 
5f633fe
4356376
 
 
 
 
 
5f633fe
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
d3c4487
5f633fe
 
 
4356376
 
 
5f633fe
 
 
 
 
bc7058c
 
 
 
5f633fe
4356376
 
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
---
license: apache-2.0
language:
- ko
- en
metrics:
- accuracy
base_model:
- BAAI/bge-reranker-v2-m3
pipeline_tag: text-classification
library_name: sentence-transformers
---

# Reranker (Cross-Encoder)

Different from embedding model, reranker uses question and document as input and directly output similarity instead of embedding. You can get a relevance score by inputting query and passage to the reranker. And the score can be mapped to a float value in [0,1] by sigmoid function.

## Model Details
- Base model :  BAAI/bge-reranker-v2-m3
- The multilingual model has been optimized for Korean.

## Usage with Transformers

```python
from transformers import AutoTokenizer, AutoModelForSequenceClassification
import torch

model = AutoModelForSequenceClassification.from_pretrained('dragonkue/bge-reranker-v2-m3-ko')
tokenizer = AutoTokenizer.from_pretrained('dragonkue/bge-reranker-v2-m3-ko')

features = tokenizer([['λͺ‡ 년도에 μ§€λ°©μ„Έμ™Έμˆ˜μž…λ²•μ΄ μ‹œν–‰λμ„κΉŒ?', 'μ‹€λ¬΄κ΅μœ‘μ„ 톡해 β€˜μ§€λ°©μ„Έμ™Έμˆ˜μž…λ²•β€™μ— λŒ€ν•œ μžμΉ˜λ‹¨μ²΄μ˜ 관심을 μ œκ³ ν•˜κ³  μžμΉ˜λ‹¨μ²΄μ˜ 차질 μ—†λŠ” 업무 좔진을 μ§€μ›ν•˜μ˜€λ‹€. μ΄λŸ¬ν•œ 쀀비과정을 거쳐 2014λ…„ 8μ›” 7일뢀터 β€˜μ§€λ°©μ„Έμ™Έμˆ˜μž…λ²•β€™μ΄ μ‹œν–‰λ˜μ—ˆλ‹€.'], 
['λͺ‡ 년도에 μ§€λ°©μ„Έμ™Έμˆ˜μž…λ²•μ΄ μ‹œν–‰λμ„κΉŒ?', 'μ‹ν’ˆμ˜μ•½ν’ˆμ•ˆμ „μ²˜λŠ” 21일 κ΅­λ‚΄ μ œμ•½κΈ°μ—… μœ λ°”μ΄μ˜€λ‘œμ§μŠ€κ°€ 개발 쀑인 μ‹ μ’… μ½”λ‘œλ‚˜λ°”μ΄λŸ¬μŠ€ 감염증(μ½”λ‘œλ‚˜19) λ°±μ‹  ν›„λ³΄λ¬Όμ§ˆ β€˜μœ μ½”λ°±-19β€™μ˜ μž„μƒμ‹œν—˜ κ³„νšμ„ μ§€λ‚œ 20일 μŠΉμΈν–ˆλ‹€κ³  λ°ν˜”λ‹€.']],  padding=True, truncation=True, return_tensors="pt")

model.eval()
with torch.no_grad():
    logits = model(**features).logits
    scores = torch.sigmoid(logits)
    print(scores)
# [9.9997962e-01 5.0702977e-07]
```


## Usage with SentenceTransformers
First install the Sentence Transformers library:
```
pip install -U sentence-transformers
```

```python
from sentence_transformers import CrossEncoder

model = CrossEncoder('dragonkue/bge-reranker-v2-m3-ko', default_activation_function=torch.nn.Sigmoid())

scores = model.predict([['λͺ‡ 년도에 μ§€λ°©μ„Έμ™Έμˆ˜μž…λ²•μ΄ μ‹œν–‰λμ„κΉŒ?', 'μ‹€λ¬΄κ΅μœ‘μ„ 톡해 β€˜μ§€λ°©μ„Έμ™Έμˆ˜μž…λ²•β€™μ— λŒ€ν•œ μžμΉ˜λ‹¨μ²΄μ˜ 관심을 μ œκ³ ν•˜κ³  μžμΉ˜λ‹¨μ²΄μ˜ 차질 μ—†λŠ” 업무 좔진을 μ§€μ›ν•˜μ˜€λ‹€. μ΄λŸ¬ν•œ 쀀비과정을 거쳐 2014λ…„ 8μ›” 7일뢀터 β€˜μ§€λ°©μ„Έμ™Έμˆ˜μž…λ²•β€™μ΄ μ‹œν–‰λ˜μ—ˆλ‹€.'], 
['λͺ‡ 년도에 μ§€λ°©μ„Έμ™Έμˆ˜μž…λ²•μ΄ μ‹œν–‰λμ„κΉŒ?', 'μ‹ν’ˆμ˜μ•½ν’ˆμ•ˆμ „μ²˜λŠ” 21일 κ΅­λ‚΄ μ œμ•½κΈ°μ—… μœ λ°”μ΄μ˜€λ‘œμ§μŠ€κ°€ 개발 쀑인 μ‹ μ’… μ½”λ‘œλ‚˜λ°”μ΄λŸ¬μŠ€ 감염증(μ½”λ‘œλ‚˜19) λ°±μ‹  ν›„λ³΄λ¬Όμ§ˆ β€˜μœ μ½”λ°±-19β€™μ˜ μž„μƒμ‹œν—˜ κ³„νšμ„ μ§€λ‚œ 20일 μŠΉμΈν–ˆλ‹€κ³  λ°ν˜”λ‹€.']])
print(scores)
# [9.9997962e-01 5.0702977e-07]
```

## Usage with FlagEmbedding
First install the FlagEmbedding library:
```
pip install -U FlagEmbedding
```
```python
from FlagEmbedding import FlagReranker

reranker = FlagReranker('dragonkue/bge-reranker-v2-m3-ko')

scores = reranker.compute_score([['λͺ‡ 년도에 μ§€λ°©μ„Έμ™Έμˆ˜μž…λ²•μ΄ μ‹œν–‰λμ„κΉŒ?', 'μ‹€λ¬΄κ΅μœ‘μ„ 톡해 β€˜μ§€λ°©μ„Έμ™Έμˆ˜μž…λ²•β€™μ— λŒ€ν•œ μžμΉ˜λ‹¨μ²΄μ˜ 관심을 μ œκ³ ν•˜κ³  μžμΉ˜λ‹¨μ²΄μ˜ 차질 μ—†λŠ” 업무 좔진을 μ§€μ›ν•˜μ˜€λ‹€. μ΄λŸ¬ν•œ 쀀비과정을 거쳐 2014λ…„ 8μ›” 7일뢀터 β€˜μ§€λ°©μ„Έμ™Έμˆ˜μž…λ²•β€™μ΄ μ‹œν–‰λ˜μ—ˆλ‹€.'], 
['λͺ‡ 년도에 μ§€λ°©μ„Έμ™Έμˆ˜μž…λ²•μ΄ μ‹œν–‰λμ„κΉŒ?', 'μ‹ν’ˆμ˜μ•½ν’ˆμ•ˆμ „μ²˜λŠ” 21일 κ΅­λ‚΄ μ œμ•½κΈ°μ—… μœ λ°”μ΄μ˜€λ‘œμ§μŠ€κ°€ 개발 쀑인 μ‹ μ’… μ½”λ‘œλ‚˜λ°”μ΄λŸ¬μŠ€ 감염증(μ½”λ‘œλ‚˜19) λ°±μ‹  ν›„λ³΄λ¬Όμ§ˆ β€˜μœ μ½”λ°±-19β€™μ˜ μž„μƒμ‹œν—˜ κ³„νšμ„ μ§€λ‚œ 20일 μŠΉμΈν–ˆλ‹€κ³  λ°ν˜”λ‹€.']], normalize=True)
print(scores)
# [9.9997962e-01 5.0702977e-07]
```

## Fine-tune
Refer to https://github.com/FlagOpen/FlagEmbedding 


## Evaluation


### Bi-encoder and Cross-encoder 

Bi-Encoders convert texts into fixed-size vectors and efficiently calculate similarities between them. They are fast and ideal for tasks like semantic search and classification, making them suitable for processing large datasets quickly.

Cross-Encoders directly compare pairs of texts to compute similarity scores, providing more accurate results. While they are slower due to needing to process each pair, they excel in re-ranking top results and are important in Advanced RAG techniques for enhancing text generation.


### Korean Embedding Benchmark with AutoRAG
(https://github.com/Marker-Inc-Korea/AutoRAG-example-korean-embedding-benchmark)

This is a Korean embedding benchmark for the financial sector. 


**Top-k 1**

Bi-Encoder (Sentence Transformer)

| Model name                            | F1         | Recall     | Precision  |
|---------------------------------------|------------|------------|------------|
| paraphrase-multilingual-mpnet-base-v2 | 0.3596     | 0.3596     | 0.3596     |
| KoSimCSE-roberta                      | 0.4298     | 0.4298     | 0.4298     |
| Cohere embed-multilingual-v3.0        | 0.3596     | 0.3596     | 0.3596     |
| openai ada 002                        | 0.4737     | 0.4737     | 0.4737     |
| multilingual-e5-large-instruct        | 0.4649     | 0.4649     | 0.4649     |
| Upstage Embedding                     | 0.6579     | 0.6579     | 0.6579     |
| paraphrase-multilingual-MiniLM-L12-v2 | 0.2982     | 0.2982     | 0.2982     |
| openai_embed_3_small                  | 0.5439     | 0.5439     | 0.5439     |
| ko-sroberta-multitask                 | 0.4211     | 0.4211     | 0.4211     |
| openai_embed_3_large                  | 0.6053     | 0.6053     | 0.6053     |
| KU-HIAI-ONTHEIT-large-v1              | 0.7105     | 0.7105     | 0.7105     |
| KU-HIAI-ONTHEIT-large-v1.1            | 0.7193     | 0.7193     | 0.7193     |
| kf-deberta-multitask                  | 0.4561     | 0.4561     | 0.4561     |
| gte-multilingual-base                 | 0.5877     | 0.5877     | 0.5877     |
| KoE5                                  | 0.7018     | 0.7018     | 0.7018     |
| BGE-m3                                | 0.6578     | 0.6578     | 0.6578     |
| bge-m3-korean                         | 0.5351     | 0.5351     | 0.5351     |
| **BGE-m3-ko**                         | **0.7456** | **0.7456** | **0.7456** |


Cross-Encoder (Reranker)

| Model name                            | F1         | Recall     | Precision  |
|---------------------------------------|------------|------------|------------|
| gte-multilingual-reranker-base | 0.7281 | 0.7281     | 0.7281     |
| jina-reranker-v2-base-multilingual | 0.8070  | 0.8070     | 0.8070     |
| bge-reranker-v2-m3               | 0.8772     | 0.8772     | 0.8772     |
| upskyy/ko-reranker-8k                | 0.8684| 0.8684    | 0.8684       |
| upskyy/ko-reranker                    | 0.8333| 0.8333    | 0.8333       |
| mncai/bge-ko-reranker-560M           | 0.0088| 0.0088    | 0.0088       |
| Dongjin-kr/ko-reranker                | 0.8509| 0.8509    | 0.8509       |
| **bge-reranker-v2-m3-ko**             | **0.9123** | **0.9123** | **0.9123** |


**Top-k 3**

Bi-Encoder (Sentence Transformer)

| Model name                            | F1         | Recall     | Precision  |
|---------------------------------------|------------|------------|------------|
| paraphrase-multilingual-mpnet-base-v2 | 0.2368     | 0.4737     | 0.1579     |
| KoSimCSE-roberta                      | 0.3026     | 0.6053     | 0.2018     |
| Cohere embed-multilingual-v3.0        | 0.2851     | 0.5702     | 0.1901     |
| openai ada 002                        | 0.3553     | 0.7105     | 0.2368     |
| multilingual-e5-large-instruct        | 0.3333     | 0.6667     | 0.2222     |
| Upstage Embedding                     | 0.4211     | 0.8421     | 0.2807     |
| paraphrase-multilingual-MiniLM-L12-v2 | 0.2061     | 0.4123     | 0.1374     |
| openai_embed_3_small                  | 0.3640     | 0.7281     | 0.2427     |
| ko-sroberta-multitask                 | 0.2939     | 0.5877     | 0.1959     |
| openai_embed_3_large                  | 0.3947     | 0.7895     | 0.2632     |
| KU-HIAI-ONTHEIT-large-v1              | 0.4386     | 0.8772     | 0.2924     |
| KU-HIAI-ONTHEIT-large-v1.1            | 0.4430     | 0.8860     | 0.2953     |
| kf-deberta-multitask                  | 0.3158     | 0.6316     | 0.2105     |
| gte-multilingual-base                 | 0.4035     | 0.8070     | 0.2690     |
| KoE5                                  | 0.4254     | 0.8509     | 0.2836     |
| BGE-m3                                | 0.4254     | 0.8508     | 0.2836     |
| bge-m3-korean                         | 0.3684     | 0.7368     | 0.2456     |
| **BGE-m3-ko**                         | **0.4517** | **0.9035** | **0.3011** |

Cross-Encoder (Reranker)

| Model name                            | F1         | Recall     | Precision  |
|---------------------------------------|------------|------------|------------|
| gte-multilingual-reranker-base | 0.4605 | 0.9211     | 0.3070     |
| jina-reranker-v2-base-multilingual | 0.4649  | 0.9298     | 0.3099     |
| bge-reranker-v2-m3               | 0.4781     | 0.9561     | 0.3187     |
| upskyy/ko-reranker-8k                | 0.4781| 0.9561    | 0.3187       |
| upskyy/ko-reranker                    | 0.4649| 0.9298    | 0.3099       |
| mncai/bge-ko-reranker-560M           | 0.0044| 0.0088    | 0.0029       |
| Dongjin-kr/ko-reranker                | 0.4737| 0.9474    | 0.3158       |
| **bge-reranker-v2-m3-ko**             | **0.4825** | **0.9649** | **0.3216** |