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
text2vec using inference API
Hi,
is there a way we can convert the text to a vector using the inference API, rather than hosting sentence-transformers?
Thank you
I'm interested in this as well, it seems that the hosted inference API will only do sentence similarity scores, but it is not able to return vector embeddings, is this correct?
Hello!
Please refer to https://discuss.huggingface.co/t/using-accelerated-inference-api-to-produce-sentense-embeddings/6223/3. Omar there mentions an experimental API that you can call to use Feature Extraction rather than Sentence Similarity:
This is the exact API URL: https://api-inference.huggingface.co/pipeline/feature-extraction/sentence-transformers/all-MiniLM-L6-v2
Replace the URL from this snippet with the aforementioned one, and you'll have a free & working embedding API. Hope this helps!
- Tom Aarsen
This api is down
The API should be all back as of 12 hours ago!
why api is still down?
Is the api down for https://api-inference.huggingface.co/pipeline/feature-extraction/sentence-transformers/all-MiniLM-L6-v2?
I get 404 Error