Hostname: page-component-74656f9884-8r8nv Total loading time: 0 Render date: 2026-11-07T22:25:32.319Z Has data issue: false hasContentIssue false

On Finetuning Large Language Models

Published online by Cambridge University Press:  28 November 2023

Yu Wang*
Affiliation:
Fudan Institute for Advanced Study in Social Sciences, Fudan University, Shanghai, China
Rights & Permissions [Opens in a new window]

Abstract

A recent paper by Häffner et al. (2023, Political Analysis 31, 481–499) introduces an interpretable deep learning approach for domain-specific dictionary creation, where it is claimed that the dictionary-based approach outperforms finetuned language models in predictive accuracy while retaining interpretability. We show that the dictionary-based approach’s reported superiority over large language models, BERT specifically, is due to the fact that most of the parameters in the language models are excluded from finetuning. In this letter, we first discuss the architecture of BERT models, then explain the limitations of finetuning only the top classification layer, and lastly we report results where finetuned language models outperform the newly proposed dictionary-based approach by 27% in terms of $R^2$ and 46% in terms of mean squared error once we allow these parameters to learn during finetuning. Researchers interested in large language models, text classification, and text regression should find our results useful. Our code and data are publicly available.

Information

Type
Letter
Copyright
© The Author(s), 2023. Published by Cambridge University Press on behalf of The Society for Political Methodology
Figure 0

Figure 1 Illustration of the BERT model’s architecture. Numbers are based on Häffner et al. (2023) and Hu et al. (2022). Code for calculating the number of parameters is included in the replication package. Diagram is not drawn to proportion.

Figure 1

Table 1 Metrics comparison between finetuning only the classification layer and finetuning the entire model. Due to space limit, we only report the first 5,000 steps. Interested readers could find all the training steps in the replication package.

Figure 2

Table 2 By making all parameters learnable, finetuned BERT models outperform dictionary-based models by a large margin. Results in columns 1–3 are from Table 2 in Häffner et al. (2023). By increasing the maximum sequence length to 512, we are able to further improve the performance of those finetuned models. Best results in bold.

Supplementary material: PDF

Wang supplementary material

Appendix

Download Wang supplementary material(PDF)
PDF 194.7 KB
Supplementary material: Link
Link