Table of Contents
Fetching ...

Analyzing Narrative Processing in Large Language Models (LLMs): Using GPT4 to test BERT

Patrick Krauss, Jannik Hösch, Claus Metzner, Andreas Maier, Peter Uhrig, Achim Schilling

TL;DR

This study uses GPT-4 to generate seven stylistic variants of ten fables and analyzes BERT CLS-token activations across 12 transformer blocks using MDS and label-free clustering metrics (GDV and EDD). It finds that writing style clusters are strongest in early layers (block 1) while semantic content clustering emerges in mid-layers (blocks 4-5), with later layers integrating both properties. The results support layer-wise specialization in transformer architectures and offer a Cognitive Computational Neuroscience framework for probing LLM internals without task-specific probes, linking model dynamics to human language processing. Overall, the work provides a principled method to open the LLM black box and compare internal representations to brain-based language processing.

Abstract

The ability to transmit and receive complex information via language is unique to humans and is the basis of traditions, culture and versatile social interactions. Through the disruptive introduction of transformer based large language models (LLMs) humans are not the only entity to "understand" and produce language any more. In the present study, we have performed the first steps to use LLMs as a model to understand fundamental mechanisms of language processing in neural networks, in order to make predictions and generate hypotheses on how the human brain does language processing. Thus, we have used ChatGPT to generate seven different stylistic variations of ten different narratives (Aesop's fables). We used these stories as input for the open source LLM BERT and have analyzed the activation patterns of the hidden units of BERT using multi-dimensional scaling and cluster analysis. We found that the activation vectors of the hidden units cluster according to stylistic variations in earlier layers of BERT (1) than narrative content (4-5). Despite the fact that BERT consists of 12 identical building blocks that are stacked and trained on large text corpora, the different layers perform different tasks. This is a very useful model of the human brain, where self-similar structures, i.e. different areas of the cerebral cortex, can have different functions and are therefore well suited to processing language in a very efficient way. The proposed approach has the potential to open the black box of LLMs on the one hand, and might be a further step to unravel the neural processes underlying human language processing and cognition in general.

Analyzing Narrative Processing in Large Language Models (LLMs): Using GPT4 to test BERT

TL;DR

This study uses GPT-4 to generate seven stylistic variants of ten fables and analyzes BERT CLS-token activations across 12 transformer blocks using MDS and label-free clustering metrics (GDV and EDD). It finds that writing style clusters are strongest in early layers (block 1) while semantic content clustering emerges in mid-layers (blocks 4-5), with later layers integrating both properties. The results support layer-wise specialization in transformer architectures and offer a Cognitive Computational Neuroscience framework for probing LLM internals without task-specific probes, linking model dynamics to human language processing. Overall, the work provides a principled method to open the LLM black box and compare internal representations to brain-based language processing.

Abstract

The ability to transmit and receive complex information via language is unique to humans and is the basis of traditions, culture and versatile social interactions. Through the disruptive introduction of transformer based large language models (LLMs) humans are not the only entity to "understand" and produce language any more. In the present study, we have performed the first steps to use LLMs as a model to understand fundamental mechanisms of language processing in neural networks, in order to make predictions and generate hypotheses on how the human brain does language processing. Thus, we have used ChatGPT to generate seven different stylistic variations of ten different narratives (Aesop's fables). We used these stories as input for the open source LLM BERT and have analyzed the activation patterns of the hidden units of BERT using multi-dimensional scaling and cluster analysis. We found that the activation vectors of the hidden units cluster according to stylistic variations in earlier layers of BERT (1) than narrative content (4-5). Despite the fact that BERT consists of 12 identical building blocks that are stacked and trained on large text corpora, the different layers perform different tasks. This is a very useful model of the human brain, where self-similar structures, i.e. different areas of the cerebral cortex, can have different functions and are therefore well suited to processing language in a very efficient way. The proposed approach has the potential to open the black box of LLMs on the one hand, and might be a further step to unravel the neural processes underlying human language processing and cognition in general.
Paper Structure (1 section, 4 figures, 1 table)

This paper contains 1 section, 4 figures, 1 table.

Figures (4)

  • Figure 1: Label-free measure of cluster formation The EDD value shows that the cluster formation of the CLS token across the layers is minimal (no clear cluster evolve). The used CLS tokens (2D projections) are shown in Fig. \ref{['fig:scatter-semantic']} and Fig. \ref{['fig:scatter-style']}. Note that the labels (colors of the markers) play no role for the EDD value (see metzner2023beyond).
  • Figure 2: 2D projections of CLS token through all transformer blocks colored according to the narrative The plot shows the 2D projections of the CLS token of the 12 transformer blocks (block 1-12) projected with the MDS method. The colors correspond to the different narratives (fables). The numbers in the legend correspond to the numbers in Table \ref{['tab:inputdata']} 2nd column.
  • Figure 3: 2D projections of CLS token through all transformer blocks colored according to writing style The plot shows the MDS-projected CLS tokens of the 12 transformer blocks analogously to Fig \ref{['fig:scatter-semantic']}. The colors of the markers represent the different writing styles (see Table \ref{['tab:inputdata']} column 3 and 4 to find the according writing style of the numbers in the legend of the plot).
  • Figure 4: GDV as a function of the layer resp. transformer block a-c: Shows the center of mass and the standard deviation of the CLS token along the principal axis plotted as colored ellipses for exemplary narratives and layers 1, 4, and 12. d: GDV as a function of the transformer block (layer). The CLS token vectors separate best (minimum of the GDV) according to the content of the story in block 4, 5. e-g: Same as a-c but for 5 exemplary writing styles; h: The GDV as a function of the writing style. The CLS vectors separate best (minimum of GDV) according to the writing style in block 1. The fact that the minimum of the GDV lies in different layers for different styles and different narratives illustrates that different layers of the transformer process language differently and are specialized on certain properties of language.