Toward Structured Knowledge Reasoning: Contrastive Retrieval-Augmented Generation on Experience (2025)

Abstract: Large language models (LLMs) achieve strong performance on plain text tasks but underperform on structured data like tables and databases. Potential challenges arise from their underexposure during pre-training and rigid text-to-structure transfer mechanisms. Unlike humans who seamlessly apply learned patterns across data modalities, LLMs struggle to infer implicit relationships embedded in tabular formats, especially in the absence of explicit structural guidance. To bridge this cognitive gap, we introduce Contrastive Retrieval-Augmented Generation on Experience (CoRE), a framework that builds experience memory representations and enhances generalization through contrastive In-Context Learning (ICL) to simulate human-like knowledge transfer. Experiments on Text-to-SQL and TableQA show CoRE significantly improves performance, achieving average gains of 3.44% and 4.24%, with up to 17.2% on challenging tasks. Our Monte Carlo Tree Search (MCTS)-generated Experience Memory expands training data 8-9×, enhancing diversity and domain coverage. This training-free and continual method propels LLMs toward structured knowledge expertise.

## introduction large language models (llms) have shown remarkable capabilities on plain text but struggle with low-frequency, domain-specific concepts @xcite and structured data @xcite @xcite like tables and databases. this arises from two key issues: (1) limited exposure of llms to structural relationships during pretraining @xcite , and (2) difficulty in transferring reasoning from text to structured data @xcite . these issues are especially evident when reasoning with structured knowledge, where understanding the connections between structured data pieces and query text is crucial for accurate conclusions. to reduce reliance on pre-training data, retrieval-augmented generation (rag) @xcite has become a widely adopted technique for injecting external knowledge into llms. while effective in textbased tasks @xcite , naïve rag shown in figure 1 (a), fails to improve performance due to the lack of specialized mechanisms for structured knowledge reasoning. adding disconnected structured components (e.g. schemas and sub-tables) without grasping their interrelationships can disrupt the reasoning chain and hinder performance @xcite . while rag struggles with structured knowledge reasoning, humans excel at leveraging and transferring past experiences to solve complex, specialized problems, even those they have less exposure to. according to deliberate practice @xcite , human experts deliberately expose themselves to diverse schema cases, building mental representations that compensate for initial knowledge gaps (more explanation in appendix a.1). this enables them to solve unfamiliar problems by reflecting on both successful and failed attempts (e.g., joining database tables correctly or incorrectly). through self-monitoring, they identify mistakes, refine strategies, and focus on transferring patterns to structural reasoning rather than just memorizing surface-level facts. to adapt this human-like learning process to llms, the focus shifts to building dynamic experience and leveraging contrastive reflection. previous works on contrastive learning @xcite 2020), alignment @xcite , and in-context learning @xcite have shown that llms can learn more effectively by both positive and negative examples. this idea has been further supported by studies on reasoning @xcite , which improve the generalization of contrastive trajectories in complex, multi-step reasoning tasks. therefore, we introduce contrastive retrieval-augmented generation on experience (core). core builds experience memory representations and incorporates contrasted examples-both successful and failed cases-into the context to solve structured knowledge reasoning problems. as shown in figure 1 (b), core simplifies intricate structured reasoning problems into decomposable ones. it employs monte carlo tree search (mcts) @xcite along with a self-evaluation mechanism @xcite to mimic human deliberate practice, heuristically guiding the collection of successful and failed trajectories. through selection, expansion, simulation, and back-propagation, question-answer pairs are generated with reward labels (representing the probability of success in intermediate steps). subsequently, when a new problem arises, core retrieves relevant cases and re-ranks them based on reward labels to present both successful (positive) and failed (negative) examples for contrastive reflection, enabling more accurate and knowledgeintensive answers. extensive experiments on structured knowledge reasoning tasks, such as text-to-sql and tableqa, show that core significantly enhances both performance and efficiency, yielding average gains of 3.44% and 4.24% over baseline methods. in particular, core achieves greater improvements on more challenging problems, with increases of 17.2% and 8.2% (figure 4 ), respectively. the experience memory dataset built from mcts trajec-tories expands the original training dataset by 8-9×, demonstrating increased diversity and domain coverage with diluted, decomposed high-density knowledge (figure 3 ). moreover, compared to fewshot approaches using only fixed examples, core underscores the effectiveness of contrastive learning in context, achieving a 1.76% gain ( ## preliminary research questions and the formulation of structured knowledge reasoning, which uses llms to solve complex reasoning tasks based on structured data. research questions (1) can mcts effectively imitate human's practice for heuristic data augmentation? (2) can rag enhance structured knowledge reasoning? (3) does contrastive icl outperform fixed examples? existing methods for structured knowledge reasoning seldom employ rag because retrievable, domain-specific data is scarce. instead, retrieval from general documents often introduces noise, leading to a negative impact @xcite . for instance, dail-sql @xcite restricts retrieval to training data, limiting diversity and coverage. second, agent-based methods @xcite @xcite rely on fixed few-shot examples without incorporating dynamic contrastive learning for human-like adaptation. third, most approaches lack systematic mechanisms to evaluate positive/negative signal impacts during reasoning. these gaps drive our investigation into mctsbased augmentation, rag optimization, and contrastive learning for structured knowledge reasoning with llms. formalization structured knowledge reasoning can be described as a question-answering task. given a triple @xmath0, k, a), where q represents a natural language question, k is a structured knowledge representation, and a is an evidencesupported answer. based on the natural language question q and the accessible structured data k (e.g., a table or database), the first step is to extract useful evidence e from k (i.e., structured knowledge grounding). notably, e remains a structured, high-density knowledge representation. then, the llm generator g uses this evidence to generate the expected answer a in response to the question q. according to the task requirement, the generated answer a must be evidence-supported, but either free-form answers in natural language or structured expressions (e.g. sql statements) to be executed for obtaining the answer from k. this process can be formalized as: in our work, we focus on improving reasoning over extracted structured evidence, excluding the grounding phase. to better illustrate our task, we detail two types of reasoning formulation on databases and data tables: text-to-sql we define a database @xmath1, c}, where @xmath2, t 2 , . . . , t |t | } denotes tables and @xmath3, c 2 , . . . , c |c| } denotes columns, with foreign keys {(c tableqa we model a data table @xmath4, r}, where @xmath5, c 2 , . . . , c |c| } are columns and @xmath6, r 2 , . . . , r |r| } are rows, with each cell value denoted by v i,j ; accordingly, the grounding process identifies from k the pertinent columns c e and rows r e based on q, forming evidence ## core we present our core framework in this section. as illustrated in figure 2 , it consists of three key modules: contrastive thinker ( § 3.3), retriever ( § 3.2) and experience memory buildier ( § 3.1). ## experiment in this section, we first outline the experiment setup in § 4.1 and describe the experience memory dataset we constructed in § 4.2. then, we present experiments and results for two structured knowledge reasoning tasks in §4.3, including tableqa and text-to-sql. finally, the ablation study ( § 4.4) and strategy analysis ( § ??) are presented. ## conclusion we have introduced core, a training-free contrastive rag framework that uses monte carlo tree search to build an experience memory for structured knowledge reasoning. our experiments on text-to-sql and tableqa tasks demonstrate that core improves performance substantially on challenging queries by retrieving evidence with greater diversity and coverage than prior approaches. by incorporating both positive and negative examples through contrastive in-context learning, core enhances reasoning robustness across different grounding methods and remains scalable under strict token limits through multi-turn prompting. the offline memory construction incurs a one-time cost that is amortized across tasks, and inference-time retrieval adds negligible overhead. these results establish core as a flexible, efficient solution that extends the generalization of nlp models to complex structured reasoning scenarios.