Instructions to use hkunlp/instructor-xl with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- sentence-transformers
How to use hkunlp/instructor-xl with sentence-transformers:
from sentence_transformers import SentenceTransformer model = SentenceTransformer("hkunlp/instructor-xl") 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-xl with Transformers:
# Load model directly from transformers import AutoTokenizer, AutoModel tokenizer = AutoTokenizer.from_pretrained("hkunlp/instructor-xl") model = AutoModel.from_pretrained("hkunlp/instructor-xl") - Notebooks
- Google Colab
- Kaggle
Any guidelines on composing instructions?
Do you have insights or best practices around crafting instructions for embeddings? As I understand, an instruction has the following general format:
Represent the domain text_type for task_objective:
What are the values we can specify for text_type and task_objective? Can we specify anything or is there a limited number of supported values?
Hi, Thanks a lot for your interest in the INSTRUCTOR model!
We provide a few examples in Table 5 of our paper (https://arxiv.org/pdf/2212.09741.pdf), but the values of the domain, text type, and task objective often depend on the specific task and are not restricted to the values mentioned in Table 5.
Feel free to add any further questions or comments!