Loading…
Loading…
This is an MLX conversion of hotchpotch/japanese-reranker-xsmall-v2, a lightweight Japanese reranker (cross-encoder) model. All credit for the original model goes to its author.
pip install -U mlx-embeddings
from mlx_embeddings import load
from transformers import AutoTokenizer
import mlx.core as mx
model, tokenizer = load("masahiroid/japanese-reranker-xsmall-v2-mlx")
hf_tokenizer = AutoTokenizer.from_pretrained("hotchpotch/japanese-reranker-xsmall-v2")
query = "瑠璃色はどんな色?"
document = "瑠璃色(るりいろ)は、紫みを帯びた濃い青。"
enc = hf_tokenizer(query, document, return_tensors="np")
input_ids = mx.array(enc["input_ids"])
attention_mask = mx.array(enc["attention_mask"])
out = model(input_ids, attention_mask)
score = out.pooler_output # relevance score in [0, 1]
print(score)
Audited against its upstream with model-audit-lite: weight format, bundled code, and a machine-readable lineage (ML-BOM). Details, checksums and how to reproduce: SECURITY.md.
hotchpotch/japanese-reranker-xsmall-v2(軽量な日本語reranker、ModernBERTベース)のMLX変換版です。元モデルの著作権はその作者に帰属します。
pip install -U mlx-embeddings
from mlx_embeddings import load
from transformers import AutoTokenizer
import mlx.core as mx
model, tokenizer = load("masahiroid/japanese-reranker-xsmall-v2-mlx")
hf_tokenizer = AutoTokenizer.from_pretrained("hotchpotch/japanese-reranker-xsmall-v2")
query = "瑠璃色はどんな色?"
document = "瑠璃色(るりいろ)は、紫みを帯びた濃い青。"
enc = hf_tokenizer(query, document, return_tensors="np")
input_ids = mx.array(enc["input_ids"])
attention_mask = mx.array(enc["attention_mask"])
out = model(input_ids, attention_mask)
score = out.pooler_output # 0〜1の関連度スコア
print(score)
model-audit-lite で変換元と突き合わせて監査済みです(重みの形式、同梱コード、機械可読な系譜=ML-BOM)。詳細・チェックサム・再現方法は SECURITY.md をご覧ください。