Large Language Models (LLMs) have rapidly become central to NLP, demonstrating their ability to adapt to various tasks through prompting techniques, including sentiment analysis. However, we still have a limited understanding of how these models capture sentiment-related information. This study probes the hidden layers of LLaMA models to pinpoint where sentiment features are most represented and to assess how this affects sentiment analysis.Using probe classifiers, we analyze sentiment encoding across layers and scales, identifying the layers and pooling methods that best capture sentiment signals. Our results show that sentiment information is most concentrated in mid-layers for binary polarity tasks, with detection accuracy increasing up to 14% over prompting techniques. Additionally, we find that in decoder-only models, the last token is not consistently the most informative for sentiment encoding. Finally, this approach enables sentiment tasks to be performed with memory requirements reduced by an average of 57%.These insights contribute to a broader understanding of sentiment in LLMs, suggesting layer-specific probing as an effective approach for sentiment tasks beyond prompting, with potential to enhance model utility and reduce memory requirements.

LLaMAs Have Feelings Too: Unveiling Sentiment and Emotion Representations in LLaMA Models Through Probing / Di Palma, Dario; De Bellis, Alessandro; Servedio, Giovanni; Anelli, Vito Walter; Narducci, Fedelucio; Di Noia, Tommaso. - ELETTRONICO. - (2025), pp. 6124-6142. ( 63rd Annual Meeting of the Association for Computational Linguistics Vienna, Austria July 27 - August 1, 2025) [10.18653/v1/2025.acl-long.306].

LLaMAs Have Feelings Too: Unveiling Sentiment and Emotion Representations in LLaMA Models Through Probing

Di Palma Dario;De Bellis Alessandro;Servedio Giovanni;Anelli Vito Walter;Narducci Fedelucio;Di Noia Tommaso
2025

Abstract

Large Language Models (LLMs) have rapidly become central to NLP, demonstrating their ability to adapt to various tasks through prompting techniques, including sentiment analysis. However, we still have a limited understanding of how these models capture sentiment-related information. This study probes the hidden layers of LLaMA models to pinpoint where sentiment features are most represented and to assess how this affects sentiment analysis.Using probe classifiers, we analyze sentiment encoding across layers and scales, identifying the layers and pooling methods that best capture sentiment signals. Our results show that sentiment information is most concentrated in mid-layers for binary polarity tasks, with detection accuracy increasing up to 14% over prompting techniques. Additionally, we find that in decoder-only models, the last token is not consistently the most informative for sentiment encoding. Finally, this approach enables sentiment tasks to be performed with memory requirements reduced by an average of 57%.These insights contribute to a broader understanding of sentiment in LLMs, suggesting layer-specific probing as an effective approach for sentiment tasks beyond prompting, with potential to enhance model utility and reduce memory requirements.
2025
63rd Annual Meeting of the Association for Computational Linguistics
979-8-89176-251-0
LLaMAs Have Feelings Too: Unveiling Sentiment and Emotion Representations in LLaMA Models Through Probing / Di Palma, Dario; De Bellis, Alessandro; Servedio, Giovanni; Anelli, Vito Walter; Narducci, Fedelucio; Di Noia, Tommaso. - ELETTRONICO. - (2025), pp. 6124-6142. ( 63rd Annual Meeting of the Association for Computational Linguistics Vienna, Austria July 27 - August 1, 2025) [10.18653/v1/2025.acl-long.306].
File in questo prodotto:
File Dimensione Formato  
2025_LLaMAs_Have_Feelings_Too_pdfeditoriale.pdf

accesso aperto

Tipologia: Versione editoriale
Licenza: Creative commons
Dimensione 1.02 MB
Formato Adobe PDF
1.02 MB Adobe PDF Visualizza/Apri

I documenti in IRIS sono protetti da copyright e tutti i diritti sono riservati, salvo diversa indicazione.

Utilizza questo identificativo per citare o creare un link a questo documento: https://hdl.handle.net/11589/291861
Citazioni
  • Scopus 0
  • ???jsp.display-item.citation.isi??? 0
social impact