Compare named training-data mixtures by fitting a scaling curve to each row of observed sizes and losses:
Lk(D)=Ek+AkD−αk.Here, k identifies a mixture, D is its data size, Lk(D) is predicted loss, Ek is the loss floor, Ak is a positive coefficient, and αk is a positive decay exponent. For each candidate floor below every observed loss in that row, the fit is unweighted least squares in natural-log space:
log(Lk,i−Ek)=ak+bklogDk,i.Index i identifies an observation; Dk,i and Lk,i are its size and loss. The fitted intercept is ak=logAk and slope is bk=−αk. Among fits with positive finite coefficient and exponent, select the smallest root mean squared error on the original loss scale, keeping the first candidate on ties. The mixture with the lowest prediction at target_size wins; ties favor the earlier mixture.
Return a Python dictionary with fits, a mixture-ordered list of dictionaries containing name (string) and floor, coefficient, exponent, rmse (Python floats); target_predictions, a float64 PyTorch tensor of shape (number of mixtures,) on the input device; winning_mixture, its name; and winning_index, its zero-based Python integer index.
Input: mixture_names = ["balanced","code"], data_sizes = [[1,4,16],[1,4,16]], losses = [[5,3,2],[6.5,3.5,2]], target_size = 64, floor_candidates = [0.5,1]
Output: {"fits":[{"name":"balanced","floor":1,"coefficient":4,"exponent":0.5,"rmse":0},{"name":"code","floor":0.5,"coefficient":6,"exponent":0.5,"rmse":0}],"target_predictions":[1.5,1.25],"winning_mixture":"code","winning_index":1}
Explanation: The code mixture begins with higher observed loss but its fitted curve extrapolates below the balanced curve at size 64.
Input: mixture_names = ["first","second"], data_sizes = [[1,4,16],[1,4,16]], losses = [[3,2,1.5],[3,2,1.5]], target_size = 64, floor_candidates = [1]
Output: {"fits":[{"name":"first","floor":1,"coefficient":2,"exponent":0.5,"rmse":0},{"name":"second","floor":1,"coefficient":2,"exponent":0.5,"rmse":0}],"target_predictions":[1.25,1.25],"winning_mixture":"first","winning_index":0}
Input: mixture_names = ["web","books","code"], data_sizes = [[1,4,16],[1,4,16],[1,4,16]], losses = [[4,2.5,1.75],[5,3,2],[3,1.75,1.125]], target_size = 64, floor_candidates = [0.5,1]
Output: {"fits":[{"name":"web","floor":1,"coefficient":3,"exponent":0.5,"rmse":0},{"name":"books","floor":1,"coefficient":4,"exponent":0.5,"rmse":0},{"name":"code","floor":0.5,"coefficient":2.5,"exponent":0.5,"rmse":0}],"target_predictions":[1.375,1.5,0.8125],"winning_mixture":"code","winning_index":2}
torch.linalg.lstsq solves a least-squares system.
torch.argmin returns the first index when minimum values tie.
enumerate keeps each mixture name aligned with its tensor row.
Accepts: array
Accepts: array
Accepts: array
Accepts: number
Accepts: array
Compare named training-data mixtures by fitting a scaling curve to each row of observed sizes and losses:
Lk(D)=Ek+AkD−αk.Here, k identifies a mixture, D is its data size, Lk(D) is predicted loss, Ek is the loss floor, Ak is a positive coefficient, and αk is a positive decay exponent. For each candidate floor below every observed loss in that row, the fit is unweighted least squares in natural-log space:
log(Lk,i−Ek)=ak+bklogDk,i.Index i identifies an observation; Dk,i and Lk,i are its size and loss. The fitted intercept is ak=logAk and slope is bk=−αk. Among fits with positive finite coefficient and exponent, select the smallest root mean squared error on the original loss scale, keeping the first candidate on ties. The mixture with the lowest prediction at target_size wins; ties favor the earlier mixture.
Return a Python dictionary with fits, a mixture-ordered list of dictionaries containing name (string) and floor, coefficient, exponent, rmse (Python floats); target_predictions, a float64 PyTorch tensor of shape (number of mixtures,) on the input device; winning_mixture, its name; and winning_index, its zero-based Python integer index.
Input: mixture_names = ["balanced","code"], data_sizes = [[1,4,16],[1,4,16]], losses = [[5,3,2],[6.5,3.5,2]], target_size = 64, floor_candidates = [0.5,1]
Output: {"fits":[{"name":"balanced","floor":1,"coefficient":4,"exponent":0.5,"rmse":0},{"name":"code","floor":0.5,"coefficient":6,"exponent":0.5,"rmse":0}],"target_predictions":[1.5,1.25],"winning_mixture":"code","winning_index":1}
Explanation: The code mixture begins with higher observed loss but its fitted curve extrapolates below the balanced curve at size 64.
Input: mixture_names = ["first","second"], data_sizes = [[1,4,16],[1,4,16]], losses = [[3,2,1.5],[3,2,1.5]], target_size = 64, floor_candidates = [1]
Output: {"fits":[{"name":"first","floor":1,"coefficient":2,"exponent":0.5,"rmse":0},{"name":"second","floor":1,"coefficient":2,"exponent":0.5,"rmse":0}],"target_predictions":[1.25,1.25],"winning_mixture":"first","winning_index":0}
Input: mixture_names = ["web","books","code"], data_sizes = [[1,4,16],[1,4,16],[1,4,16]], losses = [[4,2.5,1.75],[5,3,2],[3,1.75,1.125]], target_size = 64, floor_candidates = [0.5,1]
Output: {"fits":[{"name":"web","floor":1,"coefficient":3,"exponent":0.5,"rmse":0},{"name":"books","floor":1,"coefficient":4,"exponent":0.5,"rmse":0},{"name":"code","floor":0.5,"coefficient":2.5,"exponent":0.5,"rmse":0}],"target_predictions":[1.375,1.5,0.8125],"winning_mixture":"code","winning_index":2}
torch.linalg.lstsq solves a least-squares system.
torch.argmin returns the first index when minimum values tie.
enumerate keeps each mixture name aligned with its tensor row.
Accepts: array
Accepts: array
Accepts: array
Accepts: number
Accepts: array