CoolFace
Modelpublic

MO7YW4NG/ms-marco-MiniLM-L-6-v2-4bit-nf4

sourceHugging Faceapache-2.0updated 7mo agoView on Hugging Face
0likes9downloads
Model Card

MiniLM-L6-v2 Cross-Encoder (4-bit NF4 Quantized)

A 4-bit NF4 quantized version of `cross-encoder/ms-marco-MiniLM-L-6-v2` for passage reranking, using bitsandbytes quantization.

Quantization Details

SettingValue
Methodbitsandbytes NF4
Bits4
Double quantizationYes
Compute dtypefloat16
Skipped modulesclassifier (kept in fp16)
Base model params22.7M
Quantized weight size~17M effective params

Evaluation

Evaluated on three IR benchmarks using a BM25 (top-100) + neural reranking pipeline.

LitSearch (Academic Literature Search)

ModelParamsR@5R@20MRR@10NDCG@10
BM25 only—0.29510.36070.19700.2287
MiniLM-L6-v2 (fp32)23M0.44260.60660.34450.3796
MiniLM-L6-v2 (4-bit NF4)17M0.44260.60660.34350.3822
BGE-reranker-base278M0.42620.55740.32430.3754
BGE-reranker-v2-m3568M0.44260.60660.38010.4070

SciFact (Scientific Fact Verification)

ModelParamsR@5R@20MRR@10NDCG@10
BM25 only—0.58930.70200.54160.5609
MiniLM-L6-v2 (fp32)23M0.71550.76280.64630.6605
MiniLM-L6-v2 (4-bit NF4)17M0.70650.76280.63960.6556
BGE-reranker-base278M0.69520.77930.62970.6481
BGE-reranker-v2-m3568M0.72300.80630.64600.6682

NFCorpus (Biomedical IR)

ModelParamsR@5R@20MRR@10NDCG@10
BM25 only—0.10480.15120.44700.2688
MiniLM-L6-v2 (fp32)23M0.11940.16490.51810.3045
MiniLM-L6-v2 (4-bit NF4)17M0.11920.16550.51550.3050
BGE-reranker-base278M0.11190.14930.46760.2717
BGE-reranker-v2-m3568M0.10670.15550.48080.2726

Summary

4-bit NF4 quantization preserves near-identical quality across all three benchmarks:

Datasetfp32 NDCG@104-bit NDCG@10Delta
LitSearch0.37960.3822+0.07%
SciFact0.66050.6556−0.07%
NFCorpus0.30450.3050+0.02%

Usage

With transformers

python
from transformers import AutoModelForSequenceClassification, AutoTokenizer
import torch

model = AutoModelForSequenceClassification.from_pretrained(
    "MO7YW4NG/ms-marco-MiniLM-L-6-v2-4bit-nf4",
    device_map="auto",
)
tokenizer = AutoTokenizer.from_pretrained(
    "MO7YW4NG/ms-marco-MiniLM-L-6-v2-4bit-nf4",
)

query = "What is the impact of climate change on coral reefs?"
passage = "Rising ocean temperatures cause widespread coral bleaching events..."

inputs = tokenizer(
    query, passage,
    return_tensors="pt",
    truncation=True,
    max_length=512,
    padding=True,
).to(model.device)

with torch.no_grad():
    score = model(**inputs).logits.squeeze().item()
print(f"Relevance score: {score:.4f}")

With sentence-transformers CrossEncoder

python
from sentence_transformers.cross_encoder import CrossEncoder

model = CrossEncoder(
    "MO7YW4NG/ms-marco-MiniLM-L-6-v2-4bit-nf4",
    max_length=512,
)

query = "What is the impact of climate change on coral reefs?"
passages = [
    "Rising ocean temperatures cause widespread coral bleaching events...",
    "The history of marine biology dates back to ancient Greece...",
]

pairs = [[query, p] for p in passages]
scores = model.predict(pairs)
print(scores)

Technical Notes

  • —The classifier head is kept in fp16 (not quantized) to maintain output precision.
  • —Requires bitsandbytes and a CUDA-capable GPU at inference time.
  • —Model size on disk: ~17 MB (vs ~88 MB for fp32).

Citation

Base model:

bibtex
@misc{ms-marco-MiniLM-L-6-v2,
  title={MS MARCO Cross-Encoder MiniLM-L-6-v2},
  author={Nils Reimers},
  url={https://huggingface.co/cross-encoder/ms-marco-MiniLM-L-6-v2},
}