BGE-Reranker-v2#

Model

Language

Parameters

Model Size

Description

BAAI/bge-reranker-v2-m3

Multilingual

568M

2.27 GB

Lightweight reranker model, possesses strong multilingual capabilities, easy to deploy, with fast inference.

BAAI/bge-reranker-v2-gemma

Multilingual

2.51B

10 GB

Suitable for multilingual contexts, performs well in both English proficiency and multilingual capabilities.

BAAI/bge-reranker-v2-minicpm-layerwise

Multilingual

2.72B

10.9 GB

Suitable for multilingual contexts, allows freedom to select layers for output, facilitating accelerated inference.

BAAI/bge-reranker-v2.5-gemma2-lightweight

Multilingual

2.72B

10.9 GB

Suitable for multilingual contexts, allows freedom to select layers, compress ratio and compress layers for output, facilitating accelerated inference.

Tip

You can select the model according your senario and resource:

  • For multilingual, utilize BAAI/bge-reranker-v2-m3, BAAI/bge-reranker-v2-gemma and BAAI/bge-reranker-v2.5-gemma2-lightweight.

  • For Chinese or English, utilize BAAI/bge-reranker-v2-m3 and BAAI/bge-reranker-v2-minicpm-layerwise.

  • For efficiency, utilize BAAI/bge-reranker-v2-m3 and the low layer of BAAI/bge-reranker-v2-minicpm-layerwise.

  • For better performance, recommand BAAI/bge-reranker-v2-minicpm-layerwise and BAAI/bge-reranker-v2-gemma.

Make sure always test on your real use case and choose the one with best speed-quality balance!

Usage#

bge-reranker-v2-m3

Use bge-reranker-v2-m3 in the same way as bge-reranker-base and bge-reranker-large.

from FlagEmbedding import FlagReranker

# Setting use_fp16 to True speeds up computation with a slight performance degradation
reranker = FlagReranker('BAAI/bge-reranker-v2-m3', use_fp16=True)

score = reranker.compute_score(['query', 'passage'])
# or set "normalize=True" to apply a sigmoid function to the score for 0-1 range
score = reranker.compute_score(['query', 'passage'], normalize=True)

print(score)

bge-reranker-v2-gemma

Use the FlagLLMReranker class for bge-reranker-v2-gemma.

from FlagEmbedding import FlagLLMReranker

# Setting use_fp16 to True speeds up computation with a slight performance degradation
reranker = FlagLLMReranker('BAAI/bge-reranker-v2-gemma', use_fp16=True)

score = reranker.compute_score(['query', 'passage'])
print(score)

bge-reranker-v2-minicpm-layerwise

Use the LayerWiseFlagLLMReranker class for bge-reranker-v2-minicpm-layerwise.

from FlagEmbedding import LayerWiseFlagLLMReranker

# Setting use_fp16 to True speeds up computation with a slight performance degradation
reranker = LayerWiseFlagLLMReranker('BAAI/bge-reranker-v2-minicpm-layerwise', use_fp16=True)

# Adjusting 'cutoff_layers' to pick which layers are used for computing the score.
score = reranker.compute_score(['query', 'passage'], cutoff_layers=[28])
print(score)

bge-reranker-v2.5-gemma2-lightweight

Use the LightWeightFlagLLMReranker class for bge-reranker-v2.5-gemma2-lightweight.

from FlagEmbedding import LightWeightFlagLLMReranker

# Setting use_fp16 to True speeds up computation with a slight performance degradation
reranker = LightWeightFlagLLMReranker('BAAI/bge-reranker-v2.5-gemma2-lightweight', use_fp16=True)

# Adjusting 'cutoff_layers' to pick which layers are used for computing the score.
score = reranker.compute_score(['query', 'passage'], cutoff_layers=[28], compress_ratio=2, compress_layer=[24, 40])
print(score)