mlsanityData to 14 Oct 2026

Mean-Pooled Cosine Similarity is Not Length-Invariant: Theory and Cross-Domain Evidence for a Length-Invariant Alternative

arXiv 2605.07345 ↗First posted 8 May 2026cs.CL cs.LGcited by 0

Not on the map. Why?

Abstract (arXiv)

Mean-pooled cosine similarity is the default metric for comparing neural representations across languages, modalities, and tasks. We establish that this metric is not length-invariant: under the anisotropy that characterizes modern transformer representations, mean-pooled cosine grows monotonically in sequence length, independent of representational content. Empirically, on HumanEvalPack across four code LLMs, the length ratio alone explains R2 = 0.52--0.75 of cross-language "Python proximity," while AST depth and shared-token fraction add less than 3% of explained variance beyond length. Substituting Centered Kernel Alignment (CKA) reduces explained variance by 83% and reverses the sign of the length coefficient (βlen: +0.86 → -0.37). The same pattern holds in Mistral-7B on parallel WMT pairs (R2 = 0.23 EN-FR, R2 = 0.33 EN-DE for cosine; R2 < 0.01 for CKA). In CLIP ViT-B/32, mean-pooling reduces the length effect relative to EOS-pooling (R2: 0.21 → <0.01), as predicted by the theory's dependence on anisotropy. We argue that length-invariant metrics such as CKA should be the default for cross-representation comparisons, and that recent claims of cross-lingual representational convergence built on mean-pooled cosine warrant re-examination.

Key facts. No citing papers in the map yet (data through 14 Oct 2026). Builds on 11 of its 16 references that are in the map. First posted on arXiv 8 May 2026.

Builds on

11 of 16 references.

References · 11

  1. 2021Learning Transferable Visual Models From Natural Language Supervisioncited by 33,744
  2. 2019Unsupervised Cross-lingual Representation Learning at Scalecited by 3,935
  3. 2023Code Llama: Open Foundation Models for Codecited by 2,139
  4. 2019Similarity of Neural Network Representations Revisitedcited by 1,755
  5. 2024Qwen2.5-Coder Technical Reportcited by 1,203
  6. 2024Do Llamas Work in English? On the Latent Language of Multilingual Transformerscited by 281
  7. 2019Representation Degeneration Problem in Training Natural Language Generation Modelscited by 255
  8. 2023Language Model Tokenizers Introduce Unfairness Between Languagescited by 214
  9. 2017All-but-the-Top: Simple and Effective Postprocessing for Word Representationscited by 212
  10. 2023OctoPack: Instruction Tuning Code Large Language Modelscited by 189
  11. 2022Reliability of CKA as a Similarity Measure in Deep Learningcited by 87

Built on by

Not cited yet.