Instructions to use hkunlp/instructor-large with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- sentence-transformers
How to use hkunlp/instructor-large with sentence-transformers:
from sentence_transformers import SentenceTransformer model = SentenceTransformer("hkunlp/instructor-large") 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 hkunlp/instructor-large with Transformers:
# Load model directly from transformers import AutoTokenizer, AutoModel tokenizer = AutoTokenizer.from_pretrained("hkunlp/instructor-large") model = AutoModel.from_pretrained("hkunlp/instructor-large") - Notebooks
- Google Colab
- Kaggle
Problem when using embedding=HuggingFaceEmbeddings(model_name="hkunlp/instructor-xl")
Hi. When I am trying to use hkunlp/instructor-xl by calling HuggingFaceEmbeddings (imported from langchain_community.embeddings), there will be a type error as below. I also tried to download instructor-xl and call it locally, but I still get the same type error. Anyone may help?
File "/home/xiaomin/anaconda3/envs/llama/lib/python3.10/site-packages/sentence_transformers/models/Pooling.py", line 120, in load
return Pooling(**config)
TypeError: Pooling.init() got an unexpected keyword argument 'pooling_mode_weightedmean_tokens'
The pip library InstructorEmbedding is abandonded and is no longer kept up to date. To use with the latest version of sentence-transformers (3.3.1), install this modified version:
pip install git+https://github.com/NoahBPeterson/instructor-embedding.git@54076ec450d9825cf84f1ed6e54a5748f6877070