Add `text-embeddings-inference` tag & snippet
Browse files## Description
- Add `text-embeddings-inference` tag to improve discoverability
- Adds a sample snippet on how to run Text Embeddings Inference (TEI) via Docker
⚠️ **This PR has been generated automatically, so please review it before merging.**
README.md
CHANGED
|
@@ -6,6 +6,7 @@ tags:
|
|
| 6 |
- feature-extraction
|
| 7 |
- sentence-similarity
|
| 8 |
- transformers
|
|
|
|
| 9 |
pipeline_tag: sentence-similarity
|
| 10 |
---
|
| 11 |
|
|
@@ -65,7 +66,7 @@ encoded_input = tokenizer(sentences, padding=True, truncation=True, return_tenso
|
|
| 65 |
with torch.no_grad():
|
| 66 |
model_output = model(**encoded_input)
|
| 67 |
|
| 68 |
-
# Perform pooling. In this case,
|
| 69 |
sentence_embeddings = mean_pooling(model_output, encoded_input['attention_mask'])
|
| 70 |
|
| 71 |
print("Sentence embeddings:")
|
|
@@ -97,4 +98,36 @@ If you find this model helpful, feel free to cite our publication [Sentence-BERT
|
|
| 97 |
publisher = "Association for Computational Linguistics",
|
| 98 |
url = "http://arxiv.org/abs/1908.10084",
|
| 99 |
}
|
| 100 |
-
```
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 6 |
- feature-extraction
|
| 7 |
- sentence-similarity
|
| 8 |
- transformers
|
| 9 |
+
- text-embeddings-inference
|
| 10 |
pipeline_tag: sentence-similarity
|
| 11 |
---
|
| 12 |
|
|
|
|
| 66 |
with torch.no_grad():
|
| 67 |
model_output = model(**encoded_input)
|
| 68 |
|
| 69 |
+
# Perform pooling. In this case, mean pooling.
|
| 70 |
sentence_embeddings = mean_pooling(model_output, encoded_input['attention_mask'])
|
| 71 |
|
| 72 |
print("Sentence embeddings:")
|
|
|
|
| 98 |
publisher = "Association for Computational Linguistics",
|
| 99 |
url = "http://arxiv.org/abs/1908.10084",
|
| 100 |
}
|
| 101 |
+
```
|
| 102 |
+
|
| 103 |
+
## Usage (Text Embeddings Inference (TEI))
|
| 104 |
+
|
| 105 |
+
[Text Embeddings Inference (TEI)](https://github.com/huggingface/text-embeddings-inference) is a blazing fast inference solution for text embeddings models.
|
| 106 |
+
|
| 107 |
+
- CPU:
|
| 108 |
+
```bash
|
| 109 |
+
docker run -p 8080:80 -v hf_cache:/data --pull always ghcr.io/huggingface/text-embeddings-inference:cpu-latest \
|
| 110 |
+
--model-id sentence-transformers/paraphrase-mpnet-base-v2 \
|
| 111 |
+
--pooling mean \
|
| 112 |
+
--dtype float16
|
| 113 |
+
```
|
| 114 |
+
|
| 115 |
+
- NVIDIA GPU:
|
| 116 |
+
```bash
|
| 117 |
+
docker run --gpus all -p 8080:80 -v hf_cache:/data --pull always ghcr.io/huggingface/text-embeddings-inference:cuda-latest \
|
| 118 |
+
--model-id sentence-transformers/paraphrase-mpnet-base-v2 \
|
| 119 |
+
--pooling mean \
|
| 120 |
+
--dtype float16
|
| 121 |
+
```
|
| 122 |
+
|
| 123 |
+
Send a request to `/v1/embeddings` to generate embeddings via the [OpenAI Embeddings API](https://platform.openai.com/docs/api-reference/embeddings/create):
|
| 124 |
+
```bash
|
| 125 |
+
curl -s http://localhost:8080/v1/embeddings \
|
| 126 |
+
-H "Content-Type: application/json" \
|
| 127 |
+
-d '{
|
| 128 |
+
"model": "sentence-transformers/paraphrase-mpnet-base-v2",
|
| 129 |
+
"input": "This is an example sentence"
|
| 130 |
+
}'
|
| 131 |
+
```
|
| 132 |
+
|
| 133 |
+
Or check the [Text Embeddings Inference API specification](https://huggingface.github.io/text-embeddings-inference/) instead.
|