When Does Context Help? Error Dynamics of Contextual Information in Large Language Models

Fuente: arXiv
Salvato in:
Dettagli Bibliografici
Autori principali: Wang, Dingzirui, Zhang, Xuanliang, Xu, Keyan, Zhu, Qingfu, Che, Wanxiang, Deng, Yang
Natura: Preprint
Pubblicazione: 2026
Soggetti:
Accesso online:
Tags: Aggiungi Tag
Nessun Tag, puoi essere il primo ad aggiungerne!!
_version_ 1866917259472011264
author Wang, Dingzirui
Zhang, Xuanliang
Xu, Keyan
Zhu, Qingfu
Che, Wanxiang
Deng, Yang
author_facet Wang, Dingzirui
Zhang, Xuanliang
Xu, Keyan
Zhu, Qingfu
Che, Wanxiang
Deng, Yang
contents Contextual information at inference time, such as demonstrations, retrieved knowledge, or interaction history, can substantially improve large language models (LLMs) without parameter updates, yet its theoretical role remains poorly understood beyond specific settings such as in-context learning (ICL). We present a unified theoretical framework for analyzing the effect of arbitrary contextual information in Transformer-based LLMs. Our analysis characterizes contextual influence through output error dynamics. In a single-layer Transformer, we prove that the context-conditioned error vector decomposes additively into the baseline error vector and a contextual correction vector. This yields necessary geometric conditions for error reduction: the contextual correction must align with the negative baseline error and satisfy a norm constraint. We further show that the contextual correction norm admits an explicit upper bound determined by context-query relevance and complementarity. These results extend to multi-context and multi-layer Transformers. Experiments across ICL, retrieval-augmented generation, and memory evolution validate our theory and motivate a principled context selection strategy that improves performance by $0.6\%$.
format Preprint
id arxiv_https___arxiv_org_abs_2602_08294
institution arXiv
publishDate 2026
record_format arxiv
spellingShingle When Does Context Help? Error Dynamics of Contextual Information in Large Language Models
Wang, Dingzirui
Zhang, Xuanliang
Xu, Keyan
Zhu, Qingfu
Che, Wanxiang
Deng, Yang
Computation and Language
Contextual information at inference time, such as demonstrations, retrieved knowledge, or interaction history, can substantially improve large language models (LLMs) without parameter updates, yet its theoretical role remains poorly understood beyond specific settings such as in-context learning (ICL). We present a unified theoretical framework for analyzing the effect of arbitrary contextual information in Transformer-based LLMs. Our analysis characterizes contextual influence through output error dynamics. In a single-layer Transformer, we prove that the context-conditioned error vector decomposes additively into the baseline error vector and a contextual correction vector. This yields necessary geometric conditions for error reduction: the contextual correction must align with the negative baseline error and satisfy a norm constraint. We further show that the contextual correction norm admits an explicit upper bound determined by context-query relevance and complementarity. These results extend to multi-context and multi-layer Transformers. Experiments across ICL, retrieval-augmented generation, and memory evolution validate our theory and motivate a principled context selection strategy that improves performance by $0.6\%$.
title When Does Context Help? Error Dynamics of Contextual Information in Large Language Models
topic Computation and Language
url https://arxiv.org/abs/2602.08294