Skip to content

Commit bea26e9

Browse files
committed
update reranker v2
1 parent 50cfb6b commit bea26e9

2 files changed

Lines changed: 7 additions & 5 deletions

File tree

FlagEmbedding/llm_reranker/README.md

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,8 @@ print(scores) # [0.00027803096387751553, 0.9948403768236574]
6565

6666
```python
6767
from FlagEmbedding import FlagLLMReranker
68-
reranker = FlagLLMReranker('BAAI/bge-reranker-v2-gemma', use_bf16=True) # Setting use_bf16 to True speeds up computation with a slight performance degradation
68+
reranker = FlagLLMReranker('BAAI/bge-reranker-v2-gemma', use_fp16=True) # Setting use_fp16 to True speeds up computation with a slight performance degradation
69+
# reranker = FlagLLMReranker('BAAI/bge-reranker-v2-gemma', use_fp16=True) # You can also set use_bf16=True to speed up computation with a slight performance degradation
6970

7071
score = reranker.compute_score(['query', 'passage'])
7172
print(score)
@@ -78,7 +79,8 @@ print(scores)
7879

7980
```python
8081
from FlagEmbedding import LayerWiseFlagLLMReranker
81-
reranker = LayerWiseFlagLLMReranker('BAAI/bge-reranker-v2-minicpm-layerwise', use_bf16=True) # Setting use_bf16 to True speeds up computation with a slight performance degradation
82+
reranker = LayerWiseFlagLLMReranker('BAAI/bge-reranker-v2-minicpm-layerwise', use_fp16=True) # Setting use_fp16 to True speeds up computation with a slight performance degradation
83+
# reranker = LayerWiseFlagLLMReranker('BAAI/bge-reranker-v2-minicpm-layerwise', use_bf16=True) # You can also set use_bf16=True to speed up computation with a slight performance degradation
8284

8385
score = reranker.compute_score(['query', 'passage'], cutoff_layers=[28]) # Adjusting 'cutoff_layers' to pick which layers are used for computing the score.
8486
print(score)
@@ -218,8 +220,8 @@ def get_inputs(pairs, tokenizer, prompt=None, max_length=1024):
218220
return_tensors='pt',
219221
)
220222

221-
tokenizer = AutoTokenizer.from_pretrained('BAAI/bge-reranker-v2-minicpm-layerwise', trust_remote_code=True, torch_dtype=torch.bfloat16)
222-
model = AutoModelForCausalLM.from_pretrained('BAAI/bge-reranker-v2-minicpm-layerwise', trust_remote_code=True, torch_dtype=torch.bfloat16)
223+
tokenizer = AutoTokenizer.from_pretrained('BAAI/bge-reranker-v2-minicpm-layerwise', trust_remote_code=True)
224+
model = AutoModelForCausalLM.from_pretrained('BAAI/bge-reranker-v2-minicpm-layerwise', trust_remote_code=True, torch_dtype=torch.float16)
223225
model = model.to('cuda')
224226
model.eval()
225227

@@ -331,7 +333,7 @@ Our rerankers are initialized from [google/gemma-2b](https://huggingface.co/goog
331333

332334
rereank the top 100 results from bge-en-v1.5 large.
333335

334-
![image-20240318152741276](./evaluation/BEIR-bge-en-v1.5.png)
336+
![image-20240319140555921](./evaluation/BEIR-bge-en-v1.5.png)
335337

336338
rereank the top 100 results from e5 mistral 7b instruct.
337339

81 Bytes
Loading

0 commit comments

Comments
 (0)