Large Language Models (LLMs) demonstrate strong few-shot generalization through in-context learning, yet their reasoning in dynamic and stochastic environments remains opaque. Prior studies mainly focus on static tasks and overlook the online adaptation required when beliefs must be continuously updated, which is a key capability for LLMs acting as world models or agents. We introduce a Bayesian filtering framework to evaluate online inference in LLMs. Our probabilistic probe suite spans both multivariate discrete distributions, such as dice rolls, and continuous distributions, such as Gaussian processes, where ground-truth parameters shift over time. We find that while LLM belief updates resemble Bayesian posteriors, they are more accurately characterized by an exponential forgetting filter with a model-specific discount factor smaller than one. This reveals systematic discounting of older evidence that varies significantly across model architectures. Although inherent priors are often miscalibrated, the updating mechanism itself remains structured and principled. We further validate these findings in a simulated agent task and propose prompting strategies that effectively recalibrate priors with minimal computational cost.
翻译:大型语言模型(LLMs)通过上下文学习展现出强大的少样本泛化能力,但其在动态随机环境中的推理机制仍不透明。先前研究主要聚焦于静态任务,忽视了当信念需要持续更新时所必需的在线适应能力——这是LLMs作为世界模型或智能体运作的关键能力。我们引入贝叶斯滤波框架来评估LLMs的在线推理性能。我们的概率探测套件涵盖多元离散分布(如骰子投掷)和连续分布(如高斯过程),其中真实参数随时间动态变化。研究发现,虽然LLM的信念更新近似于贝叶斯后验,但更精确的描述是具有模型特定折扣因子(小于1)的指数遗忘滤波器。这揭示了LLMs系统性地对旧证据进行折扣处理的现象,且该现象在不同模型架构间存在显著差异。尽管模型固有先验常存在校准偏差,但其更新机制本身仍保持结构化和原则性。我们进一步在模拟智能体任务中验证了这些发现,并提出了能以最小计算成本有效重新校准先验的提示策略。