An output layer converts a model’s final hidden representations into task-specific prediction scores. In GPT classification fine-tuning, replace the vocabulary-sized layer with a linear layer whose outputs match the class count. section 6.5
A classification output layer follows this data flow:
- The GPT model produces 768-dimensional representations through transformer blocks and final normalization. section 6.5
- A linear layer maps each representation from 768 units to two class scores for spam and not spam; a three-class task uses three outputs. section 6.5
Replacing the GPT output layer
Set num_classes = 2 and assign torch.nn.Linear(in_features=BASE_CONFIG["emb_dim"], out_features=num_classes) to model.out_head. The resulting final-token scores are tensor([[-3.5983, 3.9902]].
