Skip to content

Commit af3831d

Browse files
committed
update-reranker-v2
1 parent 4f573c5 commit af3831d

2 files changed

Lines changed: 5 additions & 6 deletions

File tree

FlagEmbedding/flag_reranker.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -349,8 +349,7 @@ def __init__(
349349
@torch.no_grad()
350350
def compute_score(self, sentence_pairs: Union[List[Tuple[str, str]], Tuple[str, str]], batch_size: int = 16,
351351
max_length: int = 512, cutoff_layers: List[int] = None, prompt: str = None,
352-
normalize: bool = False) -> Union[float, List[Any], List[Union[float, Any]], List[
353-
List[Any], List[Union[float, Any]]], Any]:
352+
normalize: bool = False) -> Union[float, List[float], List[List[float]]]:
354353
assert isinstance(sentence_pairs, list)
355354
if isinstance(sentence_pairs[0], str):
356355
sentence_pairs = [sentence_pairs]

FlagEmbedding/llm_reranker/README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ And the score can be mapped to a float value in [0,1] by sigmoid function.
1919
| [BAAI/bge-reranker-large](https://huggingface.co/BAAI/bge-reranker-large) | [xlm-roberta-large](https://huggingface.co/FacebookAI/xlm-roberta-large) | Chinese and English | - | Lightweight reranker model, easy to deploy, with fast inference. |
2020
| [BAAI/bge-reranker-v2-m3](https://huggingface.co/BAAI/bge-reranker-v2-m3) | [bge-m3](https://huggingface.co/BAAI/bge-m3) | Multilingual | - | Lightweight reranker model, possesses strong multilingual capabilities, easy to deploy, with fast inference. |
2121
| [BAAI/bge-reranker-v2-gemma](https://huggingface.co/BAAI/bge-reranker-v2-gemma) | [google/gemma-2b](https://huggingface.co/google/gemma-2b) | Multilingual | - | Suitable for multilingual contexts, performs well in both English proficiency and multilingual capabilities. |
22-
| [BAAI/bge-reranker-v2-minicpm-layerwise](https://huggingface.co/BAAI/bge-reranker-v2-minicpm-layerwise) | [openbmb/MiniCPM-2B-dpo-fp16](https://huggingface.co/openbmb/MiniCPM-2B-dpo-fp16/tree/main) | Multilingual | 8-40 | Suitable for multilingual contexts, performs well in both English and Chinese proficiency, allows freedom to select layers for output, facilitating accelerated inference. |
22+
| [BAAI/bge-reranker-v2-minicpm-layerwise](https://huggingface.co/BAAI/bge-reranker-v2-minicpm-layerwise) | [openbmb/MiniCPM-2B-dpo-bf16](https://huggingface.co/openbmb/MiniCPM-2B-dpo-bf16) | Multilingual | 8-40 | Suitable for multilingual contexts, performs well in both English and Chinese proficiency, allows freedom to select layers for output, facilitating accelerated inference. |
2323

2424

2525
You can select the model according your senario and resource.
@@ -255,7 +255,7 @@ You can fine-tune the reranker with the following code:
255255
torchrun --nproc_per_node {number of gpus} \
256256
-m FlagEmbedding.llm_reranker.finetune_for_instruction.run \
257257
--output_dir {path to save model} \
258-
--model_name_or_path BAAI/bge-reranker-v2-gemma \
258+
--model_name_or_path google/gemma-2b \
259259
--train_data ./toy_finetune_data.jsonl \
260260
--learning_rate 2e-4 \
261261
--num_train_epochs 1 \
@@ -286,7 +286,7 @@ torchrun --nproc_per_node {number of gpus} \
286286
torchrun --nproc_per_node {number of gpus} \
287287
-m FlagEmbedding.llm_reranker.finetune_for_layerwise.run \
288288
--output_dir {path to save model} \
289-
--model_name_or_path BAAI/bge-reranker-v2-minicpm-layerwise \
289+
--model_name_or_path openbmb/MiniCPM-2B-dpo-bf16 \
290290
--train_data ./toy_finetune_data.jsonl \
291291
--learning_rate 2e-4 \
292292
--num_train_epochs 1 \
@@ -314,7 +314,7 @@ torchrun --nproc_per_node {number of gpus} \
314314
--head_type simple
315315
```
316316

317-
Our rerankers are initialized from [google/gemma-2b](https://huggingface.co/google/gemma-2b) (for llm-based reranker) and [openbmb/MiniCPM-2B-dpo-fp16](https://huggingface.co/openbmb/MiniCPM-2B-dpo-fp16/tree/main) (for llm-based layerwise reranker), and we train it on a mixture of multilingual datasets:
317+
Our rerankers are initialized from [google/gemma-2b](https://huggingface.co/google/gemma-2b) (for llm-based reranker) and [openbmb/MiniCPM-2B-dpo-bf16](https://huggingface.co/openbmb/MiniCPM-2B-dpo-bf16) (for llm-based layerwise reranker), and we train it on a mixture of multilingual datasets:
318318

319319
- [bge-m3-data](https://huggingface.co/datasets/Shitao/bge-m3-data)
320320
- [quora train data](https://huggingface.co/datasets/quora)

0 commit comments

Comments
 (0)