Upload folder using huggingface_hub
Browse files
README.md
CHANGED
@@ -21094,25 +21094,32 @@ model-index:
|
|
21094 |
value: 78.51132446157838
|
21095 |
---
|
21096 |
|
21097 |
-
# mlx-community/modernbert-embed-base-8bit
|
21098 |
|
21099 |
-
The Model [mlx-community/modernbert-embed-base-8bit](https://huggingface.co/mlx-community/modernbert-embed-base-8bit) was converted to MLX format from [nomic-ai/modernbert-embed-base](https://huggingface.co/nomic-ai/modernbert-embed-base) using mlx-lm version **0.0.3**.
|
21100 |
|
21101 |
-
## Use with mlx
|
21102 |
|
21103 |
-
```bash
|
21104 |
-
pip install mlx-embeddings
|
21105 |
-
```
|
21106 |
|
21107 |
-
```python
|
21108 |
-
from mlx_embeddings import load, generate
|
|
|
21109 |
|
21110 |
-
model, tokenizer = load("mlx-community/modernbert-embed-base-8bit")
|
21111 |
|
21112 |
-
# For text embeddings
|
21113 |
-
output = generate(model, processor,
|
21114 |
-
#
|
21115 |
-
embeddings = output.text_embeds # Shape: [batch_size, hidden_size]
|
21116 |
|
|
|
|
|
21117 |
|
21118 |
-
|
|
|
|
|
|
|
|
|
|
|
|
21094 |
value: 78.51132446157838
|
21095 |
---
|
21096 |
|
21097 |
+
# mlx-community/modernbert-embed-base-8bit
|
21098 |
|
21099 |
+
The Model [mlx-community/modernbert-embed-base-8bit](https://huggingface.co/mlx-community/modernbert-embed-base-8bit) was converted to MLX format from [nomic-ai/modernbert-embed-base](https://huggingface.co/nomic-ai/modernbert-embed-base) using mlx-lm version **0.0.3**.
|
21100 |
|
21101 |
+
## Use with mlx
|
21102 |
|
21103 |
+
```bash
|
21104 |
+
pip install mlx-embeddings
|
21105 |
+
```
|
21106 |
|
21107 |
+
```python
|
21108 |
+
from mlx_embeddings import load, generate
|
21109 |
+
import mlx.core as mx
|
21110 |
|
21111 |
+
model, tokenizer = load("mlx-community/modernbert-embed-base-8bit")
|
21112 |
|
21113 |
+
# For text embeddings
|
21114 |
+
output = generate(model, processor, texts=["I like grapes", "I like fruits"])
|
21115 |
+
embeddings = output.text_embeds # Normalized embeddings
|
|
|
21116 |
|
21117 |
+
# Compute dot product between normalized embeddings
|
21118 |
+
similarity_matrix = mx.matmul(embeddings, embeddings.T)
|
21119 |
|
21120 |
+
print("
|
21121 |
+
Similarity matrix between texts:")
|
21122 |
+
print(similarity_matrix)
|
21123 |
+
|
21124 |
+
|
21125 |
+
```
|