We analyze internal representations of large language models with zigzag persistent homology, treating depth as a discrete time axis for point clouds of last-token embeddings. At each layer we build a k-nearest-neighbors clique complex, connect adjacent layers via intersections, and summarize the resulting diagrams with effective persistence images. From these we derive two descriptors: Births’ Relative Frequency (at what rate new p-dimensional features appear) and Inter-Layer Persistence (how long they survive across depth). On the SST movie reviews dataset and three open-source models (Llama-3.1, OSS-20B, Phi-4), we consistently observe three evolving phases: early rapid changes, a middle regime of stable organization, and a final reorganization before output. Using the stability signal (inter-layer persistence) to guide where to remove contiguous blocks of layers, we find that pruning within high-persistence regions maintains 5-shot MMLU performance (with the same trend visible even for the more pruning-sensitive OSS-20B). This suggests that zigzag-based summaries capture meaningful, system-level dynamics and can inform lightweight pruning.

Zigzag Persistence of Large Language Models Representations / Gardinazzi, Y., Viswanathan, K., Panerai, G., Ansuini, A., Cazzaniga, A., Biagetti, M.. - (2026), pp. 120-129. (Geometry, Topology, and Machine Learning Leipzig 10-14 November 2025).

Zigzag Persistence of Large Language Models Representations

Yuri Gardinazzi
Primo
Membro del Collaboration Group
;
Alberto Cazzaniga
Membro del Collaboration Group
;
2026-01-01

Abstract

We analyze internal representations of large language models with zigzag persistent homology, treating depth as a discrete time axis for point clouds of last-token embeddings. At each layer we build a k-nearest-neighbors clique complex, connect adjacent layers via intersections, and summarize the resulting diagrams with effective persistence images. From these we derive two descriptors: Births’ Relative Frequency (at what rate new p-dimensional features appear) and Inter-Layer Persistence (how long they survive across depth). On the SST movie reviews dataset and three open-source models (Llama-3.1, OSS-20B, Phi-4), we consistently observe three evolving phases: early rapid changes, a middle regime of stable organization, and a final reorganization before output. Using the stability signal (inter-layer persistence) to guide where to remove contiguous blocks of layers, we find that pruning within high-persistence regions maintains 5-shot MMLU performance (with the same trend visible even for the more pruning-sensitive OSS-20B). This suggests that zigzag-based summaries capture meaningful, system-level dynamics and can inform lightweight pruning.
File in questo prodotto:
Non ci sono file associati a questo prodotto.
Pubblicazioni consigliate

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/11368/3150902
 Avviso

Attenzione! I dati visualizzati non sono stati sottoposti a validazione da parte dell'ateneo

Citazioni
  • ???jsp.display-item.citation.pmc??? ND
  • Scopus ND
  • ???jsp.display-item.citation.isi??? ND
social impact