Update README.md
Browse files
README.md
CHANGED
|
@@ -1,3 +1,46 @@
|
|
| 1 |
-
---
|
| 2 |
-
license: apache-2.0
|
| 3 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
license: apache-2.0
|
| 3 |
+
base_model:
|
| 4 |
+
- Snowflake/snowflake-arctic-embed-l
|
| 5 |
+
---
|
| 6 |
+
|
| 7 |
+
***This model is a neuron compiled version of https://huggingface.co/Snowflake/snowflake-arctic-embed-l ***
|
| 8 |
+
|
| 9 |
+
It was compiled on version 2.20 of the Neuron SDK. You may need to run the compilation process again.
|
| 10 |
+
|
| 11 |
+
See https://huggingface.co/docs/optimum-neuron/en/inference_tutorials/sentence_transformers for more details
|
| 12 |
+
|
| 13 |
+
For information on how to run on SageMaker: https://huggingface.co/docs/optimum-neuron/en/inference_tutorials/sentence_transformers
|
| 14 |
+
|
| 15 |
+
To run:
|
| 16 |
+
```
|
| 17 |
+
|
| 18 |
+
from optimum.neuron import NeuronModelForSentenceTransformers
|
| 19 |
+
from transformers import AutoTokenizer
|
| 20 |
+
model_id = "jburtoft/snowflake-arctic-embed-l"
|
| 21 |
+
|
| 22 |
+
# Use the line below if you have to compile the model yourself
|
| 23 |
+
#model_id = "snowflake-arctic-embed-l-inf2"
|
| 24 |
+
|
| 25 |
+
|
| 26 |
+
model = NeuronModelForSentenceTransformers.from_pretrained(model_id)
|
| 27 |
+
tokenizer = AutoTokenizer.from_pretrained(model_id)
|
| 28 |
+
|
| 29 |
+
# Run inference
|
| 30 |
+
prompt = "I like to eat apples"
|
| 31 |
+
encoded_input = tokenizer(prompt, return_tensors='pt')
|
| 32 |
+
outputs = model(**encoded_input)
|
| 33 |
+
|
| 34 |
+
token_embeddings = outputs.token_embeddings
|
| 35 |
+
sentence_embedding = outputs.sentence_embedding
|
| 36 |
+
|
| 37 |
+
print(f"token embeddings: {token_embeddings.shape}") # torch.Size([1, 7, 384])
|
| 38 |
+
print(f"sentence_embedding: {sentence_embedding.shape}") # torch.Size([1, 384])
|
| 39 |
+
|
| 40 |
+
```
|
| 41 |
+
|
| 42 |
+
To compile :
|
| 43 |
+
```
|
| 44 |
+
optimum-cli export neuron -m Snowflake/snowflake-arctic-embed-l --sequence_length 512 --batch_size 1 --task feature-extraction snowflake-arctic-embed-l-inf2
|
| 45 |
+
```
|
| 46 |
+
|