afanjul/gte-reranker-modernbert-base-mlx
The Model afanjul/gte-reranker-modernbert-base-mlx was converted to MLX format from Alibaba-NLP/gte-reranker-modernbert-base using mlx-lm version 0.1.1.
Use with mlx
pip install mlx-embeddings
from mlx_embeddings import load, generate
import mlx.core as mx
model, tokenizer = load("afanjul/gte-reranker-modernbert-base-mlx")
# For reranking (sequence classification)
pairs = [
["what is the capital of China?", "Beijing"],
["how to implement quick sort in python?", "Introduction of quick sort"],
]
output = generate(model, processor, texts=pairs, max_length=8192)
scores = output.pooler_output.squeeze()
print("Reranking scores:")
for pair, score in zip(pairs, scores.tolist()):
print(f" Query: {pair[0]}")
print(f" Document: {pair[1]}")
print(f" Score: {score:.4f}")
print()