journal article·2026-04-27Open access

Layer-Wise Attention with Pivot Layers for Effective Fine-Tuning of Encoder-Based Language Models

Seung-Dong Lee, Jun-Ha Hwang, Miseo Kim, Young-Seob Jeong

Applied Sciences· Volume 16· Issue 9

Abstract

Fine-tuning pre-trained encoder-based language models for down-stream tasks is typically performed by exploiting the output of the last encoder layer. However, an alternative line of research suggests that leveraging representations from multiple encoder layers may yield richer linguistic information. Previous studies found that different layers convey different linguistic knowledge, suggesting that the last layer might not be optimal for all down-stream tasks. In this paper, we propose a layer-wise attention mechanism using a pivot layer as a new fine-tuning method. The pivot layer is used to compute attention scores of encoder layers, and we define three types of pivot layers. We also examine four attention functions and demonstrate through experiments that the attention function plays an important role in layer-wise attention for fine-tuning. The best-performing combination of our proposed mechanism outperformed the standard fine-tuning method and other recent methods in the General Language Understanding Evaluation (GLUE) benchmark. By visualizing the attention distributions, we found that the last layer is not always preferable for every GLUE benchmark task, and that differences in attention distribution are associated with task performance.
Source: crossref · Quality: baseline

Research context

OpenAlex topics: Multimodal Machine Learning Applications · Text Readability and Simplification · Natural Language Processing Techniques

SciVX discovery tags are terminology-based. OpenAlex topics are source-provided classifications.

Affiliations

FS Co., Ltd., 151 Gyejok-ro, Dong-gu, Daejeon 34640, Republic of Korea

Department of Computer Engineering, Chungbuk National University, Cheongju-si 28644, Republic of Korea

Funding

Ministry of Education

References (47)

Show source-provided references
1. Attention is all you need
2. Devlin, J., Chang, M.W., Lee, K., and Toutanova, K. (2019, January 2–7). BERT: Pre-training of Deep Bidirectional Transformers for Language Understanding. Proceedings of the 2019 Conference of the North American Chapter of the Association for Computational Linguistics: Human Language Technologies, Volume 1 (Long and Short Papers), Minneapolis, MN, USA.
3. Radford, A., Narasimhan, K., Salimans, T., and Sutskever, I. (2026, April 20). Improving Language Understanding by Generative Pre-Training. Available online: https://www.mikecaptain.com/resources/pdf/GPT-1.pdf.
4. Training language models to follow instructions with human feedback
5. Yang, Z., Li, L., Lin, K., Wang, J., Lin, C.C., Liu, Z., and Wang, L. (2023). The dawn of lmms: Preliminary explorations with gpt-4v (ision). arXiv.
6. Touvron, H., Lavril, T., Izacard, G., Martinet, X., Lachaux, M.A., Lacroix, T., Rozière, B., Goyal, N., Hambro, E., and Azhar, F. (2023). Llama: Open and efficient foundation language models. arXiv.
7. Touvron, H., Martin, L., Stone, K., Albert, P., Almahairi, A., Babaei, Y., Bashlykov, N., Batra, S., Bhargava, P., and Bhosale, S. (2023). Llama 2: Open foundation and fine-tuned chat models. arXiv.
8. Liu, Y., Ott, M., Goyal, N., Du, J., Joshi, M., Chen, D., Levy, O., Lewis, M., Zettlemoyer, L., and Stoyanov, V. (2019). Roberta: A robustly optimized bert pretraining approach. arXiv.
9. He, P., Liu, X., Gao, J., and Chen, W. (2020). Deberta: Decoding-enhanced bert with disentangled attention. arXiv.
10. A Survey on Deep Learning for Named Entity Recognition10.1109/TKDE.2020.2981314 ↗
11. Munikar, M., Shakya, S., and Shrestha, A. (2019, January 5). Fine-grained Sentiment Classification using BERT. Proceedings of the 2019 Artificial Intelligence for Transforming Business and Society (AITB), Kathmandu, Nepal.10.1109/AITB48515.2019.8947435 ↗
12. Lee, J. (2022, January 18–22). The Emotion is Not One-hot Encoding: Learning with Grayscale Label for Emotion Recognition in Conversation. Proceedings of the Interspeech 2022, Incheon, Republic of Korea.10.21437/Interspeech.2022-551 ↗
13. Jawahar, G., Sagot, B., and Seddah, D. (August, January 28). What does BERT learn about the structure of language?. Proceedings of the ACL 2019—57th Annual Meeting of the Association for Computational Linguistics, Florence, Italy.10.18653/v1/P19-1356 ↗
14. Sajjad, H., Durrani, N., Dalvi, F., Alam, F., Khan, A., and Xu, J. (2022, January 10–15). Analyzing Encoded Concepts in Transformer Language Models. Proceedings of the 2022 Conference of the North American Chapter of the Association for Computational Linguistics: Human Language Technologies, Seattle, WA, USA.10.18653/v1/2022.naacl-main.225 ↗
15. A Primer in BERTology: What We Know About How BERT Works10.1162/tacl_a_00349 ↗
16. Wang, A., Singh, A., Michael, J., Hill, F., Levy, O., and Bowman, S. (November, January 31). GLUE: A Multi-Task Benchmark and Analysis Platform for Natural Language Understanding. Proceedings of the 2018 EMNLP Workshop BlackboxNLP: Analyzing and Interpreting Neural Networks for NLP, Brussels, Belgium.10.18653/v1/W18-5446 ↗
17. Exploring the limits of transfer learning with a unified text-to-text transformer
18. Jurafsky, D., Chai, J., Schluter, N., and Tetreault, J. (2020). BART: Denoising Sequence-to-Sequence Pre-training for Natural Language Generation, Translation, and Comprehension. Proceedings of the 58th Annual Meeting of the Association for Computational Linguistics, Online, 5–10 July 2020, ACL.
19. Wang, S., Guo, Y., Wang, Y., Sun, H., and Huang, J. (2019, January 7–10). SMILES-BERT: Large Scale Unsupervised Pre-Training for Molecular Property Prediction. Proceedings of the 10th ACM International Conference on Bioinformatics, Computational Biology and Health Informatics, New York, NY, USA.10.1145/3307339.3342186 ↗
20. Zhao, L., Li, L., Zheng, X., and Zhang, J. (2021). A BERT based Sentiment Analysis and Key Entity Detection Approach for Online Financial Texts. Proceedings of the 2021 IEEE 24th International Conference on Computer Supported Cooperative Work in Design (CSCWD), IEEE.10.1109/CSCWD49262.2021.9437616 ↗
21. Clark, K., Khandelwal, U., Levy, O., and Manning, C.D. (2019, January 1). What Does BERT Look at? An Analysis of BERT’s Attention. Proceedings of the 2019 ACL Workshop BlackboxNLP: Analyzing and Interpreting Neural Networks for NLP, Florence, Italy.10.18653/v1/W19-4828 ↗
22. Prottasha, N.J., Sami, A.A., Kowsher, M., Murad, S.A., Bairagi, A.K., Masud, M., and Baz, M. (2022). Transfer learning for sentiment analysis using BERT based supervised fine-tuning. Sensors, 22.10.3390/s22114157 ↗
23. Oh, D., Kim, Y., Lee, H., Huang, H.H., and Lim, H. (2022, January 12–17). Don’t Judge a Language Model by Its Last Layer: Contrastive Learning with Layer-Wise Attention Pooling. Proceedings of the 29th International Conference on Computational Linguistics, Gyeongju, Republic of Korea.
24. Hu, E.J., Shen, Y., Wallis, P., Allen-Zhu, Z., Li, Y., Wang, S., Wang, L., and Chen, W. (2022, January 25–29). LoRA: Low-Rank Adaptation of Large Language Models. Proceedings of the International Conference on Learning Representations, Virtual.
25. Houlsby, N., Giurgiu, A., Jastrzebski, S., Morrone, B., De Laroussilhe, Q., Gesmundo, A., Attariyan, M., and Gelly, S. (2019, January 9–15). Parameter-Efficient Transfer Learning for NLP. Proceedings of the International Conference on Machine Learning, Long Beach, CA, USA.
26. Li, X.L., and Liang, P. (2021, January 1–6). Prefix-Tuning: Optimizing Continuous Prompts for Generation. Proceedings of the 59th Annual Meeting of the Association for Computational Linguistics, Online.10.18653/v1/2021.acl-long.353 ↗
27. Zong, C., Xia, F., Li, W., and Navigli, R. (2021). LV-BERT: Exploiting Layer Variety for BERT. Proceedings of the Findings of the Association for Computational Linguistics: ACL-IJCNLP 2021, Online, 1–6 August 2021, ACL.
28. Luong, T., Pham, H., and Manning, C.D. (2015, January 17–21). Effective Approaches to Attention-based Neural Machine Translation. Proceedings of the 2015 Conference on Empirical Methods in Natural Language Processing, Lisbon, Portugal.10.18653/v1/D15-1166 ↗
29. Graves, A., Wayne, G., and Danihelka, I. (2014). Neural turing machines. arXiv.
30. Glorot, X., and Bengio, Y. (2010, January 13–15). Understanding the difficulty of training deep feedforward neural networks. Proceedings of the Thirteenth International Conference on Artificial Intelligence and Statistics, Sardinia, Italy.
31. Warstadt, A., Singh, A., and Bowman, S.R. (2018). Neural Network Acceptability Judgments. arXiv.10.1162/tacl_a_00290 ↗
32. Socher, R., Perelygin, A., Wu, J., Chuang, J., Manning, C.D., Ng, A., and Potts, C. (2013, January 18–21). Recursive deep models for semantic compositionality over a sentiment treebank. Proceedings of the EMNLP, Seattle, WA, USA.10.18653/v1/D13-1170 ↗
33. Dolan, W.B., and Brockett, C. (2005, January 14). Automatically constructing a corpus of sentential paraphrases. Proceedings of the International Workshop on Paraphrasing, Jeju Island, Republic of Korea.
34. Agirre, E., M’arquez, L., and Wicentowski, R. (2007). Proceedings of the Fourth International Workshop on Semantic Evaluations (SemEval-2007), Association for Computational Linguistics.
35. Williams, A., Nangia, N., and Bowman, S.R. (2018, January 1–6). A Broad-Coverage Challenge Corpus for Sentence Understanding through Inference. Proceedings of the NAACL-HLT, New Orleans, LA, USA.10.18653/v1/N18-1101 ↗
36. Rajpurkar, P., Zhang, J., Lopyrev, K., and Liang, P. (2016). SQuAD: 100,000+ Questions for Machine Comprehension of Text. Proceedings of the EMNLP, Association for Computational Linguistics.10.18653/v1/D16-1264 ↗
37. Dagan, I., Glickman, O., and Magnini, B. (2006). The PASCAL recognising textual entailment challenge. Machine Learning Challenges. Evaluating Predictive Uncertainty, Visual Object Classification, and Recognising Tectual Entailment, Springer.10.1007/11736790_9 ↗
38. Bar Haim, R., Dagan, I., Dolan, B., Ferro, L., Giampiccolo, D., Magnini, B., and Szpektor, I. (2026, April 20). The Second PASCAL Recognising Textual Entailment Challenge. Available online: https://www.semanticscholar.org/paper/The-Second-PASCAL-Recognising-Textual-Entailment-Bar-Haim-Dagan/136326377c122560768db674e35f5bcd6de3bc40.
39. Giampiccolo, D., Magnini, B., Dagan, I., and Dolan, B. (2007). The third PASCAL recognizing textual entailment challenge. Proceedings of the ACL-PASCAL Workshop on Textual Entailment and Paraphrasing, Association for Computational Linguistics.10.3115/1654536.1654538 ↗
40. The Fifth PASCAL Recognizing Textual Entailment Challenge
41. The Winograd schema challenge
42. Wolf, T., Debut, L., Sanh, V., Chaumond, J., Delangue, C., Moi, A., Cistac, P., Rault, T., Louf, R., and Funtowicz, M. (2020, January 16–20). Transformers: State-of-the-Art Natural Language Processing. Proceedings of the 2020 Conference on Empirical Methods in Natural Language Processing: System Demonstrations, Online.10.18653/v1/2020.emnlp-demos.6 ↗
43. Loshchilov, I., and Hutter, F. (2019, January 6–9). Decoupled Weight Decay Regularization. Proceedings of the International Conference on Learning Representations, New Orleans, LA, USA.
44. Kingma, D.P., and Ba, J. (2014). Adam: A method for stochastic optimization. arXiv.
45. Burstein, J., Doran, C., and Solorio, T. (2019). Linguistic Knowledge and Transferability of Contextual Representations. Proceedings of the 2019 Conference of the North American Chapter of the Association for Computational Linguistics: Human Language Technologies, Volume 1 (Long and Short Papers), Minneapolis, MN, USA, 2–7 June 2019, Association for Computational Linguistics.
46. Convbert: Improving bert with span-based dynamic convolution
47. Efficient Training of BERT by Progressively Stacking