# Data Imputation Based on Retrieval-Augmented Generation
## 1 Introduction
Additionally, pre-trained LLMs typically require only a small amount of extra labeled data or prompts to perform well across multiple tasks, significantly reducing the effort and cost of training models. Therefore, utilizing LLMs to tackle data imputation tasks--while simultaneously ensuring high-quality predictions and keeping monetary costs manageable--has become a vibrant area of research. Recent work has explored prompt-based strategies that guide LLMs to infer and fill missing values in tabular datasets [29]. However, to fully realize the dual goals of improving imputation accuracy and minimizing cost, the following key challenges remain to be addressed:  
1. **How to equip LLMs with Cross-Domain Knowledge. ** Although LLMs have been trained on vast corpora and have absorbed a wealth of domain knowledge, the complexity and semantic heterogeneity of relational data still pose challenges for understanding and reasoning across domains. Therefore, it is crucial to study how to better utilize LLMs to solve the problem of cross-domain knowledge understanding and reasoning, which will help improve the quality of data imputation using LLMs. 2. **How to Enhance the Performance of LLMs in Data Imputation Tasks by Optimizing Prompt Strategies. ** Prompt design has a major impact on LLM performance in imputation tasks. In zero-shot settings, the model only sees a task description. This minimal context makes it hard to infer missing values [30; 31]. Few-shot prompting adds a small set of labeled examples. These examples help the model learn patterns and improve accuracy. However, results can vary greatly depending on which examples are chosen [32; 33]. Iterative prompting methods, such as chain-of-thought or tree-of-thought methods, break imputation into smaller reasoning steps. This gives the model richer, more structured context [34; 35]. While prompt engineering can enable LLMs to tackle data imputation tasks simply by constructing appropriate inputs, each prompt style still limits the total accessible information. Therefore, optimizing prompt strategies to enhance the performance of LLMs is critically important. 3. **How to Balance Imputation Quality and LLM Inference Cost** Prompt detail often drives LLM accuracy. Richer prompts or retrieval-augmented inputs supply more context and reduce errors, yet longer prompts directly raise inference costs. When imputing large datasets, even small cost increases multiply rapidly. Frequent calls to the LLM become expensive in terms of both time and money. Moreover, excessive context can slow down inference and complicate prompt design. Thus, a core challenge is finding the sweet spot, i.e., supplying enough information to ensure high-quality imputation while keeping token usage and latency within practical limits. To address the aforementioned issues, we propose the following approach:  
**Semantic Indexing of Data Lakes for Understanding of Cross-Domain Knowledge. **  
Data lakes contain vast, diverse knowledge in structured tables and long, unstructured texts. To make retrieval both fast and precise, we first convert all data to a unified semantic representation. Structured records, documents, and tables are embedded into the same vector space. We then build indexes on these embeddings so that cross-domain content can be retrieved efficiently and consistently. **Recall and Re-Ranking for Prompt Construction**  
With semantic indexes in place, we perform a coarse-grained recall to pull all potentially relevant data for a given imputation task. However, the recall set usually contains irrelevant information, which may risk introducing noise and hallucinations when fed entirely into LLMs. To prevent this, we apply a fine-grained ranking step to select only the top k most contextually relevant snippets. These high-quality snippets form the prompt's knowledge context, optimizing LLM focus and reducing error rates. **Cost-Aware Quality Optimization**  
To control inference costs in large datasets, we leverage LLMs to generate and validate executable code.