Feature Extraction
Transformers
Safetensors
sentence-transformers
English
nvembed
mteb
custom_code
Eval Results (legacy)
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
Update configuration_nvembed.py (transformers + sentence-transformers) and infinity usage (#23)
Browse files- Update configuration_nvembed.py (792a641e6a3a67da84c2fb71e80212e94166de0e)
- Update usage instructions with infinity / Sentence Transformers (755e6afa538e05a0ecda68c92131522e64f54203)
Co-authored-by: Michael <michaelfeil@users.noreply.huggingface.co>
- README.md +8 -0
- configuration_nvembed.py +2 -0
README.md
CHANGED
|
@@ -2107,6 +2107,14 @@ scores = (query_embeddings @ passage_embeddings.T) * 100
|
|
| 2107 |
print(scores.tolist())
|
| 2108 |
```
|
| 2109 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2110 |
## License
|
| 2111 |
This model should not be used for any commercial purpose. Refer the [license](https://spdx.org/licenses/CC-BY-NC-4.0) for the detailed terms.
|
| 2112 |
|
|
|
|
| 2107 |
print(scores.tolist())
|
| 2108 |
```
|
| 2109 |
|
| 2110 |
+
### Usage (Infinity)
|
| 2111 |
+
|
| 2112 |
+
Usage via [Infinity, MIT License](https://github.com/michaelfeil/infinity).
|
| 2113 |
+
```bash
|
| 2114 |
+
docker run -it --gpus all -v ./data:/app/.cache -p 7997:7997 michaelf34/infinity:0.0.70 \
|
| 2115 |
+
v2 --model-id nvidia/NV-Embed-v2 --revision "refs/pr/23" --batch-size 8
|
| 2116 |
+
```
|
| 2117 |
+
|
| 2118 |
## License
|
| 2119 |
This model should not be used for any commercial purpose. Refer the [license](https://spdx.org/licenses/CC-BY-NC-4.0) for the detailed terms.
|
| 2120 |
|
configuration_nvembed.py
CHANGED
|
@@ -76,6 +76,8 @@ class LatentAttentionConfig(PretrainedConfig):
|
|
| 76 |
self.latent_dim = latent_dim
|
| 77 |
self.cross_dim_head = cross_dim_head
|
| 78 |
|
|
|
|
|
|
|
| 79 |
|
| 80 |
class BidirectionalMistralConfig(MistralConfig):
|
| 81 |
model_type = BIDIR_MISTRAL_TYPE
|
|
|
|
| 76 |
self.latent_dim = latent_dim
|
| 77 |
self.cross_dim_head = cross_dim_head
|
| 78 |
|
| 79 |
+
super().__init__(**kwargs)
|
| 80 |
+
|
| 81 |
|
| 82 |
class BidirectionalMistralConfig(MistralConfig):
|
| 83 |
model_type = BIDIR_MISTRAL_TYPE
|