TensorTonic
Study Plans
Study Plan
Remove Response-Length Bias from Judge Scores
Metrics & EvaluationLanguage Models
Hard

Separate model preference from response-length bias in pairwise judge votes. For comparison nnn, ana_nan​ and bnb_nbn​ are model IDs, Δn\Delta_nΔn​ is response A's length minus response B's length, and yny_nyn​ is one for an A win, zero for a B win or one half for a tie. With model utilities uiu_iui​ and length coefficient β\betaβ, predict:

pn=σ(uan−ubn+βΔn).p_n=\sigma(u_{a_n}-u_{b_n}+\beta\Delta_n).pn​=σ(uan​​−ubn​​+βΔn​).

Here, σ\sigmaσ is the logistic sigmoid and pnp_npn​ the A-win probability. For MMM comparisons, fit the mean binary cross-entropy:

L=−1M∑n[ynlog⁡pn+(1−yn)log⁡(1−pn)].L=-\frac{1}{M}\sum_n\left[y_n\log p_n+(1-y_n)\log(1-p_n)\right].L=−M1​n∑​[yn​logpn​+(1−yn​)log(1−pn​)].

Log is the natural logarithm. Initialize utilities and the coefficient to zero. Perform exactly steps full-batch gradient-descent updates with the supplied learning rate, updating both from the same pre-update values. Center all utilities after each update. With no comparisons, the parameters stay zero.

Evaluate the fitted model at zero length difference:

pn(0)=σ(uan−ubn).p_n^{(0)}=\sigma(u_{a_n}-u_{b_n}).pn(0)​=σ(uan​​−ubn​​).

A model's win rate averages pn(0)p_n^{(0)}pn(0)​ over its A appearances and 1−pn(0)1-p_n^{(0)}1−pn(0)​ over its B appearances; an unseen model receives 0.5.

Return a Python dictionary with length_coefficient as a Python float, debiased_probabilities as a float64 PyTorch tensor of shape (M,) in comparison order, and model_win_rates as a float64 PyTorch tensor of shape (num_models,) in model-index order. Both tensors use the outcomes device.

Loading visualization...

Examples

Input: num_models = 2, model_a = [0,1,0,1], model_b = [1,0,1,0], length_differences = [2,2,-2,-2], outcomes = [1,1,0,0], steps = 20, learning_rate = 0.1

Output: {"length_coefficient":0.994088,"debiased_probabilities":[0.5,0.5,0.5,0.5],"model_win_rates":[0.5,0.5]}

Explanation: Model identity is balanced across longer and shorter responses, so the fitted preference is assigned to length while zero-length probabilities stay neutral.

Input: num_models = 2, model_a = [0,1], model_b = [1,0], length_differences = [0,0], outcomes = [0.5,0.5], steps = 10, learning_rate = 0.1

Output: {"length_coefficient":0,"debiased_probabilities":[0.5,0.5],"model_win_rates":[0.5,0.5]}

Input: num_models = 3, model_a = [0], model_b = [1], length_differences = [0], outcomes = [1], steps = 10, learning_rate = 0.1

Output: {"length_coefficient":0,"debiased_probabilities":[0.691512],"model_win_rates":[0.691512,0.308488,0.5]}

Hint 1

torch.sigmoid evaluates logistic probabilities elementwise.

Hint 2

Tensor.index_add_ accumulates values for repeated model IDs.

Hint 3

torch.bincount counts appearances of nonnegative integer IDs.

Requirements

  • Use PyTorch float64 arithmetic.
  • Fit with the supplied length differences, but evaluate the returned probabilities without length bias.
  • Do not modify input tensors.

Constraints

  • num_models is a positive Python integer; model IDs range from zero to num_models minus one.
  • model_a and model_b are aligned one-dimensional int64 PyTorch tensors; the two IDs in each comparison differ.
  • length_differences and outcomes are aligned, finite float64 PyTorch tensors.
  • Outcomes are 0, 0.5 or 1; comparisons may be empty or repeated and models may be unseen.
  • steps is a nonnegative Python integer; learning_rate is a positive finite Python number.
  • Tensor inputs share a device and may be noncontiguous.
Try Similar Problems
Fit Elo Ratings from Pairwise VotesHardCompute Conditional PerplexityMediumScore Multiple-Choice ContinuationsMediumDecode Attention with a KV CacheHardRecover an IsoFLOP Compute-Optimal FrontierHardFit a Data Power Law with a Noise FloorHardTop-k MoE Router with Load StatisticsHardRoute Cache-Aware Prefill RequestsHardImplement Speculative Decoding and Token VerificationHardBeam Search DecodingHardEvaluation Metrics (BLEU, ROUGE)MediumAUC-ROC from ScratchMedium

Accepts: number

Accepts: array

Accepts: array

Accepts: array

Accepts: array

Accepts: number

Accepts: number

You must run your code first.

Remove Response-Length Bias from Judge Scores

Metrics & EvaluationLanguage Models
Hard

Separate model preference from response-length bias in pairwise judge votes. For comparison nnn, ana_nan​ and bnb_nbn​ are model IDs, Δn\Delta_nΔn​ is response A's length minus response B's length, and yny_nyn​ is one for an A win, zero for a B win or one half for a tie. With model utilities uiu_iui​ and length coefficient β\betaβ, predict:

pn=σ(uan−ubn+βΔn).p_n=\sigma(u_{a_n}-u_{b_n}+\beta\Delta_n).pn​=σ(uan​​−ubn​​+βΔn​).

Here, σ\sigmaσ is the logistic sigmoid and pnp_npn​ the A-win probability. For MMM comparisons, fit the mean binary cross-entropy:

L=−1M∑n[ynlog⁡pn+(1−yn)log⁡(1−pn)].L=-\frac{1}{M}\sum_n\left[y_n\log p_n+(1-y_n)\log(1-p_n)\right].L=−M1​n∑​[yn​logpn​+(1−yn​)log(1−pn​)].

Log is the natural logarithm. Initialize utilities and the coefficient to zero. Perform exactly steps full-batch gradient-descent updates with the supplied learning rate, updating both from the same pre-update values. Center all utilities after each update. With no comparisons, the parameters stay zero.

Evaluate the fitted model at zero length difference:

pn(0)=σ(uan−ubn).p_n^{(0)}=\sigma(u_{a_n}-u_{b_n}).pn(0)​=σ(uan​​−ubn​​).

A model's win rate averages pn(0)p_n^{(0)}pn(0)​ over its A appearances and 1−pn(0)1-p_n^{(0)}1−pn(0)​ over its B appearances; an unseen model receives 0.5.

Return a Python dictionary with length_coefficient as a Python float, debiased_probabilities as a float64 PyTorch tensor of shape (M,) in comparison order, and model_win_rates as a float64 PyTorch tensor of shape (num_models,) in model-index order. Both tensors use the outcomes device.

Loading visualization...

Examples

Input: num_models = 2, model_a = [0,1,0,1], model_b = [1,0,1,0], length_differences = [2,2,-2,-2], outcomes = [1,1,0,0], steps = 20, learning_rate = 0.1

Output: {"length_coefficient":0.994088,"debiased_probabilities":[0.5,0.5,0.5,0.5],"model_win_rates":[0.5,0.5]}

Explanation: Model identity is balanced across longer and shorter responses, so the fitted preference is assigned to length while zero-length probabilities stay neutral.

Input: num_models = 2, model_a = [0,1], model_b = [1,0], length_differences = [0,0], outcomes = [0.5,0.5], steps = 10, learning_rate = 0.1

Output: {"length_coefficient":0,"debiased_probabilities":[0.5,0.5],"model_win_rates":[0.5,0.5]}

Input: num_models = 3, model_a = [0], model_b = [1], length_differences = [0], outcomes = [1], steps = 10, learning_rate = 0.1

Output: {"length_coefficient":0,"debiased_probabilities":[0.691512],"model_win_rates":[0.691512,0.308488,0.5]}

Hint 1

torch.sigmoid evaluates logistic probabilities elementwise.

Hint 2

Tensor.index_add_ accumulates values for repeated model IDs.

Hint 3

torch.bincount counts appearances of nonnegative integer IDs.

Requirements

  • Use PyTorch float64 arithmetic.
  • Fit with the supplied length differences, but evaluate the returned probabilities without length bias.
  • Do not modify input tensors.

Constraints

  • num_models is a positive Python integer; model IDs range from zero to num_models minus one.
  • model_a and model_b are aligned one-dimensional int64 PyTorch tensors; the two IDs in each comparison differ.
  • length_differences and outcomes are aligned, finite float64 PyTorch tensors.
  • Outcomes are 0, 0.5 or 1; comparisons may be empty or repeated and models may be unseen.
  • steps is a nonnegative Python integer; learning_rate is a positive finite Python number.
  • Tensor inputs share a device and may be noncontiguous.
Try Similar Problems
Fit Elo Ratings from Pairwise VotesHardCompute Conditional PerplexityMediumScore Multiple-Choice ContinuationsMediumDecode Attention with a KV CacheHardRecover an IsoFLOP Compute-Optimal FrontierHardFit a Data Power Law with a Noise FloorHardTop-k MoE Router with Load StatisticsHardRoute Cache-Aware Prefill RequestsHardImplement Speculative Decoding and Token VerificationHardBeam Search DecodingHardEvaluation Metrics (BLEU, ROUGE)MediumAUC-ROC from ScratchMedium

Accepts: number

Accepts: array

Accepts: array

Accepts: array

Accepts: array

Accepts: number

Accepts: number

You must run your code first.