Multi-Task Score Fusion
Background
A production ranker exposes multiple heads - predicted click, watch time, completion, like. The serving stack has to fuse these into one comparable score. The canonical combiner is a weighted geometric mean (i.e. weighted product in score space): . The weights are not learned - they're tuned via online A/B tests, expressing product trade-offs.
Problem statement
Implement multi_task_fusion(head_outputs, weights). head_outputs is a 2-D array of shape where each row is one item's head outputs in (typically click-prob, watch-time-frac, etc.). weights is a length- array of non-negative floats. Return a length- array of fused scores:
with a small on each factor to avoid / pathologies.
Input
head_outputs-np.ndarrayshape , values in .weights- array-like length , non-negative.eps- small float (default ).
Output
np.ndarraylength , fused scores.
Examples
Example 1 - equal weights
Input: head_outputs = [[0.5, 0.5], [0.8, 0.2]], weights = [1, 1]
Output: [0.25, 0.16]
Example 2 - weight a head to zero -> it drops out
Input: head_outputs = [[0.5, 0.9], [0.5, 0.1]], weights = [1, 0]
Output: ~[0.5, 0.5] # second head ignored
Constraints
- Use the numerically stable form: compute in log space then exponentiate.
exp(sum(w * log(p + eps))). - Negative weights raise
ValueError. - Mismatched lengths raise
ValueError.
Notes
- Why geometric, not arithmetic. Geometric (product / log-sum-exp-style) penalises items that are weak on any single head; arithmetic mean lets one strong head mask a weak one. Production rankers want a balanced item.
- Tuning weights. They're searched online via A/B factorial designs, typically in log-space (a 5x5 grid of exponents is a real experimentation plan).
▶ Run executes the 3 visible sample tests below in your browser. Submit runs the full suite — including hidden tests — on the server for an official verdict.
- •Reference example: equal weights give the product of probabilities
- •Sample: fractional weights across three heads
- •Reference: item strong on every head scores its geometric mean