def lmloss(inputs: list[int], params) -> float: the labels y are just the input shifted…
- User
def lm_loss(inputs: list[int], params) -> float: # the labels y are just the input shifted 1 to the left # # inputs = [not, all, heros, wear, capes] # x = [not, all, heroes, wear] # y = [all, heroes, wear, capes] # # of course, we don't have a label for inputs[-1], so we exclude it from x # # as such, for N inputs, we have N - 1 langauge modeling example pairs x, y = inputs[:-1], inputs[1:] # both have shape [num_tokens_in_seq - 1]
# forward pass # all the predicted next token probability distributions at each position output = gpt(x, params) # has shape [num_tokens_in_seq - 1, num_tokens_in_vocab] # cross entropy loss # we take the average over all N-1 examples loss = np.mean(-np.log(output[np.arange(len(output)), y])) return lossExplain this what is happening here ?
Assistant
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.