Instructions to use nvidia/NV-Embed-v2 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use nvidia/NV-Embed-v2 with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("feature-extraction", model="nvidia/NV-Embed-v2", trust_remote_code=True)# Load model directly from transformers import AutoModel model = AutoModel.from_pretrained("nvidia/NV-Embed-v2", trust_remote_code=True, dtype="auto") - sentence-transformers
How to use nvidia/NV-Embed-v2 with sentence-transformers:
from sentence_transformers import SentenceTransformer model = SentenceTransformer("nvidia/NV-Embed-v2", trust_remote_code=True) 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] - Notebooks
- Google Colab
- Kaggle
max_seq_length seems not to be properly reported in sentence_bert_config.json
Hi authors, I was looking at the max_seq_length of this model and found out that it's not properly written in sentence_bert_config.json(https://huggingface.co/nvidia/NV-Embed-v2/blob/main/sentence_bert_config.json)
In the "Usage" section (https://huggingface.co/nvidia/NV-Embed-v2#usage-huggingface-transformers), the max_seq_length is 32768. Maybe the max_seq_length you wrote (4096) in sentence_bert_config.json might represent the hidden state (or the size of the output vector)
Can you please check?
It would be awesome if @tomaarsen could check too.
Thank you.
Hello!
You're right, it should be 32768 in sentence_bert_config.json. The reason it didn't affect the README snippet is because the 4096 immediately gets overridden due to model.max_seq_length = 32768. But we should probably update the config.
- Tom Aarsen
Hi, @yjoonjang . Thanks for the question. This issue is resolved by merging your request: https://huggingface.co/nvidia/NV-Embed-v2/discussions/38.