Selecting and generating web search based features using small language models for tabular data classification

Selecting and generating web search based features using small language models for tabular data classification

Dataset and metrics

We leverage two small datasets, namely the Global Country Information Dataset (GCI)31 and the Animal Information Dataset (AID)32 as shown in Table 1. GCI provides a collection of country-level indicators covering a wide range of socio-economic, demographic, environmental, and geographic attributes. It includes variables such as life expectancy, infant and maternal mortality rates, and education enrollment ratios. Healthcare-related indicators include physicians per thousand people as a measure of system capacity, as well as out-of-pocket health expenditure. The dataset also contains labor force participation measures and economic indicators such as tax revenue, consumer price index (CPI), and minimum wage. In addition to these, environmental and spatial attributes such as CO2 emissions, forested and agricultural land percentages, population density, and geographic coordinates are included. Demographic and structural information, including population size, urbanization rate, capital cities, official languages, and administrative identifiers, are also provided.

Table 1 Dataset samples from different domains.

For the GCI dataset, life expectancy is selected as the target variable and discretized to enable classification-based evaluation. This variable represents a key outcome influenced by multiple socio-economic, healthcare, and environmental factors, making it suitable for evaluating the relevance of selected features. Life expectancy is originally a continuous variable in the GCI dataset and is discretized into four classes using quartile-based binning. Based on the 181 non-missing observations, the quartile boundaries are 67.0, 73.2, and 77.5 years, with a minimum value of 52.8 and a maximum value of 85.4 years. Accordingly, the four classes correspond approximately to 52.8–67.0, 67.0–73.2, 73.2–77.5, and 77.5–85.4 years. This quartile-based procedure produces an approximately balanced target, with each class containing about 25% of the valid observations (approximately 45–46 instances per class).

AID provides a structured collection of animal-level attributes covering biological, ecological, and behavioural characteristics. The dataset includes taxonomic information such as animal names and family classifications, along with ecological attributes including habitat, diet, and natural predators. It also contains life-history and reproduction-related variables such as lifespan, gestation period, and offspring per birth. Physical and morphological characteristics, including height, weight, and color, are provided, along with behavioural and performance-related indicators such as average and maximum speed. Geographical distribution and conservation-related information, including countries where species are found and their conservation status, are also included.

For the AID dataset, social structure is used as the target variable, representing higher-level behavioural characteristics of animal species. Ecological and biological attributes such as habitat, diet, predator relationships, and taxonomic information (e.g., family) are expected to be informative for predicting social structure, as they reflect environmental pressures, evolutionary traits, and survival strategies. The social structure feature is an originally categorical target rather than a discretized continuous variable. It contains 10 classes: solitary (124), group-based (35), social groups (17), herd-based (6), colony-based (5), pack-based (4), flocks (2), social pods (1), eusocial (1), and varies (1), for a total of 196 observations. The resulting class distribution is highly imbalanced, with the solitary class accounting for 63.27% of the dataset. In addition, attributes such as conservation status and species identity (animal) may capture broader ecological patterns associated with behavioural organization.

The rationale for selecting the GCI and AID datasets is primarily motivated by the need to ensure a fair comparison with the reference study12. Both datasets are relatively small, containing approximately 200 samples and a large number of features, making them well suited for evaluating feature selection and feature generation tasks. Furthermore, the datasets represent two distinct domains: country-level indicators encompassing socio-economic and demographic characteristics, and animal-level features capturing diverse biological and ecological characteristics. This domain diversity provides an appropriate basis for assessing the generalizability of our approach. In addition, the reference study12 (see Table 10) employs these datasets to compare its approach with existing methods, including reinforcement learning-based feature engineering (RL)33 and context-aware automated feature engineering (CAAFE)34.

The assessment of the prompt-based feature generation framework presented for machine learning classification relies on standard metrics, including precision, recall, and the F1 score. These metrics are widely used for general classification tasks35 and are considered standard evaluation measures for feature engineering. As reported in the reference study12 (see Table 10), we compute Precision, Recall, and F1-score using macro averaging.

Feature selection

Based on the main system prompt of the feature selection subtask23, we show the most critical features for each dataset in Table 3 and 4. For our experiments, we utilize small language models (SLMs): Gemma3:4b36, LLaMA3.2:3b37, and Qwen3:4b38, all deployed locally via the Ollama framework39. Although there is no universally fixed parameter threshold distinguishing small from large language models, Lu et al.40 adopt a 100M–5B parameter range for the SLMs considered in their survey. Following this convention, we refer to the 3–4B models used in our experiments as SLMs. This approach avoids reliance on proprietary and commercial generative models such as GPT-4.

To identify highly critical features, we use a threshold of \(\mathrm {LLM\text {-}Score} \ge 0.75\). This threshold was selected as a practical compromise between selectivity and coverage, retaining features with strong relevance while excluding those with only moderate or marginal contributions. Tables 2 and 3 report the selected features that meet this threshold for the GCI and AID datasets, respectively.

Table 2 Features of the GCI dataset with LLM-Score greater than or equal to 0.75.

The features identified by the SLMs are largely consistent with established determinants of life expectancy. Health-related indicators such as infant mortality, maternal mortality ratio, physicians per thousand, and out-of-pocket health expenditure directly reflect population health and healthcare accessibility. Education-related variables, including gross primary and tertiary education enrollment rates, capture human capital development and are commonly related with enhanced health status. Economic and labor-market indicators, such as CPI change, labor force participation, and unemployment rate, provide insights into economic well-being and living conditions. Together, these features represent complementary dimensions of healthcare, education, and socio-economic development that are strongly associated with variations in life expectancy across countries. The consistent selection of these variables across different SLMs suggests that the models successfully identify semantically meaningful predictors of the target variable.

Table 3 Features of the AID dataset with LLM-Score greater than or equal to 0.75.

The selected features of AID suggest that the SLMs associate social structure with ecological, taxonomic, and behavioral characteristics. Attributes such as habitat, diet, predators, and family describe the ecological niche and evolutionary relationships of species, while conservation status and species identity may capture broader ecological and behavioral patterns. Together, these factors are likely to influence how animals interact, organize, and survive within their environments, making them relevant predictors of social structure. The recurring selection of these attributes across different SLMs further indicates that they are considered semantically meaningful for characterizing animal social organization.

Results

Considering this subsection, we present the computational results of the RAG-based feature generation experiments conducted on a consumer-grade computer. The system is equipped with an Intel Core i7-4770, 8 GB of RAM, and an NVIDIA GeForce GTX 1070 GPU with 8 GB of VRAM, and runs locally deployed models via the Ollama library (https://ollama.com). This setup demonstrates the efficiency of the proposed approach, showing that strong natural language processing performance can be achieved without high-performance computing resources. As a result, the method lowers the barrier to entry for researchers working within practical hardware constraints.

We adapt our method to generate candidate features by leveraging the existing features in the dataset. Importantly, our method does not use LLM-estimated values to populate the generated features, thereby avoiding the risk of introducing hallucinated or fabricated numerical values and reducing potential data leakage. Instead, the generated feature names are validated by a domain expert, who uses web search results to determine whether reliable, externally available data for each feature can be obtained for the entities in the corresponding dataset. The domain expert does not manually curate or assign feature values; rather, this step is limited to assessing the availability and relevance of external data sources. Consequently, the actual feature values are obtained from external web-based sources rather than generated or estimated by the LLM.

This design mitigates the risk that the LLM memorizes information from the public datasets or directly infers target-related values from row identifiers, such as country or species names. In our experiments, the average time required to process a query is approximately 2.34 and 3.21 seconds for the GCI and AID datasets, respectively. Furthermore, we obtain an average inter-annotator agreement rate of 0.8541, indicating substantial consistency in the feature validation process. These design choices make the generated features more interpretable and reproducible while supporting our broader goal of developing an SLM-assisted, web-search-based feature engineering approach.

Comparison with literature studies

To compare our method with literature studies, we use the baseline methods from Zhang et al.12, as it serves as the reference study for a fair comparison. We select Random Forests42 as the machine learning classification method for tabular datasets. Our study is compared against the LASSO43, the Reinforcement Learning-based Feature Engineering for Predictive Modeling (RL)33, and the CAAFE approach34.

Zhang et al.12 employ Wikipedia as the external knowledge library for feature generation. Their approach involves performing multiple searches within a 5-second window for each query and restricting the results to the top three most relevant documents. GPT-4o then selects the most appropriate document from these for feature generation.

Table 4 Comparison with existing studies12 on the AID and GC datasets.

The statistical significance test was conducted to compare the GCI F1-macro performance of LLaMA3.2:3b and Gemma3:4b. LLaMA3.2:3b achieved a higher GCI F1-macro score than Gemma3:4b (0.848 ± 0.012 vs. 0.823 ± 0.015), and the observed difference was statistically significant (p = 0.03). Since p < 0.05, the improvement of LLaMA3.2:3b over Gemma3:4b is statistically significant at the 5% significance level. The same procedure was applied to compare the AID F1-macro performance of LLaMA3.2:3b and Gemma3:4b. LLaMA3.2:3b achieved a higher AID F1-macro score than Qwen3:4b (0.383 ± 0.081 vs. 0.37 ± 0.076); however, the observed difference was not statistically significant (p = 0.12). Therefore, although LLaMA3.2:3b achieved a higher mean F1-macro score, the improvement over Qwen3:4b cannot be considered statistically significant at the 5% significance level. Overall, these results indicate that LLaMA3.2:3b provides a statistically significant improvement over Gemma3:4b on the GCI dataset, whereas the improvement on the AID dataset is not statistically significant. The lack of statistical significance on AID may be influenced by the severe class imbalance in its 10-class target, with several classes containing only one or two observations.

Table  4 compares our approach with those of previous studies. We employ the Random Forest method because it is a robust supervised machine learning technique that builds and combines many decision trees to produce more accurate and reliable predictions. As an ensemble learning technique, it aggregates the outputs of multiple individual models into a single, stronger predictive model.

Instead of relying on commercial systems such as the Google Search API, we utilise open-source SLMs together with Dux Distributed Global Search (DDGS) to retrieve relevant documents that guide feature generation.

Overall, the results indicate that the presented web search–based retrieval-augmented feature generation approach delivers more stable and higher performance than the Raw, LASSO, RL, CAAFE, and RAFG methods across all evaluated open-source small language models, including Gemma 3, LLaMA 3.2, and Qwen 3. Among these models, LLaMA 3.2 achieves the highest scores among the evaluated SLM configurations on the AID and GCI datasets, with macro-F1 scores of 0.383 and 0.848, respectively.

Experiments on the GCI dataset: effects of feature selection and generation

To compare the effects of the important selected features and generated features, we run experiments on the GCI dataset considering the same evaluation setup defined in Zhang et al. study12, in which F1 scores are based on the mean of 5-fold cross-validation. The main difference of our study is to identify the most critical features23 instead of using all features depicted from Zhang et al. study12. Moreover, our study is entirely built on open-source small language models and publicly accessible web search systems, making it well-suited for resource-constrained devices and sensitive domains where data privacy is a key concern.

Table 5 Effects of different selected features for the GCI dataset using the Gemma3:4b model.Table 6 Effects of different selected features for the GCI dataset using the LLaMA3.2:3b model.

Gemma 336 is a multimodal extension of the Gemma family of lightweight open models, with parameter sizes ranging from 1 to 27 billion. This release adds capabilities for visual understanding, broader multilingual support, and extended context handling of at least 128K tokens. Moreover, the model architecture has been redesigned to reduce the KV-cache memory overhead that typically increases with longer contexts. This improvement is achieved by increasing the proportion of local attention layers relative to global attention layers while maintaining a short span for local attention.

Llama 337 is publicly released, including both pre-trained and post-trained versions of language models designed with native support for multilingual tasks, coding, reasoning, and tool utilization. Its largest variant is a dense Transformer model containing 405 billion parameters and supporting a context length of up to 128K tokens.

Table 7 Effects of different selected features for the GCI dataset using the Qwen3:4b model.

Qwen 338 consists of a collection of language models aimed at improving performance, efficiency, and multilingual support. The series features both dense and Mixture-of-Experts architectures, with model sizes spanning from 0.6 billion to 235 billion parameters. One of the major advancements in Qwen3 is the unified incorporation of both thinking mode, which handles complex multi-step reasoning, and non-thinking mode, which enables context-aware outputs. However, it generates redundant explanations about the generated feature suggestions because of this thinking mode.

Table 5 illustrates the impact of different selected features on the GCI dataset using the Gemma3:4b model. To ensure a fair and controlled experimental setup, we adopt the same strategy of randomly selecting features across all datasets. In the initial setting, no generated features from the Gemma3:4b model are incorporated (see Fig. 1 for further details). Subsequently, we utilize the Random Forest classifier42 for this tabular dataset, as it achieved the highest F1 score among the evaluated methods in the baseline study12. After incorporating features generated by the Gemma3:4b model, the approach achieved an F1 score of 0.823 using the important+generated features strategy. In this setting, the generated features include urbanization density, GDP, environmental risk index, and fertility rate.

Table 6 presents the same experimental setup for the GCI dataset; however, in this case, the LLaMA3.2:3b model is utilized for feature generation. To carry out a fair comparison, the same randomly selected features are leveraged to train the Random Forest classifier. Our method achieves an F1 score of 0.848 by generating additional features, including GDP per capita, the Healthcare Access Index, and growth rate. These are all highly relevant indicators for modelling life expectancy at the country level.

In particular, the Healthcare Access Index captures the availability, quality, and accessibility of medical services within a country, directly affecting disease prevention, treatment effectiveness, and overall public health outcomes. Countries with higher healthcare accessibility generally exhibit lower mortality rates and longer life expectancy due to stronger healthcare infrastructure and broader medical coverage. Similarly, Growth Rate reflects the pace of population or economic development and can impact life expectancy through its influence on resource allocation, healthcare demand, employment opportunities, and social welfare. Stable and sustainable growth patterns are often associated with improved socioeconomic conditions that contribute to increased life expectancy.

Table 7 proposes the same evaluation setup using the Qwen3:4b model, which performs slightly worse than the corresponding configuration with the LLaMA3.2:3b model. In this case, the model generates poverty and unemployment rate as additional suggested features to augment the important feature set. A higher poverty rate is often associated with poorer health outcomes, limited access to medical services, malnutrition, and lower overall life expectancy, since disadvantaged populations typically face greater barriers to maintaining good health. The unemployment rate is the ratio of people who are actively looking for work but cannot find it to the total number of people in the workforce. High unemployment can negatively affect life expectancy indirectly by reducing income stability, increasing stress, limiting access to healthcare and nutritious food, and worsening mental health outcomes. Together, both poverty and unemployment are key socioeconomic indicators that strongly influence population health and longevity.

Experiments on the AID dataset: effects of feature selection and generation

In this subsection, we run experiments on the AID dataset using the same evaluation setup defined in the previous subsection. Table 8 presents the effects of various feature selection and generation combinations using the Gemma 3:4b model.

Table 8 The impact of varying settings on the AID dataset using the Gemma3:4b model.

As shown in Table 9, randomly selected features without generated features achieve an F1 score of 0.212. Regarding the generated features, the Gemma 3:4b model suggests body mass, home range size, and metabolic rate as additional features. Under this setting, the combined important-and-generated feature strategy achieves the highest F1 score of 0.359.

Table 9 The impact of varying settings on the AID dataset using the LLaMA3.2:3b model.

Table 9 indicates the effects of different selected and generated features using the LLaMA 3.2:3b model. To guarantee a fair and controllable comparison, we use the same randomly selected features in all the experiments in the table. In the combined important-and-generated feature strategy, the LLaMA 3.2:3b model suggests Environmental Adaptability, Domain-Specific Burden, and Taxonomic Hierarchy Depth as generated features.

This combined strategy achieves the best F1 score of 0.383. Although the F1 score of 0.383 is relatively modest, the AID dataset is challenging, with only 205 samples distributed across 10 classes. Therefore, the result is more meaningful when compared with previously reported performance than when considered in isolation. In the reference study, the best-performing method on AID, RAFG with Random Forest, achieves a macro-F1 score of 0.324, while our LLaMA3.2:3b configuration reaches 0.383. This improvement suggests that the proposed feature selection and generation approach can provide additional predictive value on AID, although the overall performance also shows that there is still considerable room for improvement on this dataset.

As a use-case scenario, the domain expert in biology suggested the term ‘Ecological Pressure’ instead of ‘Domain-Specific Burden’; however, we retained the version generated by the LLaMA model. Since these equations provide detailed representations, we present only two examples to clarify the overall objective of the proposed method. The generated feature ‘Domain-Specific Burden’ is also motivated by the prompt design, which includes the instruction shown in Fig. 3: ‘Prioritize features that capture mechanisms, interactions, burden, temporal dynamics, intensity, contextual risk, or grouped domain states.’

We use the term Domain-Specific Burden (DSB), instantiated as Ecological Pressure in the biology domain, as a composite score derived from existing AID features. Since habitat and diet are categorical variables, we first encode each category as a pressure score. The derived form of the \(DSB_i\) for species i is defined as follows:

$$\begin{aligned} DSB_i = \omega _hH_i+\omega _dD_i+\omega _pP_i \end{aligned}$$

(4)

where \(H_i\), \(D_i\) and \(P_i\) represent the habitat pressure, dietary and predator pressures for species i, respectively. Since the weights satisfy \(\sum \omega =1\), we assign weights of 0.4 to habitat pressure and 0.3 to each of dietary and predator pressures. Similarly, we use the term “Environmental Adaptability (EA)” as a derived feature that combines habitat and dietary adaptability.

$$\begin{aligned} EA_i = \frac{1}{2} (\frac{H_i^c}{H_m}+\frac{D_i^c}{D_m}) \end{aligned}$$

(5)

where \(H_i\) and \(D_i\) represent habitat and dietary adaptabilities of species i, respectively. Specifically, \(H_i^c\) denotes the number of habitat types occupied by species i, while \(D_i^c\) denotes the number of diet categories used by species i. Finally, \(H_m\) and \(D_m\) indicate the maximum number of habitat types and diet categories, respectively.

Table 10 The impact of varying settings on the AID dataset using the Qwen3:4b model.

Finally, Table 10 reveals the F1 scores obtained using randomly selected features, important selected features, and their combinations with generated features. The Qwen3:4b model suggests BMI and Reproductive Rate (offspring/year) as generated features and achieves slightly lower performance than the LLaMA 3.2:3b model. In addition, the Qwen3:4b model produces irrelevant feature explanations due to its reasoning (“thinking”) mode.