Instructions to use intfloat/e5-mistral-7b-instruct with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- sentence-transformers
How to use intfloat/e5-mistral-7b-instruct with sentence-transformers:
from sentence_transformers import SentenceTransformer model = SentenceTransformer("intfloat/e5-mistral-7b-instruct") sentences = [ "The weather is lovely today.", "It's so sunny outside!", "He drove to the stadium." ] embeddings = model.encode(sentences) similarities = model.similarity(embeddings, embeddings) print(similarities.shape) # [3, 3] - Transformers
How to use intfloat/e5-mistral-7b-instruct with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("feature-extraction", model="intfloat/e5-mistral-7b-instruct")# Load model directly from transformers import AutoTokenizer, AutoModel tokenizer = AutoTokenizer.from_pretrained("intfloat/e5-mistral-7b-instruct") model = AutoModel.from_pretrained("intfloat/e5-mistral-7b-instruct", device_map="auto") - Notebooks
- Google Colab
- Kaggle
Safetensor keys differ with mistralai/Mistral-7B-v0.1
Hello, perhaps I'm missing something obvious. But the keys in: https://huggingface.co/intfloat/e5-mistral-7b-instruct/blob/main/model.safetensors.index.json
Differ from most other mistral models, like https://huggingface.co/mistralai/Mistral-7B-v0.1/blob/main/model.safetensors.index.json
This is not an issue in python transformers, but causes an issue in Candle. Which assumes all keys are prefixed with model: https://github.com/huggingface/candle/blob/main/candle-transformers/src/models/mistral.rs#L384
This is an issue that should be solved in Candle, but I'm simply curious as to why this differs in the first place?
This is expected.
The difference is caused by the lack of LM head for embedding models. For text generation models, one loads with AutoModelForCausalLM.from_pretrained(...), while for this embedding model, one should load with AutoModel.from_pretrained(...).
That makes sense. I've created a PR that addresses this for loading Mistral in Candle: https://github.com/huggingface/candle/pull/1636