Instructions to use sentence-transformers/all-MiniLM-L6-v1 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-v1 with sentence-transformers:
from sentence_transformers import SentenceTransformer model = SentenceTransformer("sentence-transformers/all-MiniLM-L6-v1") 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-v1 with Transformers:
# Load model directly from transformers import AutoTokenizer, AutoModel tokenizer = AutoTokenizer.from_pretrained("sentence-transformers/all-MiniLM-L6-v1") model = AutoModel.from_pretrained("sentence-transformers/all-MiniLM-L6-v1") - Inference
- Notebooks
- Google Colab
- Kaggle
Adapting this model so that it produces a statistical distribution rather than a vector-valued embedding?
I am wondering if anyone has considered how to adapt this model so that it represents the embedding of a sentence not as a vector but as a statistical distribution, perhaps a multivariate normal distribution with a diagonal covariance matrix. See https://arxiv.org/abs/1412.6623. Something more sophisticated would be even better. Either way, a distributional embedding would provide some quantification as to the possible meanings a passage of text might have.
Also, I appreciate that this is likely not the best place to post this more conceptual question. But I like this small model. If anyone has suggestions on a better forum, please advise.