Dongfu Jiang commited on
Commit
c7eb635
1 Parent(s): fad1144

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +38 -1
README.md CHANGED
@@ -2,4 +2,41 @@
2
  license: mit
3
  ---
4
 
5
- PairRanker, trained on deberta-v3-large
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2
  license: mit
3
  ---
4
 
5
+ PairRanker used in llm-blender, trained on deberta-v3-large.
6
+
7
+ - Github: [https://github.com/yuchenlin/LLM-Blender](https://github.com/yuchenlin/LLM-Blender)
8
+ - Paper: [https://arxiv.org/abs/2306.02561](https://arxiv.org/abs/2306.02561)
9
+
10
+ ## Usage Example
11
+ Since PairRanker contains some custom layers and tokens. We recommend use our pairranker with our llm-blender python repo.
12
+ Otherwise, loading it directly with hugging face `from_pretrained()` API will encounter errors.
13
+
14
+ First install `llm-blender` by `pip install git+https://github.com/yuchenlin/LLM-Blender.git`
15
+ Then use pairranker with the following code:
16
+ ```python
17
+ import llm_blender
18
+ # ranker config
19
+ ranker_config = llm_blender.RankerConfig()
20
+ ranker_config.ranker_type = "pairranker" # only supports pairranker now.
21
+ ranker_config.model_type = "deberta"
22
+ ranker_config.model_name = "microsoft/deberta-v3-large" # ranker backbone
23
+ ranker_config.load_checkpoint = "llm-blender/pair-ranker" # hugging face hub model path or your local ranker checkpoint <your checkpoint path>
24
+ ranker_config.cache_dir = "./hf_models" # hugging face model cache dir
25
+ ranker_config.source_maxlength = 128
26
+ ranker_config.candidate_maxlength = 128
27
+ ranker_config.n_tasks = 1 # number of singal that has been used to train the ranker. This checkpoint is trained using BARTScore only, thus being 1.
28
+ fuser_config = llm_blender.GenFuserConfig()
29
+ # ignore fuser config as we don't use it here. You can load it if you want
30
+ blender_config = llm_blender.BlenderConfig()
31
+ # blender config
32
+ blender_config.device = "cuda" # blender ranker and fuser device
33
+ blender = llm_blender.Blender(blender_config, ranker_config, fuser_config)
34
+ ```
35
+ Then you are good to use pairrankers with
36
+ - `blender.rank()` to rank candidates
37
+ - `blender.compare()` to compare 2 candiates.
38
+ See LLM-Blender Github [README.md](https://github.com/yuchenlin/LLM-Blender#rank-and-fusion)
39
+ and jupyter file [blender_usage.ipynb](https://github.com/yuchenlin/LLM-Blender/blob/main/blender_usage.ipynb)
40
+ for detailed usage examples.
41
+
42
+