bwang0911 commited on
Commit
088840c
1 Parent(s): 5078d99

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +3 -2
README.md CHANGED
@@ -3175,7 +3175,7 @@ def mean_pooling(model_output, attention_mask):
3175
  sentences = ['How is the weather today?', 'What is the current weather like today?']
3176
 
3177
  tokenizer = AutoTokenizer.from_pretrained('jinaai/jina-embeddings-v2-base-de')
3178
- model = AutoModel.from_pretrained('jinaai/jina-embeddings-v2-base-de', trust_remote_code=True)
3179
 
3180
  encoded_input = tokenizer(sentences, padding=True, truncation=True, return_tensors='pt')
3181
 
@@ -3193,11 +3193,12 @@ You can use Jina Embedding models directly from transformers package.
3193
 
3194
  ```python
3195
  !pip install transformers
 
3196
  from transformers import AutoModel
3197
  from numpy.linalg import norm
3198
 
3199
  cos_sim = lambda a,b: (a @ b.T) / (norm(a)*norm(b))
3200
- model = AutoModel.from_pretrained('jinaai/jina-embeddings-v2-base-de', trust_remote_code=True) # trust_remote_code is needed to use the encode method
3201
  embeddings = model.encode(['How is the weather today?', 'Wie ist das Wetter heute?'])
3202
  print(cos_sim(embeddings[0], embeddings[1]))
3203
  ```
 
3175
  sentences = ['How is the weather today?', 'What is the current weather like today?']
3176
 
3177
  tokenizer = AutoTokenizer.from_pretrained('jinaai/jina-embeddings-v2-base-de')
3178
+ model = AutoModel.from_pretrained('jinaai/jina-embeddings-v2-base-de', trust_remote_code=True, torch_dtype=torch.bfloat16)
3179
 
3180
  encoded_input = tokenizer(sentences, padding=True, truncation=True, return_tensors='pt')
3181
 
 
3193
 
3194
  ```python
3195
  !pip install transformers
3196
+ import torch
3197
  from transformers import AutoModel
3198
  from numpy.linalg import norm
3199
 
3200
  cos_sim = lambda a,b: (a @ b.T) / (norm(a)*norm(b))
3201
+ model = AutoModel.from_pretrained('jinaai/jina-embeddings-v2-base-de', trust_remote_code=True, torch_dtype=torch.bfloat16)
3202
  embeddings = model.encode(['How is the weather today?', 'Wie ist das Wetter heute?'])
3203
  print(cos_sim(embeddings[0], embeddings[1]))
3204
  ```