ModernBert
Collection
16 items
•
Updated
•
2
The Model mlx-community/answerdotai-ModernBERT-Large-Instruct-4bit was converted to MLX format from answerdotai/ModernBERT-Large-Instruct using mlx-lm version 0.0.3.
pip install mlx-embeddings
from mlx_embeddings import load, generate
import mlx.core as mx
model, tokenizer = load("mlx-community/answerdotai-ModernBERT-Large-Instruct-4bit")
# For text embeddings
output = generate(model, processor, texts=["I like grapes", "I like fruits"])
embeddings = output.text_embeds # Normalized embeddings
# Compute dot product between normalized embeddings
similarity_matrix = mx.matmul(embeddings, embeddings.T)
print("Similarity matrix between texts:")
print(similarity_matrix)