Feature Extraction
sentence-transformers
PyTorch
Safetensors
Transformers
multilingual
llama_bidirec
text
text-embeddings
retrieval
semantic-search
custom_code
text-embeddings-inference
Instructions to use nvidia/llama-nemotron-embed-1b-v2 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- sentence-transformers
How to use nvidia/llama-nemotron-embed-1b-v2 with sentence-transformers:
from sentence_transformers import SentenceTransformer model = SentenceTransformer("nvidia/llama-nemotron-embed-1b-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] - Transformers
How to use nvidia/llama-nemotron-embed-1b-v2 with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("feature-extraction", model="nvidia/llama-nemotron-embed-1b-v2", trust_remote_code=True)# Load model directly from transformers import AutoModel model = AutoModel.from_pretrained("nvidia/llama-nemotron-embed-1b-v2", trust_remote_code=True, device_map="auto") - Notebooks
- Google Colab
- Kaggle
Oliver Holworthy commited on
Remove note about 4.47.1 required version of transformers
Browse filesSigned-off-by: Oliver Holworthy <nvidia-oliver-holworthy@users.noreply.huggingface.co>
README.md
CHANGED
|
@@ -64,10 +64,10 @@ This NeMo embedding model is a transformer encoder - a fine-tuned version of Lla
|
|
| 64 |
|
| 65 |
### **Sentence Transformers Usage**
|
| 66 |
|
| 67 |
-
The model
|
| 68 |
|
| 69 |
```bash
|
| 70 |
-
pip install transformers
|
| 71 |
```
|
| 72 |
|
| 73 |
```python
|
|
@@ -96,20 +96,16 @@ tensor([[ 0.5968, -0.0454],
|
|
| 96 |
```
|
| 97 |
|
| 98 |
### **Transformers Usage**
|
| 99 |
-
You can also use transformers directly to run the model. The model
|
| 100 |
|
| 101 |
```bash
|
| 102 |
-
pip install transformers
|
| 103 |
```
|
| 104 |
|
| 105 |
```python
|
| 106 |
import torch
|
| 107 |
import torch.nn.functional as F
|
| 108 |
from transformers import AutoTokenizer, AutoModel
|
| 109 |
-
import transformers
|
| 110 |
-
|
| 111 |
-
if transformers.__version__ != "4.47.1":
|
| 112 |
-
raise Exception("transformers version must be 4.47.1 to run this model")
|
| 113 |
|
| 114 |
|
| 115 |
def average_pool(last_hidden_states, attention_mask):
|
|
|
|
| 64 |
|
| 65 |
### **Sentence Transformers Usage**
|
| 66 |
|
| 67 |
+
The model supports transformers versions 4.44 through 5.0+.
|
| 68 |
|
| 69 |
```bash
|
| 70 |
+
pip install transformers sentence-transformers
|
| 71 |
```
|
| 72 |
|
| 73 |
```python
|
|
|
|
| 96 |
```
|
| 97 |
|
| 98 |
### **Transformers Usage**
|
| 99 |
+
You can also use transformers directly to run the model. The model supports transformers versions 4.44 through 5.0+.
|
| 100 |
|
| 101 |
```bash
|
| 102 |
+
pip install transformers
|
| 103 |
```
|
| 104 |
|
| 105 |
```python
|
| 106 |
import torch
|
| 107 |
import torch.nn.functional as F
|
| 108 |
from transformers import AutoTokenizer, AutoModel
|
|
|
|
|
|
|
|
|
|
|
|
|
| 109 |
|
| 110 |
|
| 111 |
def average_pool(last_hidden_states, attention_mask):
|