Views
No views yet
nvidia/llama-embed-nemotron-8b — the #1 embedding model under 20B parameters on the MTEB leaderboard, outperforming models 3x its size.| Variant | Size | Relevant ↑ | Irrelevant ↓ | Margin ↑ |
|---|---|---|---|---|
| fp16 | 15 GB | 0.3763 | 0.0579 | 0.3184 |
| 8-bit | 7.5 GB | 0.3780 | 0.0583 | 0.3197 |
| 4-bit | 4.0 GB | 0.3826 | 0.0783 | 0.3043 |
| 2-bit | 2.4 GB | 0.4799 | 0.2873 | 0.1926 |
pip install mlx-embeddings1from mlx_embeddings.utils import load
2import mlx.core as mx
3
4model, tokenizer = load("ncorder/llama-embed-nemotron-8b-mlx-fp16")
5
6query = "Instruct: Given a question, retrieve passages that answer the question\nQuery: How do neural networks learn patterns from examples?"
7document = "Deep learning models adjust their weights through backpropagation."
8
9def embed(text):
10 inputs = tokenizer(text, return_tensors="np", padding=True)
11 out = model(
12 mx.array(inputs["input_ids"]),
13 mx.array(inputs["attention_mask"])
14 )
15 return out.text_embeds
16
17q_emb = embed(query)
18d_emb = embed(document)
19score = (q_emb @ d_emb.T).item()
20print(f"Similarity: {score:.4f}")Instruct: {task_instruction}
Query: {your_query}nvidia/llama-embed-nemotron-8bmlx-embeddings by Prince Canuma