ChatPaper.aiChatPaper

KV-Embedding: Embedding di Testo Senza Addestramento tramite Re-indirizzamento Interno KV in LLM Solo-Decoder

KV-Embedding: Training-free Text Embedding via Internal KV Re-routing in Decoder-only LLMs

January 3, 2026
Autori: Yixuan Tang, Yi Yang
cs.AI

Abstract

Sebbene i LLM siano potenti modelli di embedding, la loro applicazione in contesti privi di addestramento presenta due sfide strutturali: l'attenzione causale impedisce ai token iniziali di accedere al contesto successivo e l'obiettivo di predizione del token successivo distorce le rappresentazioni verso la generazione piuttosto che la compressione semantica. Per affrontare queste limitazioni, proponiamo KV-Embedding, un framework che attiva il potere rappresentativo latente di LLM congelati. Il nostro metodo sfrutta l'osservazione che gli stati chiave-valore (KV) del token finale in ogni livello codificano una visione compressa della sequenza. Reindirizzando questi stati come prefisso preposto, consentiamo a tutti i token di accedere al contesto a livello di sequenza in un unico passaggio in avanti. Per garantire un'applicabilità indipendente dal modello, introduciamo una strategia di selezione automatica del livello basata sulla dimensionalità intrinseca. Le valutazioni su MTEB condotte sui modelli Qwen, Mistral e Llama mostrano che KV-Embedding supera le baseline esistenti senza addestramento fino al 10%, mantenendo al contempo prestazioni robuste su sequenze fino a 4.096 token. Questi risultati dimostrano che la manipolazione degli stati interni offre un'alternativa efficiente alla modifica dell'input, e ci auguriamo che questo lavoro incoraggi un'ulteriore esplorazione degli interni degli LLM per l'apprendimento di rappresentazioni.
English
While LLMs are powerful embedding backbones, their application in training-free settings faces two structural challenges: causal attention restricts early tokens from accessing subsequent context, and the next-token prediction objective biases representations toward generation rather than semantic compression. To address these limitations, we propose KV-Embedding, a framework that activates the latent representation power of frozen LLMs. Our method leverages the observation that the key-value (KV) states of the final token at each layer encode a compressed view of the sequence. By re-routing these states as a prepended prefix, we enable all tokens to access sequence-level context within a single forward pass. To ensure model-agnostic applicability, we introduce an automated layer selection strategy based on intrinsic dimensionality. Evaluations on MTEB across Qwen, Mistral, and Llama backbones show that KV-Embedding outperforms existing training-free baselines by up to 10%, while maintaining robust performance on sequences up to 4,096 tokens. These results demonstrate that internal state manipulation offers an efficient alternative to input modification, and we hope this work encourages further exploration of LLM internals for representation learning.
PDF143February 27, 2026