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("image-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
Is this model aligned/censored?
Dear authors, we are using NV-Embed-v2 in a research project about online hate speech detection. In particular, we compute embeddings for social media comments with NV-Embed-v2 and run logistic regression to classify them into hate or non-hate speech. The resultant classifier achieved a test accuracy of 93% on the test set, which is comparable to the reported 92.74% test accuracy on ToxicConversationsClassification. Perhaps surprisingly, when we manually inspect the mis-classified instances, many of them contains obvious and relatively short racial slurs.
To the best of our knowledge, the base model Mistral 7B is uncensored (in fact that's one of its selling points), so I wonder if you intentionally or accidentally did some model alignment during the fine-tuning, which may make it less sensitive to these racial slurs? If not, could you please share some thoughts regarding why would the model succeed in detecting long, complicated sentences of hate speech but fail in detecting the short and obvious ones?