Instructions to use sentence-transformers/all-MiniLM-L6-v2 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- sentence-transformers
How to use sentence-transformers/all-MiniLM-L6-v2 with sentence-transformers:
from sentence_transformers import SentenceTransformer model = SentenceTransformer("sentence-transformers/all-MiniLM-L6-v2") sentences = [ "That is a happy person", "That is a happy dog", "That is a very happy person", "Today is a sunny day" ] embeddings = model.encode(sentences) similarities = model.similarity(embeddings, embeddings) print(similarities.shape) # [4, 4] - Transformers
How to use sentence-transformers/all-MiniLM-L6-v2 with Transformers:
# Load model directly from transformers import AutoTokenizer, AutoModel tokenizer = AutoTokenizer.from_pretrained("sentence-transformers/all-MiniLM-L6-v2") model = AutoModel.from_pretrained("sentence-transformers/all-MiniLM-L6-v2") - Inference
- Notebooks
- Google Colab
- Kaggle
Should I be concerned about "UserWarning: TypedStorage is deprecated. " when using the model with python 3.11?
When using the model as it is, doing an inference, with python 3.11 I am seeing the following warning (not seeing it with 3.8):
Is this sth I should be concerned about?
UserWarning: TypedStorage is deprecated. It will be removed in the future and UntypedStorage will be the only storage class. This should only matter to you if you are using storages directly. To access UntypedStorage directly, use tensor.untyped_storage() instead of tensor.storage()
return self.fget.get(instance, owner)()
Hello!
I believe this problem should go away if you use a newer version of transformers. There's some discussion on it here: https://github.com/UKPLab/sentence-transformers/issues/2450
- Tom Aarsen