Luke Merrick commited on
Commit
35df7db
1 Parent(s): 3063768

Fix usage example

Browse files
Files changed (1) hide show
  1. README.md +4 -2
README.md CHANGED
@@ -7655,7 +7655,9 @@ NOTE: A good uniform scalar quantization range to use with this model (and which
7655
  You can use the sentence-transformers package to use any of the snowflake-arctic-embed models. Here's an example for `snowflake-arctic-embed-m-v1.5`.
7656
 
7657
  ```python
 
7658
  from sentence_transformers import SentenceTransformer
 
7659
 
7660
  # Model constant.
7661
  MODEL_ID = "Snowflake/snowflake-arctic-embed-m-v1.5"
@@ -7696,8 +7698,8 @@ for query, query_scores in zip(queries, scores):
7696
  #
7697
 
7698
  #### Variation: Truncated Embeddings ####
7699
- query_embeddings_256 = normalize(query_embeddings[:, :256])
7700
- doument_embeddings_256 = normalize(doument_embeddings[:, :256])
7701
  scores_256 = query_embeddings_256 @ doument_embeddings_256.T
7702
 
7703
  # Pretty-print the results.
 
7655
  You can use the sentence-transformers package to use any of the snowflake-arctic-embed models. Here's an example for `snowflake-arctic-embed-m-v1.5`.
7656
 
7657
  ```python
7658
+ import torch
7659
  from sentence_transformers import SentenceTransformer
7660
+ from torch.nn.functional import normalize
7661
 
7662
  # Model constant.
7663
  MODEL_ID = "Snowflake/snowflake-arctic-embed-m-v1.5"
 
7698
  #
7699
 
7700
  #### Variation: Truncated Embeddings ####
7701
+ query_embeddings_256 = normalize(torch.from_numpy(query_embeddings)[:, :256])
7702
+ doument_embeddings_256 = normalize(torch.from_numpy(document_embeddings)[:, :256])
7703
  scores_256 = query_embeddings_256 @ doument_embeddings_256.T
7704
 
7705
  # Pretty-print the results.