When Cosine Similarity Fails to Reflect Linearly Accessible Structure in Dialogue Models
Organizations: LinkedIn
Abstract
Cosine similarity is widely used to analyze transformer representations, implicitly assuming that similarity reflects task-relevant structure. We study when this assumption fails in dialogue-conditioned large language models. Across three 7-8B chat-tuned models, ambient cosine similarity substantially underestimates linearly decodable persona structure on the same hidden states; numerically, linear probe AUC is in the 0.73-0.97 range while cosine kNN is in the 0.56-0.77 range on a 30-class task. A low-dimensional supervised subspace recovers much of this gap, whereas a matched-rank PCA subspace does not and in some cases degrades performance. This mismatch is regime-dependent: it is absent in single-sentence sentiment classification (SST-5), and a matched-cardinality control rules out attribute cardinality as a confound. The gap does not systematically increase across dialogue turns, and the task-aligned subspace remains stable over time. However, two of three models violate a pre-registered within-subspace separability invariance criterion (|Delta AUC| <= 0.03), and one model violates a pre-registered turn-invariance criterion (|Delta L| <= 0.05). These results show that cosine similarity can fail to reflect task-aligned structure in dialogue representations even when that structure is linearly accessible.
Figures & tables
| Method | Llama-3.1-8B (L ) | Qwen-3-8B (L ) | Mistral-7B (L ) |
|---|---|---|---|
| Shuffled-label baseline | |||
| Linear probe | |||
| Ambient cosine kNN ( ) | |||
| Supervised subspace kNN ( ) | |||
| PCA subspace kNN ( ) | |||
| Supervised lift over ambient |
Appendix figures & tables3 assets
Supplementary material from the paper’s appendix.
Appendix
| Model | Cond. | sup. lift | sup PCA gap | linear AUC | |
|---|---|---|---|---|---|
| Llama-3.1-8B (L ) | full- | ||||
| subsample | |||||
| Qwen-3-8B (L ) | full- | ||||
| subsample | |||||
| Mistral-7B (L ) | full- | ||||
| subsample |
| Axis | Llama-3.1-8B | Qwen-3-8B | Mistral-7B |
|---|---|---|---|
| formality | |||
| expertise | |||
| emotion | |||
| domain |
Representation Geometry in Language Models
Representation geometry in language models studies how embeddings and hidden states organize concepts, computation, and behavior.
See all 404 papers