Instructions to use Muzian/minimind-rerank-dense with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- sentence-transformers
How to use Muzian/minimind-rerank-dense with sentence-transformers:
from sentence_transformers import CrossEncoder model = CrossEncoder("Muzian/minimind-rerank-dense") query = "Which planet is known as the Red Planet?" passages = [ "Venus is often called Earth's twin because of its similar size and proximity.", "Mars, known for its reddish appearance, is often referred to as the Red Planet.", "Jupiter, the largest planet in our solar system, has a prominent red spot.", "Saturn, famous for its rings, is sometimes mistaken for the Red Planet." ] scores = model.predict([(query, passage) for passage in passages]) print(scores) - Notebooks
- Google Colab
- Kaggle
MiniMind-Rerank-Dense
A cross-encoder reranker built on the MiniMind-3 small language model (64M params), with the design fully aligned with Qwen3-Reranker. Part of the minimind-embedding project.
π How It Works
π‘ Instead of a separate scoring head, this model reuses the language model's
lm_head: given a query and a document, it predicts whether the next token isζ―(yes, relevant) orε¦(no, irrelevant). The probability ofζ―becomes the relevance score.
Prompt template:
<|im_start|>system
ε€ζδΈι’ηζζ‘£ζ―ε¦η¬¦εζ₯θ―’ιζ±,εͺεε€ζ―ζε¦<|im_end|>
<|im_start|>user
ζ₯θ―’:{query}
ζζ‘£:{document}<|im_end|>
<|im_start|>assistant
<think>
</think>
The model predicts the next token after </think>: ζ― (id=357) or ε¦ (id=1332). The softmax probability of ζ― is the relevance score (0~1).
ποΈ Model Details
| Item | Value |
|---|---|
| Architecture | MiniMind-3 (causal decoder-only Transformer) |
| Parameters | 64M |
| Hidden size | 768 |
| Layers | 8 |
| Vocab size | 6400 |
| Max sequence length | 8192 |
| Scoring | pointwise yes/no (next-token prediction) |
| Target tokens | ζ― (id=357) / ε¦ (id=1332) |
π Training
Trained on C-MTEB/T2Reranking (80% train split, 20% held-out for evaluation β no data leakage).
| Config | Value |
|---|---|
| Training data | T2Reranking, 80k query-doc pairs |
| Epochs | 3 |
| Batch size | 16 |
| Learning rate | 1e-5 (cosine decay) |
| Loss | Pointwise cross-entropy |
π Evaluation
C-MTEB/T2Reranking (MAP@10)
| Method | MAP@10 | Accuracy | Note |
|---|---|---|---|
| Zero-shot (pretrained backbone) | 0.472 | β | baseline |
| Full fine-tuning + Stage3 merge | 0.915 | 85% | β +94% |
| Frozen backbone (lm_head only) | 0.650 | 63% | also works (+38%) |
The Three Bugs Story
The reranker's development hit three cascading bugs that initially made all experiments look like "training makes it worse." Each fix drove the score up:
| Bug | Symptom | Root Cause | Fix | After Fix |
|---|---|---|---|---|
| β Label mapping reversed | All training decreased score (0.47β0.24) | cross_entropy(logits, labels): label=1 maps to index 1 (ε¦), but intent was "relevantβζ―"(index 0) |
target = 1 - labels |
0.47β0.65 |
| β‘ Data leakage | Score inflated (0.94) | T2Reranking has only dev split; train and eval used the same data | 80/20 split train/test | 0.94β0.92 (real) |
| β’ Tokenizer fragmentation | Prompt wasted tokens | <Query>/<Document> split into 5 BPE fragments |
Switch to Chinese ζ₯θ―’:/ζζ‘£: |
tokens 79β56 |
Key takeaway: the 64M MiniMind backbone is fully capable of reranker fine-tuning. The earlier "catastrophic forgetting" conclusion was a label bug artifact. After fixes, full fine-tuning achieves MAP@10=0.915.
π Usage
import torch
import torch.nn.functional as F
# Load with the project's modeling code
# from shared.model import MiniMindForRerank
# from shared.configs import rerank_dense_64m
# from shared.tokenizer import load_tokenizer, build_rerank_inputs
# model = MiniMindForRerank(rerank_dense_64m())
# model.load_state_dict(torch.load("rerank_768.pth"), strict=False)
# tokenizer = load_tokenizer(padding_side="left")
queries = ["倩空为δ»δΉζ―θθ²"]
documents = ["ι³ε
ζ£ε°δ½Ώε€©η©Ίεθθ²γ", "ηΊ’η§θηεζ³ζ―..."]
# Build prompt inputs
# enc = build_rerank_inputs(tokenizer, queries, documents, max_length=512)
# Score = probability of ζ―
# scores = model.predict(enc["input_ids"], enc["attention_mask"])
# Higher score = more relevant
β οΈ Limitations
- Same backbone limitations (vocab=6400, limited training data)
- Only trained on T2Reranking β domain transfer to other reranking tasks untested
- MoE version not yet trained
π Acknowledgements
- Base: MiniMind by @jingyaogong
- Route: Qwen3-Reranker
- Data: C-MTEB/T2Reranking
- Eval: MTEB
π License
Apache 2.0
- Downloads last month
- 33
Model tree for Muzian/minimind-rerank-dense
Base model
jingyaogong/minimind-3
