thenlper alvarobartt HF Staff commited on
Commit
8215cf0
·
verified ·
1 Parent(s): 028e39d

Add Text Embeddings Inference (TEI) snippet (#21)

Browse files

- Add Text Embeddings Inference (TEI) snippet (0acb790751daef0c1a7c5191122056bd16ef9f09)


Co-authored-by: Alvaro Bartolome <[email protected]>

Files changed (1) hide show
  1. README.md +39 -0
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