in rbr_weight_fitter.py [0:0]
def __init__(self,
feature_names: List[str],
examples: List[RBR_ExampleWithMetadata],
orderings: Dict[str, List[str]],
ignore_features: List[str] = [],
#optimization hyperparameters
train_data_frac: float = 0.95,
margin: float = 1,
lr: float = 1e-2,
wd: float = 0.0,
n_iters: int = 1000,
completion_label_margin: Dict[str, float] = {}):
"""
Optimize a linear function for combining the RBR with the Reward Model by optimizing the hinge loss.
Args:
feature_names (list[str]): the list of feature names
examples (list[RBR_ExampleWithMetadata]): the list of examples to optimize on
orderings (dict[str, list[str]]): a dict of str -> list[str] where an example whose label is a key is considered better than any example whose label is in the corresponding values.
ignore_features (list[str]): the list of features to ignore
train_data_frac (float): the fraction of data to use for training
margin (float): the margin for the hinge loss
lr (float): the learning rate for the optimizer
wd (float): the weight decay for the optimizer
n_iters (int): the number of iterations to run the optimizer
completion_label_margin (dict[str, float]): Pass in specific margins for completion labels to override the default margin. (ex may want to set a higher margin for "ideal" completions)
"""
self.feature_names = feature_names
self.examples = examples
self.orderings = orderings
self.ignore_features = ignore_features
self.train_data_frac = train_data_frac
self.margin = margin
self.lr = lr
self.wd = wd
self.n_iters = n_iters
self.completion_label_margin = completion_label_margin
self.weights = torch.zeros(len(feature_names), requires_grad=True)
self.metrics = {"frac_clipped": [], "loss": [], "valid_loss": []}