Repository navigation
Replies: 2 comments
|
The short answer: it should make almost no practical difference for this classification fine-tuning setup
The original GPT-2-style language modeling head is So both are reasonable: model.out_head = torch.nn.Linear(768, num_classes) # bias=True, fine
model.out_head = torch.nn.Linear(768, num_classes, bias=False) # also fineIf you want to mirror the book/code style exactly, use |
|
Good question on output layer bias! In practice for LLMs, the output projection usually does use bias (it helps the model learn token frequency offsets). But some architectures like PaLM omit it for parameter efficiency. For more interview-level depth on transformer architecture decisions: ML Interview Prep has a detailed section on LLM internals. Hope it helps anyone studying this book! |
Uh oh!
There was an error while loading. Please reload this page.
In Chapter 6, and also in Appendix E, we replace the GPTModel output layer
'out_head' in order to prepare the model for fine-tuning, changing the
out_features from 50257 to 2 (num_classes), as shown below:
num_classes = 2 model.out_head = torch.nn.Linear(in_features=768, out_features=num_classes)In running this code, I did a print(model) before, and then after the
change and I noticed that the 'bias' changed from 'False' to 'True'.
before the change:
(out_head): Linear(in_features=768, out_features=50257, bias=False)after the change:
(out_head): Linear(in_features=768, out_features=2, bias=True)My question is: does 'bias' matter in the out_head? And if so, should
the code in Chapter 6 and Appendix E have been:
num_classes = 2 model.out_head = torch.nn.Linear(in_features=768, out_features=num_classes, bias=False)Thanks for any insights
All reactions