Add Text Embeddings Inference (TEI) tag & snippet (#17)
Browse files- Add Text Embeddings Inference (TEI) tag & snippet (8afed724dfb37107ce6b9a63a8aff016919bdb24)
Co-authored-by: Alvaro Bartolome <alvarobartt@users.noreply.huggingface.co>
README.md
CHANGED
|
@@ -12,6 +12,7 @@ tags:
|
|
| 12 |
- mteb
|
| 13 |
- embedding
|
| 14 |
- transformers.js
|
|
|
|
| 15 |
---
|
| 16 |
|
| 17 |
# gte-modernbert-base
|
|
@@ -131,6 +132,47 @@ const similarities = (await matmul(embeddings.slice([0, 1]), embeddings.slice([1
|
|
| 131 |
console.log(similarities.tolist()); // [[42.89077377319336, 71.30916595458984, 33.66455841064453]]
|
| 132 |
```
|
| 133 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 134 |
## Training Details
|
| 135 |
|
| 136 |
The `gte-modernbert` series of models follows the training scheme of the previous [GTE models](https://huggingface.co/collections/Alibaba-NLP/gte-models-6680f0b13f885cb431e6d469), with the only difference being that the pre-training language model base has been replaced from [GTE-MLM](https://huggingface.co/Alibaba-NLP/gte-en-mlm-base) to [ModernBert](https://huggingface.co/answerdotai/ModernBERT-base). For more training details, please refer to our paper: [mGTE: Generalized Long-Context Text Representation and Reranking Models for Multilingual Text Retrieval](https://aclanthology.org/2024.emnlp-industry.103/)
|
|
|
|
| 12 |
- mteb
|
| 13 |
- embedding
|
| 14 |
- transformers.js
|
| 15 |
+
- text-embeddings-inference
|
| 16 |
---
|
| 17 |
|
| 18 |
# gte-modernbert-base
|
|
|
|
| 132 |
console.log(similarities.tolist()); // [[42.89077377319336, 71.30916595458984, 33.66455841064453]]
|
| 133 |
```
|
| 134 |
|
| 135 |
+
Additionally, you can also deploy `Alibaba-NLP/gte-modernbert-base` with [Text Embeddings Inference (TEI)](https://github.com/huggingface/text-embeddings-inference) as follows:
|
| 136 |
+
|
| 137 |
+
- CPU
|
| 138 |
+
|
| 139 |
+
```bash
|
| 140 |
+
docker run --platform linux/amd64 \
|
| 141 |
+
-p 8080:80 \
|
| 142 |
+
-v $PWD/data:/data \
|
| 143 |
+
--pull always \
|
| 144 |
+
ghcr.io/huggingface/text-embeddings-inference:cpu-1.7 \
|
| 145 |
+
--model-id Alibaba-NLP/gte-modernbert-base
|
| 146 |
+
```
|
| 147 |
+
|
| 148 |
+
- GPU
|
| 149 |
+
|
| 150 |
+
```bash
|
| 151 |
+
docker run --gpus all \
|
| 152 |
+
-p 8080:80 \
|
| 153 |
+
-v $PWD/data:/data \
|
| 154 |
+
--pull always \
|
| 155 |
+
ghcr.io/huggingface/text-embeddings-inference:1.7 \
|
| 156 |
+
--model-id Alibaba-NLP/gte-modernbert-base
|
| 157 |
+
```
|
| 158 |
+
|
| 159 |
+
Then you can send requests to the deployed API via the OpenAI-compatible `v1/embeddings` route (more information about the [OpenAI Embeddings API](https://platform.openai.com/docs/api-reference/embeddings)):
|
| 160 |
+
|
| 161 |
+
```bash
|
| 162 |
+
curl https://0.0.0.0:8080/v1/embeddings \
|
| 163 |
+
-H "Content-Type: application/json" \
|
| 164 |
+
-d '{
|
| 165 |
+
"input": [
|
| 166 |
+
"what is the capital of China?",
|
| 167 |
+
"how to implement quick sort in python?",
|
| 168 |
+
"Beijing",
|
| 169 |
+
"sorting algorithms"
|
| 170 |
+
],
|
| 171 |
+
"model": "Alibaba-NLP/gte-modernbert-base",
|
| 172 |
+
"encoding_format": "float"
|
| 173 |
+
}'
|
| 174 |
+
```
|
| 175 |
+
|
| 176 |
## Training Details
|
| 177 |
|
| 178 |
The `gte-modernbert` series of models follows the training scheme of the previous [GTE models](https://huggingface.co/collections/Alibaba-NLP/gte-models-6680f0b13f885cb431e6d469), with the only difference being that the pre-training language model base has been replaced from [GTE-MLM](https://huggingface.co/Alibaba-NLP/gte-en-mlm-base) to [ModernBert](https://huggingface.co/answerdotai/ModernBERT-base). For more training details, please refer to our paper: [mGTE: Generalized Long-Context Text Representation and Reranking Models for Multilingual Text Retrieval](https://aclanthology.org/2024.emnlp-industry.103/)
|