reranking-cross-encoder
Use for sentence-transformers CrossEncoder pair scoring, reranking, rank API usage, retrieve-and-rerank handoffs, multimodal reranker routing, and activation/softmax/num_labels pitfalls.
- License 许可
- Apache-2.0
- 最近更新
- 2026-09-03
- Stars
- ★ 351
- Forks
- 27
01 前言 Front Matter
- name
- reranking-cross-encoder
- license
- Apache 2.0
- metadata
- { "disco-role": "operating" }
- description
- Use for sentence-transformers CrossEncoder pair scoring, reranking, rank API usage, retrieve-and-rerank handoffs, multimodal reranker routing, and activation/softmax/num_labels pitfalls.
- disable-model-invocation
- true
02 资源文件 4
- 参考文档references/api-reference.md6.3 KB
- 参考文档references/troubleshooting.md6.7 KB
- 参考文档references/workflows.md6.3 KB
- 脚本scripts/cross_encoder_rerank_smoke.py5.3 KB
03 SKILL.md 正文
Reranking Cross Encoder
Use this sub-skill when the task is about scoring input pairs with CrossEncoder, reranking an already-retrieved candidate list, choosing between a reranker and a bi-encoder, or debugging CrossEncoder predict/rank outputs.
Route Here For
- Pair scoring with
CrossEncoder.predict, including single pair vs batch-of-pairs shape decisions. - Reranking an existing list of candidate documents with
CrossEncoder.rank,top_k,return_documents, stablecorpus_idhandling, batching, prompts, and device placement. - Choosing a CrossEncoder reranker over a bi-encoder when accuracy on a limited candidate set matters more than precomputed embeddings or high-throughput first-stage retrieval.
- Regression reranker vs pair-classification setup, especially
num_labels,activation_fn, andapply_softmaxbehavior. - Multimodal reranker routing for text-image/audio/video-capable CrossEncoder checkpoints.
Route Elsewhere
- First-stage dense retrieval,
semantic_search, hard-negative mining, quantized embeddings, and vector database orchestration belong in../retrieval-and-utilities/SKILL.md. - Detailed loss/evaluator/trainer selection belongs in
../evaluation-and-training/SKILL.md. - ONNX/OpenVINO export and backend optimization belong in
../backend-export-optimization/SKILL.md. - Dense
SentenceTransformer.encodeembeddings and similarity belong in../embeddings-and-similarity/SKILL.md.
Fast Pattern
from sentence_transformers import CrossEncoder
model = CrossEncoder("cross-encoder/ms-marco-MiniLM-L6-v2")
query = "How many people live in Berlin?"
documents = [
"Berlin had 3,520,031 registered inhabitants.",
"Berlin is well known for its museums.",
]
results = model.rank(query, documents, top_k=2, return_documents=True)
rank returns dictionaries sorted by descending score. Each result includes corpus_id from the input documents list, score, and text when return_documents=True.
Essential References
- API details:
references/api-reference.md - Reranking workflows:
references/workflows.md - Failure diagnosis:
references/troubleshooting.md - Safe CLI smoke helper:
scripts/cross_encoder_rerank_smoke.py --help
Ground Rules
- CrossEncoders score pairs jointly; they do not create reusable document embeddings.
rankis for single-label rerankers (num_labels == 1); usepredictfor multi-class pair classifiers.- Preserve stable corpus IDs by reranking the exact candidate list order and mapping
corpus_idback to first-stage hits. - For MS MARCO-style rerankers, raw logits may be unbounded; pass
activation_fn=torch.nn.Sigmoid()if the downstream consumer needs 0-1 scores. Ranking order is usually unchanged by monotonic activations. - Do not make the reranker retrieve the whole corpus. Retrieve top candidates first, then rerank only that shortlist.
04 同仓库更多 Skills
passnet-triton-opt
Make a single PassNet Triton kernel fast AND numerically faithful: performance model (when a replacement can win at all), block/grid/warp tuning, autotune policy, launch overhead, and per-op numeric recipes to pass the dtype baseline tolerances. Use when a pass matches and is correct but speedup below expected, or when correctness fails by small numeric margins.
passnet-solve
END-TO-END playbook for solving one PassNet sample: analyze the computation graphs, decide the optimization strategy (what to fuse, what to replace, what to leave alone), drive the iteration loop, and maximize the sample score. This is the ENTRY skill — invoke it first for any PassNet optimization task; it tells you when to use passnet-pattern-fusion, passnet-triton-opt and passnet-feedback.
passnet-skill
PassNet GPU kernel optimization via compiler passes. Design and implement Triton-based optimization passes, create pass files under ./pass_dir/, self-evaluate with pass_evaluator, and iterate to maximize GPU speedup.
passnet-pattern-fusion
Author PassNet pass files: write patterns that actually MATCH the FX graph, pick fusion regions (which ops to absorb into one Triton kernel), and structure multi-pass submissions with the mandatory shared-dispatch architecture. Use when creating or fixing pattern()/replacement_args()/replacement_func() files, when a pass "failed to match", or when deciding how to fuse multiple kernels/ops.
passnet-orchestrate
Round/batch planning and decision support for PassNet graph optimization. Use for multi-sample triage, worker allocation, eval-budget policy, and post-eval keep/revert decisions. For solving one concrete sample end to end, use passnet-solve as the entry skill; consult this skill only when you need broader planning or a specific decision gate.
passnet-feedback
Fast, deterministic feedback for PassNet work: pre-flight pattern/match verification WITHOUT burning a GPU evaluation, per-node bottleneck analysis of a sample's graphs, and eval-log parsing into per-variant status + estimated score + failure classification. Use BEFORE every GPU evaluation (check_pattern), at the START of a sample (analyze_graph), and AFTER every evaluation (parse_eval_log).