Vectorizing string entries for data processing on tables: when are larger language models better?

Léo Grinsztajn, Edouard Oyallon, Myung Jun Kim, Gaël VaroquauxarXiv 2023 · DOI · arXiv

Introduction

Tabular data remains the backbone of modern data science. While numerical and categorical data are well-handled by standard algorithms like Gradient Boosting Decision Trees (GBDTs), "messy" string entries—such as job titles, product descriptions, or city names—present a significant challenge. Traditionally, practitioners have relied on lightweight substring models (e.g., TF-IDF or MinHash). However, the rise of Large Language Models (LLMs) offers a new alternative: rich semantic embeddings. This paper investigates the trade-offs between these approaches, providing a roadmap for when the computational cost of LLMs is justified by downstream performance gains.

Methodology

The researchers evaluated a pipeline consisting of string vectorization followed by dimensionality reduction using PCA (reduced to 30 components). These embeddings were then used for two primary tasks:

  1. Analytics: Vectors were concatenated with numerical features and processed by a GBDT (specifically HistGradientBoostingClassifier).
  2. Fuzzy Joining: A 1-Nearest Neighbor approach was applied to the embeddings to link imperfectly aligned entity names across tables.

The study compared over 30 embedding methods, including classic n-gram models, massive 7B parameter models (Mistral, LLaMA), and models specifically fine-tuned for embeddings (e.g., OpenAI’s text-embedding-ada-002, BAAI’s bge, and Microsoft’s e5).

The Diversity Threshold

A central finding of the research is that the superiority of LLM embeddings depends on the diversity of the string entries. The authors propose a metric: the number of unique n-grams per 1,000 rows.

Gain percentage as a function of string diversity, showing a regime change around 3,000 unique n-grams.

As shown in Figure 4, there is a clear "regime change" at approximately 3,000 unique n-grams. Below this threshold (referred to as "Dirty Categories"), strings are sufficiently repetitive that simple substring models like MinHash perform comparably to LLMs. Above this threshold ("Diverse Entries"), LLMs provide substantial performance improvements by leveraging semantic understanding.

Model Selection: Size vs. Fine-tuning

The study also reveals that model size is not the sole determinant of performance. Fine-tuned embedding models often outperform significantly larger general-purpose LLMs.

Performance gain versus model parameter count, highlighting that fine-tuned embedding models often outperform larger raw LLMs.

Figure 6 illustrates that models like e5-large-v2 (335M parameters) can match or exceed the performance of 7B parameter models. This suggests that for tabular data tasks, specialized fine-tuning for sentence similarity is more impactful than raw parameter count. Furthermore, LLMs bring "world knowledge" to the task, enabling them to infer relationships (e.g., geographic properties) that are invisible to purely syntactic models.

Conclusion

For data practitioners, the choice of vectorizer should be guided by the nature of the data. For low-diversity, repetitive string columns, lightweight models like MinHash are efficient and effective. However, when dealing with high-diversity text where semantic meaning and external knowledge are required, fine-tuned embedding models offer a clear advantage. The use of PCA to reduce embedding dimensions further ensures that these powerful models can be integrated into GBDT pipelines without prohibitive computational overhead.

Reference: Grinsztajn, L., Kim, M. J., Oyallon, E., & Varoquaux, G. (2023). Vectorizing string entries for data processing on tables: when are larger language models better? arXiv:2312.09634.

Summary updated

Abstract

There are increasingly efficient data processing pipelines that work on vectors of numbers, for instance most machine learning models, or vector databases for fast similarity search. These require converting the data to numbers. While this conversion is easy for simple numerical and categorical entries, databases are strife with text entries, such as names or descriptions. In the age of large language models, what's the best strategies to vectorize tables entries, baring in mind that larger models entail more operational complexity? We study the benefits of language models in 14 analytical tasks on tables while varying the training size, as well as for a fuzzy join benchmark. We introduce a simple characterization of a column that reveals two settings: 1) a dirty categories setting, where strings share much similarities across entries, and conversely 2) a diverse entries setting. For dirty categories, pretrained language models bring little-to-no benefit compared to simpler string models. For diverse entries, we show that larger language models improve data processing. For these we investigate the complexity-performance tradeoffs and show that they reflect those of classic text embedding: larger models tend to perform better, but it is useful to fine tune them for embedding purposes.
BibTeX
@misc{grinsztajn2023vectorizing,
  author = {Léo Grinsztajn and Edouard Oyallon and Myung Jun Kim and Gaël Varoquaux},
  title = {{Vectorizing string entries for data processing on tables: when are larger language models better?}},
  year = {2023},
  eprint = {2312.09634},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2312.09634},
}
Figure