协作头脑风暴
brainstorming
在实现前澄清需求、探索设计选择,并形成清晰的开发方向。
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.
独立 GitHub 快照 · 自动分类 · 以原作者文档为准
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.
CrossEncoder.predict, including single pair vs batch-of-pairs shape decisions.CrossEncoder.rank, top_k, return_documents, stable corpus_id handling, batching, prompts, and device placement.num_labels, activation_fn, and apply_softmax behavior.semantic_search, hard-negative mining, quantized embeddings, and vector database orchestration belong in ../retrieval-and-utilities/SKILL.md.../evaluation-and-training/SKILL.md.../backend-export-optimization/SKILL.md.SentenceTransformer.encode embeddings and similarity belong in ../embeddings-and-similarity/SKILL.md.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.
references/api-reference.mdreferences/workflows.mdreferences/troubleshooting.mdscripts/cross_encoder_rerank_smoke.py --helprank is for single-label rerankers (num_labels == 1); use predict for multi-class pair classifiers.corpus_id back to first-stage hits.activation_fn=torch.nn.Sigmoid() if the downstream consumer needs 0-1 scores. Ranking order is usually unchanged by monotonic activations.