-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
24bdc39
commit b73e6db
Showing
26 changed files
with
221 additions
and
121 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
# Ranking Examples | ||
|
||
## prepare data | ||
```python | ||
from datasets import load_dataset | ||
|
||
dataset = load_dataset("C-MTEB/T2Reranking", split="dev") | ||
ds = dataset.train_test_split(test_size=0.1, seed=42) | ||
|
||
ds_train = ( | ||
ds["train"] | ||
.filter(lambda x: len(x["positive"]) > 0 and len(x["negative"]) > 0) | ||
) | ||
|
||
ds_train.to_json("t2_ranking.jsonl", force_ascii=False) | ||
``` | ||
|
||
## train | ||
- cross encoder | ||
```shell | ||
python train_cross_encoder.py | ||
``` | ||
|
||
- cross encoder | ||
```shell | ||
MODEL_NAME="BAAI/bge-reranker-base" | ||
TRAIN_DATA="/t2_ranking.jsonl" | ||
OUTPUT_DIR="/t2_output" | ||
|
||
torchrun --nproc_per_node 1 \ | ||
-m retrievals.pipelines.rerank \ | ||
--output_dir $OUTPUT_DIR \ | ||
--overwrite_output_dir \ | ||
--model_name_or_path $MODEL_NAME \ | ||
--do_train \ | ||
--train_data $TRAIN_DATA \ | ||
--positive_key positive \ | ||
--negative_key negative \ | ||
--learning_rate 3e-5 \ | ||
--fp16 \ | ||
--num_train_epochs 3 \ | ||
--per_device_train_batch_size 32 \ | ||
--dataloader_drop_last True \ | ||
--max_length 512 \ | ||
--max_negative_samples 2 \ | ||
--logging_steps 100 | ||
``` | ||
|
||
|
||
- colbert | ||
```shell | ||
python train_colbert.py | ||
``` |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.