Simple token prepending trick makes LLMs understand sentences better without extra training.
Token Prepending enhances sentence embeddings from LLMs by allowing earlier tokens to access complete sentence information through a simple prepending operation.
-----
https://arxiv.org/abs/2412.11556
π€ Original Problem:
Current LLMs use causal attention where earlier tokens can't see later tokens, leading to biased sentence embeddings. Existing solutions like repetition increase computational costs significantly.
-----
π§ Solution in this Paper:
β Token Prepending (TP) technique prepends a special <PST> token before the input sentence
β At each layer, TP replaces the <PST> token's embedding with the sentence embedding from previous layer
β This allows earlier tokens to access complete sentence information through causal attention
β The operation stops after early layers (typically 7th or 8th) to optimize performance
β Uses intermediate layer outputs instead of final layer for better semantic representation
-----
π‘ Key Insights:
β Simple token prepending significantly improves sentence embeddings without training
β Early layers are crucial for capturing backward dependencies
β Final layer embeddings contain less semantic information
β Method works across different LLM architectures and sizes
-----
π Results:
β Improves PromptEOL performance by 7.16 points on STS tasks
β Adds only 4% inference overhead compared to baseline
β Achieves 77.19 average Spearman correlation on STS tasks
β Consistently outperforms baselines across 7 transfer learning tasks










