skills/nlp/pairwise-softmax-rank-aggregation/SKILL.md
Converts pairwise binary predictions into continuous ranks via temperature-scaled softmax weighted sum over anchor positions.
npx skillsauth add wenmin-wu/ds-skills nlp-pairwise-softmax-rank-aggregationInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
In pairwise ranking, a model predicts P(A > B) for every pair (A, B). To recover a global ordering, apply temperature-scaled softmax over pairwise scores for each query item, then compute a weighted sum of anchor positions. The temperature controls sharpness: high temperature produces a soft average, low temperature approaches argmax. This converts N binary predictions into a single continuous rank value.
import numpy as np
def pairwise_to_rank(pairwise_preds, anchor_positions, temperature=20):
"""Convert pairwise scores to a continuous rank.
Args:
pairwise_preds: array of P(query > anchor_i) for each anchor
anchor_positions: known positions of anchor items (e.g., code cell ranks)
temperature: higher = sharper softmax (default 20)
"""
centered = pairwise_preds - np.mean(pairwise_preds)
weights = np.exp(centered * temperature)
weights /= weights.sum()
return np.sum(weights * anchor_positions)
# For each markdown cell, predict rank relative to all code cells
for i, md_preds in enumerate(all_pairwise_preds):
ranks[i] = pairwise_to_rank(md_preds, code_cell_ranks)
data-ai
Scaled Pinball Loss (SPL) metric for evaluating quantile forecasts, normalized by mean absolute successive differences of training data
data-ai
Walk backward through a time series and multiplicatively rescale segments when jumps exceed a fraction of the running mean to correct data collection anomalies
testing
Transform forecasting target to next/current ratio minus one so that optimizing MAE or squared error implicitly minimizes SMAPE
tools
Convert point forecasts to prediction intervals by scaling with logit-transformed quantile ratios passed through a Normal CDF