After pre-training, GPT-1 is adapted to a labelled task by adding one linear layer on the final activation of the last input token. While fine-tuning it keeps predicting the input's own tokens as a second, auxiliary objective, weighted by (the paper uses ). Compute the three objectives for a batch.
Implement fine_tune_objective(examples, W_y, W_e, lam=0.5).
examples: a list of dicts with "tokens" (the input token ids , already transformed with start and extract tokens), "h" (the pre-trained model's final-block activations, an array, row for token ) and "label" (an int).W_y: the added output layer, shape (d, K). W_e: the token embedding, shape (V, d); the language-model output layer is tied to it, .With the last row of h:
predicts every token after the first from the activation of the token before it.
Return a dict with "L1", "L2", "L3" (natural-log log-likelihoods, rounded to 4 decimals) and "predictions": for each example, the class with the highest probability (the lowest index on ties).
ValueError if an example's h does not have one row per token.