Improving LLM Final Representations with Inter-Layer Geometry

Tom Ulanovski, Eyal Blyachman, Maya Bechler-SpeicherNeurIPS 2026

TL;DR

When using a frozen Large Language Model (LLM) as a feature extractor, we almost always grab the output from the very last layer and ignore everything beneath it. This paper shows that connecting all internal layers into a mathematical network—specifically, a sparse, symmetric structure called a Cayley graph—and running a tiny Graph Neural Network over them unlocks massive accuracy gains (up to 48 percentage points!). Even wilder: keeping the LLM completely frozen and just reading its internal layers this way beats fine-tuning the model with LoRA.

What Problem Does This Paper Address?

Think of an LLM as an assembly line of depth. Lower layers tend to process surface-level and lexical features, middle layers handle syntax, and upper layers build abstract semantics. Yet, standard practice for downstream prediction tasks is to throw away the intermediate steps and feed only the final layer’s representation into a classifier.

Researchers know intermediate layers hold valuable, task-specific signals that sometimes get lost by the end. Existing workarounds either exhaustively test every layer to find the "best" one per task, or slap heavy attention mechanisms on top (which still anchor heavily to the final layer). Modifying the transformer architecture itself works too, but requires pre-training from scratch. The authors ask: how can we cheaply, symmetrically, and effectively combine signals from all layers of a frozen LLM?

Methods

The authors reframe inter-layer aggregation as a graph learning problem.

First, they use standard mean-pooling over tokens at each layer of a frozen LLM, giving every layer a single fixed-size vector. Next comes the novel part: treating each layer's vector as a node in a graph and passing messages between them using a lightweight Graph Neural Network (GNN, specifically GCN or GIN) before pooling them into one final representation.

Figure 1: An overview of Cayley-Encoder. Layer representations are mapped into nodes in a Cayley Graph over the Special Linear group SL(2, Zn), which is then fed into a GNN to learn the final inter-layer representation.

They test two graph geometries:

  1. Fully-Connected Encoder (FC-Encoder): Every layer talks directly to every other layer. Simple, dense, and surprisingly effective, though memory-heavy if scaled up.
  2. Cayley-Encoder: Instead of an all-to-all connection, layers are mapped randomly to nodes in a Cayley graph (specifically, over the Special Linear group $SL(2, \mathbb{Z}_n)$). Borrowed from group theory, this creates a 4-regular expander graph—meaning every node has exactly 4 connections, the graph is sparse, symmetric, and has a tiny "diameter" so any two layers can communicate in just a few hops without information bottlenecks (over-squashing) or GNN overfitting. If the fixed mathematical graph has more nodes than the LLM has layers, extra "virtual nodes" initialized with zeros pad the structure to keep the geometry intact.

Datasets

The authors use 13 established datasets from the MTEB benchmark (no new benchmarks are introduced):

  • 5 Classification Tasks: Banking77 (intent), Emotion, MTOPDomain, MTOPIntent (dialogue), and Poem Sentiment.
  • 8 Semantic Textual Similarity (STS) Tasks: Trained on STSBenchmark, with zero-shot transfer evaluated on STS12–16, BIOSSES, and SICK-R.

These are tested across 13 frozen LLMs spanning four model families: Pythia (7 sizes from 14M to 2.8B), Gemma2-2B, Llama3-8B, and Qwen3 (4 sizes from 1.7B to 14B).

Key Insights and Ideas

  • The exact order of layers doesn't matter—communication does: In a fascinating set of ablations, randomly shuffling which LLM layer maps to which node in the Cayley graph barely changes accuracy (variance < 2%). Furthermore, explicitly giving the GNN positional encodings so it knows which depth a signal came from actually hurts performance! What matters isn't privileging specific layers, but giving all layers a clean, symmetric communication channel.
  • Every layer pitches in: Using GNNExplainer to inspect trained models reveals that predictions don't collapse onto one "magic" layer; instead, all layers across the LLM's depth contribute roughly equally.
  • Better reading beats weight tweaking: Rather than altering the LLM's internal weights via LoRA, simply doing a better job of aggregating the representations the frozen LLM already computes yields stronger results with a fraction of the parameters.
  • Tiny models punch way above their weight: Equipped with these encoders, tiny models like Pythia-14M achieve 95–96% on MTOPDomain—just shy of a model 200x its size.
Performance across Pythia model sizes from 14M to 2.8B parameters across five classification tasks.

Key Results

  • Massive Accuracy Gains: Across classification tasks, Cayley-Encoder beats standard Last-Layer extraction by an average of 33 percentage points (and up to 48 percentage points on Emotion and Poem Sentiment) and beats picking the single Best-Layer by 25 points, while adding at most 0.1% parameters relative to the base LLM.
  • Beats Attention & LoRA: Cayley-Encoder outperforms Depth-Wise Attention (DWAtt) on all 13 tasks using 3–5x fewer parameters. Against LoRA (rank 16), Cayley-Encoder wins in 21 of 24 STS setups, and at least one GNN encoder beats LoRA in 13 of 15 classification setups—using 6–12x fewer trainable parameters.
  • Data & Memory Efficiency: In few-shot tests, just 8 samples per label is often enough to beat full-dataset baselines. When scaled up to token-level graphs (one node per token per layer), FC-Encoder runs out of memory, while the sparse Cayley-Encoder uses 12–34x less GPU memory and pushes Gemma2-2B's Emotion accuracy from 69.6% to 89.7%.

Limitations and Future Work

The current study focuses on discriminative tasks (classification and similarity) on models up to 14B parameters. Scaling this approach to massive 70B+ architectures and adapting it for generative tasks (next-token prediction) remain open challenges. Finally, because post-training inter-layer communication works so well on frozen models, the authors suggest a natural next step: baking Cayley-style inter-layer geometry directly into LLM pre-training to improve how information flows across depth from day one.

Summary updated

Abstract

The standard in LLM-based prediction is to use the final-layer representation as the input to a downstream predictor. However, intermediate layers may encode complementary task-relevant signals. Existing approaches therefore either search for the best layer for each task or apply expensive attention-based mechanisms to learn inter-layer aggregation. In this work, we first show that such complexity is unnecessary: a lightweight Graph Neural Network over a fully connected graph of LLM layers is more efficient and achieves significantly stronger predictive performance than existing approaches. We then introduce the Cayley-Encoder, which further improves both efficiency and predictive performance by replacing the fully connected graph with a Cayley graph over $SL(2,\mathbb{Z}_n)$. These Cayley graphs provide a mathematically grounded topology that is sparse, regular by construction, and has low diameter. This enables effective communication across layers while constraining the aggregation structure and reducing the risk of GNN overfitting. In an evaluation of Cayley-Encoder across 13 tasks and 13 LLMs, Cayley-Encoder consistently outperforms baselines, achieving improvements of up to 48 percentage points in accuracy, while introducing at most 0.1\% additional parameters relative to the LLM size. We further show that Cayley-Encoder is effective in few-shot regimes. Finally, we show that Cayley-Encoder outperforms LoRA fine-tuning while operating on the frozen LLM. We conclude with an explainability analysis showing that multiple layers contribute meaningfully to the final prediction, supporting our hypothesis.
BibTeX
@inproceedings{ulanovski2026improving,
  author = {Tom Ulanovski and Eyal Blyachman and Maya Bechler-Speicher},
  title = {{Improving LLM Final Representations with Inter-Layer Geometry}},
  booktitle = {Advances in Neural Information Processing Systems},
  year = {2026},
  url = {https://openreview.net/forum?id=gUPzBRGNCS},
}
Figure