Large Language Models Encode Semantics in Low-Dimensional Linear Subspaces

Baturay Saglam, Paul Kassianik, Blaine Nelson, Sajana Weerawardhena, Yaron Singer +1 more
7/13/2025
cs.CLcs.LG

No confident code implementation found for this paper. 2 possible matches can be shown below.

Abstract

Understanding the latent space geometry of large language models (LLMs) is key to interpreting their behavior and improving alignment. However, it remains unclear to what extent LLMs internally organize representations related to semantic understanding. To explore this, we conduct a large-scale empirical study of hidden representations in 11 autoregressive models across 6 scientific topics. We find that high-level semantic information consistently resides in low-dimensional subspaces that form linearly separable representations across domains. This separability becomes more pronounced in deeper layers and under prompts that elicit structured reasoning or alignment behavior$\unicode{x2013}$even when surface content remains unchanged. These findings support geometry-aware tools that operate directly in latent space to detect and mitigate harmful or adversarial content. As a proof of concept, we train an MLP probe on final-layer hidden states to act as a lightweight latent-space guardrail. This approach substantially improves refusal rates on malicious queries and prompt injections that bypass both the model's built-in safety alignment and external token-level filters.

View on arXivView PDF

Code Implementations

No confident code match yet

We couldn't find an author-owned or strongly-evidenced community implementation for this paper. 2 weaker matches are hidden by default — verify before relying on them.

No code implementations found yet.

Know of an implementation? Let us know in the comments below!

Similar Papers

Cite this paper

@article{saglam2025large,
  title  = {Large Language Models Encode Semantics in Low-Dimensional Linear Subspaces},
  author = {Baturay Saglam and Paul Kassianik and Blaine Nelson and Sajana Weerawardhena and Yaron Singer and Amin Karbasi},
  year   = {2025},
  eprint = {2507.09709},
  archivePrefix = {arXiv},
  url    = {http://arxiv.org/abs/2507.09709v2}
}

Add a badge to your README

Shows whether official code is linked for this paper.

Code of Paper badge
[![Code of Paper](https://codeofpaper.com/badge/2507.09709.svg)](https://codeofpaper.com/paper/2507.09709)

Discussion