Retrieval-Augmented Feature Generation for Domain-Specific Classification

Xinhao Zhang, Jinghan Zhang, Fengran Mo, Dakshak Keerthi Chandra, Yu-Zhong Chen, Fei Xie, Kunpeng Liu

TL;DR

RAFG (Retrieval-Augmented Feature Generation) is a novel framework that uses Large Language Models (LLMs) and external knowledge retrieval to automatically engineer interpretable, domain-specific features for tabular data. By grounding feature creation in real-world expertise—such as scientific formulas or economic indicators—RAFG significantly boosts classification performance in data-scarce environments while maintaining transparency.

What Problem Does This Paper Address?

In domain-specific fields like medicine or economics, data is often scarce, and the number of available features is limited. Traditional machine learning models struggle in these "small data" regimes. To compensate, researchers use feature generation to create new indicators from existing ones.

However, this process faces a major bottleneck:

  1. Manual Engineering: Relying on human experts is slow, expensive, and difficult to scale.
  2. Automated "Black Box" Methods: Existing automated tools often perform mathematical transformations (like squaring a variable) that lack physical meaning or domain relevance, making the resulting models hard to trust or interpret.
  3. Knowledge Gap: Models often lack the specific domain context (e.g., knowing that "Weight / Height²" equals BMI) needed to create truly useful features.

RAFG addresses this by using RAG (Retrieval-Augmented Generation) to pull in external domain knowledge, allowing an LLM to act as a "reasoning engine" that proposes and validates meaningful new features.

Methods

The RAFG framework operates in a three-stage iterative loop:

  1. Query Generation & Domain Knowledge Retrieval: The LLM analyzes the dataset's metadata (feature labels and descriptions) to identify potential relationships. It generates a search query to retrieve relevant documents from an external knowledge base (e.g., using Google’s Custom Search API).
  2. Feature Generation with Reasoning: Using the retrieved documents and a "Chain of Thought" strategy, the LLM proposes new features. These aren't just random math; they are categorized into Scaling (arithmetic on one feature), Transformation (fusing multiple features), or Judgment (logical rules). For example, as shown in the figure below, the LLM might retrieve the formula for BMI to combine height and weight features.
Fig. 1: Framework of RAFG. We adopt an LLM to generate new features according to the retrieved textual information containing expertise knowledge (e.g., the BMI as shown case).
  1. Feature Content Validation: The framework follows a "survival of the fittest" approach. A downstream classifier (like a Random Forest) evaluates the new feature. If the performance metric (e.g., Accuracy or F1) improves, the feature is adopted into the dataset, and the process repeats.
Detailed workflow of the RAFG framework

Datasets

The authors evaluated RAFG on four real-world, domain-specific datasets:

  • PDC (Parkinson’s Disease Classification): Medical domain, 754 features.
  • AID (Animal Information Dataset): Social/biological structure, 15 features.
  • GCI (Global Country Information): Economics/Geography, 34 features.
  • DIA (Diabetes Health Indicators): Medical domain, 21 features.

Key Insights and Ideas

  • Knowledge as a Grounding Mechanism: Unlike standard automated feature engineering, RAFG provides a "reason" for every feature. By linking a new feature to a retrieved document, the system ensures the feature is grounded in established domain knowledge.
  • Information Gain (IG): The authors found that RAFG-generated features don't just add noise; they significantly increase the "Information Gain," meaning they provide novel predictive signals that weren't present in the raw data.
  • LLM Robustness: The method isn't tied to a single model. While GPT-4o performed best, smaller open-source models like Llama 2-13B and Mistral-7B also showed significant improvements over baseline methods.
Fig. 3: Accuracy of using RF with RAFG and various LLMs.

Key Results

RAFG consistently outperformed baseline methods like Lasso, Reinforcement Learning (RL), and CAAFE across all datasets:

  • Accuracy Boosts: On the AID dataset, RAFG achieved a 19.2% increase in accuracy over raw data and a 3.8% lead over the next best baseline (CAAFE).
  • Precision and F1: In the GCI dataset using a Decision Tree, RAFG raised the F1 score from 55.6% to 68.1%.
  • Iterative Improvement: The case study on the GCI dataset showed that as the LLM added features like "Population Load Ratio" and "Environmental Stress Index," the information content of the dataset grew from 1.99 bits to 11.4 bits, directly correlating with accuracy gains.

Limitations and Future Work

  • Computational Cost: The iterative nature of the framework requires multiple LLM calls and search queries, which can be expensive and time-consuming for very large datasets.
  • Retrieval Quality: The system’s effectiveness is heavily dependent on the quality of the external knowledge base. If the search results are irrelevant, the generated features may not be useful.
  • Future Directions: The authors suggest exploring more complex feature types and integrating more specialized, curated domain libraries (rather than general web searches) to further improve the precision of the generated features.

Summary updated

BibTeX
@misc{zhang2024retrieval,
  author = {Xinhao Zhang and Jinghan Zhang and Fengran Mo and Dakshak Keerthi Chandra and Yu-Zhong Chen and Fei Xie and Kunpeng Liu},
  title = {{Retrieval-Augmented Feature Generation for Domain-Specific Classification}},
  year = {2024},
  eprint = {2406.11177},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2406.11177},
}
Figure