Search arXivSearch

arXiv · 2404.15420

XC-Cache: Cross-Attending to Cached Context for Efficient LLM Inference

Abstract

In-context learning (ICL) approaches typically leverage prompting to condition decoder-only language model generation on reference information. Just-in-time processing of a context is inefficient due to the quadratic cost of self-attention operations, and caching is desirable. However, caching transformer states can easily require almost as much space as the model parameters. When the right context isn't known in advance, caching ICL can be challenging. This work addresses these limitations by introducing models that, inspired by the encoder-decoder architecture, use cross-attention to condition generation on reference text without the prompt. More precisely, we leverage pre-trained decoder-only models and only train a small number of added layers. We use Question-Answering (QA) as a testbed to evaluate the ability of our models to perform conditional generation and observe that they outperform ICL, are comparable to fine-tuned prompted LLMs, and drastically reduce the space footprint relative to standard KV caching by two orders of magnitude.

Explore related subjects

Keep this discovery

Explore connections, maps & timelines

BibTeXRIS

João Monteiro, Étienne Marcotte, Pierre-André Noël, Valentina Zantedeschi, David Vázquez, Nicolas Chapados, Christopher Pal, Perouz Taslakian. 2024-11-01. XC-Cache: Cross-Attending to Cached Context for Efficient LLM Inference. https://arxiv.org/abs/2404.15420

Cite the original work for its findings. Save a collection to share your selection of sources.

KEEP EXPLORING

Related papers

Hierarchical attention interpretation: an interpretable speech-level transformer for bi-modal depression detection

Depression is a common mental disorder. Automatic depression detection tools using speech, enabled by machine learning, help early screening of depression. This paper addresses two limitations that may hinder the clinical implementations of such tools: noise resulting from segment-level labelling and a lack of model interpretability. We propose a bi-modal speech-level transformer to avoid segment-level labelling and introduce a hierarchical interpretation approach to provide both speech-level and sentence-level interpretations, based on gradient-weighted attention maps derived from all attention layers to track interactions between input features. We show that the proposed model outperforms a model that learns at a segment level ($p$=0.854, $r$=0.947, $F1$=0.897 compared to $p$=0.732, $r$=0.808, $F1$=0.768). For model interpretation, using one true positive sample, we show which sentences within a given speech are most relevant to depression detection; and which text tokens and Mel-spectrogram regions within these sentences are most relevant to depression detection. These interpretations allow clinicians to verify the validity of predictions made by depression detection tools, promoting their clinical implementations.

cs.CL

Cultural Alignment in Large Language Models Using Soft Prompt Tuning

Large Language Model (LLM) alignment is commonly achieved through supervised fine-tuning or reinforcement learning, both of which require labeled or preference data and update model weights. Without targeted cultural adaptation, however, deployed LLMs often exhibit culturally homogeneous behavior that fails to reflect diverse local values. Aligning models to cultural value frameworks such as Hofstede's Value Survey Module (VSM13) presents a distinct challenge: alignment signals are available only as aggregated survey-level scores computed after generating responses to an entire survey, providing no per-token gradient and requiring no preference data by construction. This makes standard gradient-based alignment methods ill-suited to the task. We propose a deployment-friendly approach that encodes cultural behavior in short, tunable soft prompts optimized with Differential Evolution (DE), while keeping model weights frozen and requiring no preference data. At inference, the system inserts the appropriate cultural-specific prompt to adapt model responses for different cultures. Experiments across four countries and four instruction-tuned models show that DE-optimized prompts generally reduce discrepancy with VSM13 reference profiles, improve rank agreement with the World Values Survey (WVS), an independent framework not seen during optimization, and are preferred in blinded pairwise evaluations using majority voting across three LLM judges.

cs.CL

VQ-Logits: Compressing the Output Bottleneck of Large Language Models via Vector Quantized Logits

Large Language Models (LLMs) have achieved remarkable success but face significant computational and memory challenges, particularly due to their extensive output vocabularies. The final linear projection layer, mapping hidden states to vocabulary-sized logits, often constitutes a substantial portion of the model's parameters and computational cost during inference. Existing methods like adaptive softmax or hierarchical softmax introduce structural complexities. In this paper, we propose VQ-Logits, a novel approach that leverages Vector Quantization (VQ) to drastically reduce the parameter count and computational load of the LLM output layer. VQ-Logits replaces the large V * dmodel output embedding matrix with a small, shared codebook of K embedding vectors (K << V ). Each token in the vocabulary is mapped to one of these K codebook vectors. The LLM predicts logits over this compact codebook, which are then efficiently "scattered" to the full vocabulary space using the learned or preassigned mapping. We demonstrate through extensive experiments on standard language modeling benchmarks (e.g., WikiText-103, C4) that VQ-Logits can achieve up to 99% parameter reduction in the output layer and 6x speedup in logit computation, with only a marginal 4% increase in perplexity compared to full softmax baselines. We further provide detailed ablation studies on codebook size, initialization, and learning strategies, showcasing the robustness and effectiveness of our approach.

cs.CL