Instructions to use sentence-transformers/paraphrase-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/paraphrase-MiniLM-L6-v2 with sentence-transformers:
from sentence_transformers import SentenceTransformer model = SentenceTransformer("sentence-transformers/paraphrase-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/paraphrase-MiniLM-L6-v2 with Transformers:
# Load model directly from transformers import AutoTokenizer, AutoModel tokenizer = AutoTokenizer.from_pretrained("sentence-transformers/paraphrase-MiniLM-L6-v2") model = AutoModel.from_pretrained("sentence-transformers/paraphrase-MiniLM-L6-v2", device_map="auto") - Inference
- Notebooks
- Google Colab
- Kaggle
Using the model locally
So i am working on a system without internet, so i downloaded all the files of the model then saved them locally now i want to use the model
but when i am doing model = SentenceTransformer('local path to model')
then it is giving me HFValidationError: Repo id must use alphanumeric chars or '-', '_', '.', '--' and '..' are forbidden, '-' and '.' cannot start or end the name, max length is 96: 'D:\paraphraseMiniLM'.
It seems like the problem is with the path definition. So, I would suggest you change the location of the saved model, for instance, in the same folder where you have your script. Lately, when initializing the model, just put the path inside the folder: "your_folder/saved_model".
Hope this helps