Manuscript Offprint

arXiv:2611.02637

Variable names provide priors: semantic grounding enables data-efficient numerical prediction by large language models

Xin-Rui Ma, Shi-Zhi Chen, Hai-Yan Jiang, De-Cheng Feng, Michael Beer

Open access. PaperVantage converted this article to text, so layout and figures may differ from the original.

Abstract

Large language models (LLMs) have achieved strong performance across diverse tasks, from question answering to code generation. Recent studies have found that LLMs can perform numerical prediction on tabular datasets via in-context learning. However, it remains unclear under what conditions and how LLMs use variable names and in-context examples for numerical prediction. Here we show that semantic grounding, the match between variable names and the values they describe, allows five LLMs without task-specific training to match or outperform seven supervised machine learning (ML) models across 20 datasets from nine scientific domains, particularly when examples are scarce. Reasoning traces indicate that variable names allow LLMs to draw on domain-specific knowledge acquired during pretraining. Using controlled tasks based on physical formulas, we further show that LLMs integrate domain-specific knowledge with in-context examples in a way consistent with Bayesian updating. Specifically, when the relationship between the inputs and the target cannot be inferred from the examples alone, LLMs rely on domain-specific knowledge as the prior. Conversely, as contradicting examples accumulate, LLM predictions shift progressively towards these examples, which act as the likelihood. Our work reveals how LLMs use domain-specific knowledge in numerical prediction and positions them as data-efficient predictors for data-scarce scientific domains.

Introduction

Pretrained on large and diverse text corpora, general-purpose large language models (LLMs) have acquired broad knowledge and demonstrated capabilities across tasks including language understanding, code generation and mathematical problem solving 1−3^{1-3}. Recent studies have shown that LLMs can perform numerical prediction on tabular datasets directly from in-context examples containing variable names and numerical values 4,5^{4,5}. Unlike supervised machine learning (ML) models, which typically learn statistical relationships solely from numerical values 6,7^{6,7}, LLMs can also use the semantic information conveyed by variable names. This semantic information may allow LLMs to draw on knowledge acquired during pretraining 8−10^{8-10}.

Previous studies have investigated the roles of numerical values and variable names in LLM prediction. On the one hand, LLMs can learn linear, nonlinear and high-dimensional functions from the numerical information of in-context examples 4,11−13^{4,11-13}. On the other hand, LLMs can estimate the effect of each feature on the target from variable names without any numerical values 14^{14}, suggesting that LLMs can exploit the semantic information these names carry. A few studies further find that adding variable names to in-context examples improves predictions 5,8,15^{5,8,15}, suggesting that LLMs can use both variable names and the examples. One study attributes this ability to both the retrieval of pretrained knowledge and learning from the examples 5^{5}, whereas another finds that adding in-context examples can suppress the recall of scientific knowledge 16^{16}. However, in these studies, variable names and examples reflect the same relation, so their individual contributions cannot be disentangled. In addition, these studies rely mainly on either synthetic data or real-world datasets from limited domains, which undermines the generalisability of their findings. Moreover, these datasets may be contaminated 17^{17}, making it difficult to separate the roles of pretrained knowledge and memorisation. More fundamentally, it remains unclear what enables LLMs to draw on pretrained knowledge, and these studies have not quantified how LLMs integrate this knowledge with in-context examples.

Here we evaluate five LLMs from five independent developers (Claude Opus 4.5, GPT-5.2, Gemini 3 Flash, Qwen3.5-397B and DeepSeek-V3.2) on 20 real-world tabular datasets spanning nine scientific domains (Fig. 1). These domains range from structural and geotechnical engineering to chemistry, biomedicine and urban mobility. For reference, we also evaluate seven representative supervised ML models on the same in-context examples. To mitigate data contamination, we include six datasets released after the training cutoffs of all five LLMs (Supplementary Table 19). Across these domains, LLMs perform comparably to or better than supervised ML models. This performance depends on variable names and is most pronounced under semantic grounding, the match between variable names and the values they describe. Reasoning traces indicate that variable names allow the LLMs to draw on domain-specific knowledge acquired during pretraining. Using 25 controlled tasks built from established physical formulas, we further show that four of the five LLMs integrate this knowledge with in-context examples in a way consistent with Bayesian updating, in which the knowledge acts as the prior and the examples as the likelihood. When the examples cannot distinguish the roles of two inputs, the predictions follow the roles implied by the variable names, and exchanging the two names reverses the predicted relation. As more examples contradict the names, the predictions shift progressively towards these examples. We quantify this shift and compare it with the predictions of a Bayesian observer. These findings not only reveal under what conditions and how LLMs perform numerical prediction, but also position LLMs as data-efficient predictors for scientific domains where data are scarce.

References (37)