Text Ranking
Transformers
Safetensors
multilingual
t5gemma2
text2text-generation
reranker
encoder-decoder
FBNL
Retrieval
RAG
Instructions to use KaLM-Embedding/KaLM-Reranker-V1-Large with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use KaLM-Embedding/KaLM-Reranker-V1-Large with Transformers:
# Load model directly from transformers import AutoProcessor, AutoModelForMultimodalLM processor = AutoProcessor.from_pretrained("KaLM-Embedding/KaLM-Reranker-V1-Large") model = AutoModelForMultimodalLM.from_pretrained("KaLM-Embedding/KaLM-Reranker-V1-Large") - Notebooks
- Google Colab
- Kaggle
Update README.md
Browse files
README.md
CHANGED
|
@@ -89,7 +89,38 @@ On LMEB, reranking models demonstrate a clear advantage, with even the 0.27B Nan
|
|
| 89 |

|
| 90 |
|
| 91 |
# Usage
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 92 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 93 |
|
| 94 |
# Citation
|
| 95 |
If you find this model useful, please cite our papers.
|
|
|
|
| 89 |

|
| 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.
|