A Text is Worth Several Tokens: Text Embedding from LLMs Secretly Aligns Well with The Key Tokens

Zhijie Nie, Richong Zhang, Zhanyu Wu
6/25/2024
8 citations
cs.CLcs.IR

No official code found. Best implementation: Arthurizijar/Text_aligns_tokens (18 stars, Python, Apache-2.0, last commit 2025-07-12).

Abstract

Text embeddings from large language models (LLMs) have achieved excellent results in tasks such as information retrieval, semantic textual similarity, etc. In this work, we show an interesting finding: when feeding a text into the LLM-based embedder, the obtained text embedding will be able to be aligned with the key tokens in the input text.

Show full abstract

We first fully analyze this phenomenon on eight LLM-based embedders and show that this phenomenon is universal and is not affected by model architecture, training strategy, and embedding method. With a deeper analysis, we find that the main change in embedding space between these embedders and their LLM backbones is in the first principal component. By adjusting the first principal component, we can align text embedding with the key tokens. Finally, we give several examples to demonstrate the vast application potential of this finding: (1) we propose a simple and practical sparse retrieval method based on the aligned tokens, which can achieve 80% of the dense retrieval effect of the same model while reducing the computation significantly; (2) we show that our findings provide a novel perspective to help understand novel technologies (e.g., instruction-following embedding) and fuzzy concepts (e.g., semantic relatedness vs. similarity) in this field.

View on arXivView PDF

Code Implementations(1)

Apache-2.0

The official code implementation of the ACL2025 paper “A Text is Worth Several Tokens: Text Embedding from LLMs Secretly Aligns Well with The Key Tokens”. Text Embedding from LLMs Secretly Aligns Well with The Key Tokens”.

180Python, PerlMay 25, 20251 years agoApache-2.0

Similar Papers

Cite this paper

@article{nie2024text,
  title  = {A Text is Worth Several Tokens: Text Embedding from LLMs Secretly Aligns Well with The Key Tokens},
  author = {Zhijie Nie and Richong Zhang and Zhanyu Wu},
  year   = {2024},
  eprint = {2406.17378},
  archivePrefix = {arXiv},
  url    = {http://arxiv.org/abs/2406.17378v4}
}

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/2406.17378.svg)](https://codeofpaper.com/paper/2406.17378)

Discussion