Text Ranking
Transformers
Safetensors
multilingual
t5gemma2
text2text-generation
reranker
encoder-decoder
FBNL
Retrieval
RAG
cosyy commited on
Commit
673fcd0
·
verified ·
1 Parent(s): 59102d6

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +31 -0
README.md CHANGED
@@ -89,7 +89,38 @@ On LMEB, reranking models demonstrate a clear advantage, with even the 0.27B Nan
89
  ![lmeb_emb](./assets/lmeb_emb.jpg)
90
 
91
  # Usage
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
92
 
 
 
 
 
 
 
 
 
 
93
 
94
  # Citation
95
  If you find this model useful, please cite our papers.
 
89
  ![lmeb_emb](./assets/lmeb_emb.jpg)
90
 
91
  # Usage
92
+ ```python
93
+ import argparse
94
+
95
+ from kalm_reranker import KaLMReranker
96
+
97
+
98
+ def main() -> None:
99
+ parser = argparse.ArgumentParser()
100
+ parser.add_argument(
101
+ "--model",
102
+ default="KaLM-Embedding/KaLM-Reranker-V1-Large"
103
+ )
104
+ parser.add_argument("--device", default=None)
105
+ args = parser.parse_args()
106
+
107
+ reranker = KaLMReranker(args.model, device=args.device)
108
+ query = "What is the capital of China?"
109
+ documents = [
110
+ "The capital of China is Beijing.",
111
+ "Gravity attracts bodies toward one another.",
112
+ ]
113
+ instruction = "Given a query, retrieve documents that answer the query."
114
 
115
+ pairs = [(query, document) for document in documents]
116
+ print("scores:", reranker.predict(pairs, instruction=instruction))
117
+ print("rankings:", reranker.rank(query, documents, instruction=instruction))
118
+
119
+
120
+ if __name__ == "__main__":
121
+ main()
122
+
123
+ ```
124
 
125
  # Citation
126
  If you find this model useful, please cite our papers.