Text Ranking
sentence-transformers
Safetensors
Transformers
new
text-classification
text-embeddings-inference
custom_code
Instructions to use Alibaba-NLP/gte-multilingual-reranker-base with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- sentence-transformers
How to use Alibaba-NLP/gte-multilingual-reranker-base with sentence-transformers:
from sentence_transformers import CrossEncoder model = CrossEncoder("Alibaba-NLP/gte-multilingual-reranker-base", trust_remote_code=True) query = "Which planet is known as the Red Planet?" passages = [ "Venus is often called Earth's twin because of its similar size and proximity.", "Mars, known for its reddish appearance, is often referred to as the Red Planet.", "Jupiter, the largest planet in our solar system, has a prominent red spot.", "Saturn, famous for its rings, is sometimes mistaken for the Red Planet." ] scores = model.predict([(query, passage) for passage in passages]) print(scores) - Transformers
How to use Alibaba-NLP/gte-multilingual-reranker-base with Transformers:
# Load model directly from transformers import AutoModelForSequenceClassification model = AutoModelForSequenceClassification.from_pretrained("Alibaba-NLP/gte-multilingual-reranker-base", trust_remote_code=True, dtype="auto") - Notebooks
- Google Colab
- Kaggle
Add Text Embeddings Inference (TEI) snippet
#21
by alvarobartt HF Staff - opened
README.md
CHANGED
|
@@ -136,6 +136,45 @@ michaelf34/infinity:0.0.68 \
|
|
| 136 |
v2 --model-id Alibaba-NLP/gte-multilingual-reranker-base --revision "main" --dtype bfloat16 --batch-size 32 --device cuda --engine torch --port 7997
|
| 137 |
```
|
| 138 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 139 |
## Evaluation
|
| 140 |
|
| 141 |
Results of reranking based on multiple text retreival datasets
|
|
|
|
| 136 |
v2 --model-id Alibaba-NLP/gte-multilingual-reranker-base --revision "main" --dtype bfloat16 --batch-size 32 --device cuda --engine torch --port 7997
|
| 137 |
```
|
| 138 |
|
| 139 |
+
Usage with [Text Embeddings Inference (TEI)](https://github.com/huggingface/text-embeddings-inference):
|
| 140 |
+
|
| 141 |
+
- CPU:
|
| 142 |
+
|
| 143 |
+
```bash
|
| 144 |
+
docker run --platform linux/amd64 \
|
| 145 |
+
-p 8080:80 \
|
| 146 |
+
-v $PWD/data:/data \
|
| 147 |
+
--pull always \
|
| 148 |
+
ghcr.io/huggingface/text-embeddings-inference:cpu-1.7 \
|
| 149 |
+
--model-id Alibaba-NLP/gte-multilingual-reranker-base
|
| 150 |
+
```
|
| 151 |
+
|
| 152 |
+
- GPU:
|
| 153 |
+
|
| 154 |
+
```
|
| 155 |
+
docker run --gpus all \
|
| 156 |
+
-p 8080:80 \
|
| 157 |
+
-v $PWD/data:/data \
|
| 158 |
+
--pull always \
|
| 159 |
+
ghcr.io/huggingface/text-embeddings-inference:1.7 \
|
| 160 |
+
--model-id Alibaba-NLP/gte-multilingual-reranker-base
|
| 161 |
+
```
|
| 162 |
+
|
| 163 |
+
Then you can send requests to the deployed API via the `/rerank` route (see the [Text Embeddings Inference OpenAPI Specification](https://huggingface.github.io/text-embeddings-inference/) for more details):
|
| 164 |
+
|
| 165 |
+
```bash
|
| 166 |
+
curl https://0.0.0.0:8080/rerank \
|
| 167 |
+
-H "Content-Type: application/json" \
|
| 168 |
+
-d '{
|
| 169 |
+
"query": "中国的首都在哪儿",
|
| 170 |
+
"raw_scores": false,
|
| 171 |
+
"return_text": false,
|
| 172 |
+
"texts": [ "北京" ],
|
| 173 |
+
"truncate": true,
|
| 174 |
+
"truncation_direction": "right"
|
| 175 |
+
}'
|
| 176 |
+
```
|
| 177 |
+
|
| 178 |
## Evaluation
|
| 179 |
|
| 180 |
Results of reranking based on multiple text retreival datasets
|