LLM-assisted Labeling Function Generation for Semantic Type Detection

Chenjie Li, Dan Zhang, Jin Wang

Introduction

Semantic type detection—identifying the category of data within a column, such as an ISBN, city name, or year—is a fundamental task for organizing and cleaning large-scale "data lakes." While deep learning models excel at this, they typically require thousands of manually labeled examples per type. Human annotation is notoriously slow and expensive, making it difficult to scale to the hundreds of semantic types found in real-world web tables.

Weak supervision offers a promising alternative by using noisy, automated rules called Labeling Functions (LFs) to generate training data. However, manually writing these rules for hundreds of categories is often as labor-intensive as labeling the data itself. This research introduces an end-to-end pipeline that leverages Large Language Models (LLMs) like GPT-4 to automate the generation of these labeling functions.

Methodology

The proposed framework consists of three primary stages designed to move from raw data to a high-performing detection model.

End-to-end pipeline for LLM-assisted labeling function generation and weak supervision.

1. LLM-assisted LF Generation

The system uses GPT-4 to generate three distinct types of LFs: keyword-based (checking for specific words), statistical (analyzing value distributions like averages or lengths), and regular expressions (matching structural patterns like ISBN formats). To ensure the LLM understands the semantic intent, the researchers employed a "few-shot" prompting strategy, providing the model with examples of column values and their ground-truth labels to help it write functional Python code.

2. Stacked Labeling Model

Standard weak supervision frameworks often struggle with high-cardinality datasets containing hundreds of labels. To address this, the authors developed a "Stacked Labeling Model." This approach partitions the label space into smaller, disjoint groups using K-means clustering on label embeddings. Multiple Snorkel models are then run in parallel, with a top-level "routing" model aggregating the results.

3. End Model Training

The noisy labels generated by the stacked model serve as training data for a final "End Model" (specifically a version of the Doduo transformer). This model is capable of generalizing beyond the explicit rules written by the LLM, capturing nuances that simple keywords or regex might miss.

Experimental Setup

The framework was evaluated on two major benchmarks: Viznet, a corpus of 78 column types across nearly 120,000 columns, and WikiTable (TURL), a more complex dataset featuring 255 semantic types across over 570,000 tables.

Results and Discussion

The results demonstrate a significant performance gain as data moves through the pipeline. On the Viznet dataset, raw LLM-generated LFs achieved an average F1 score of only 18%. However, the integration of the Label Model and subsequent training of the End Model saw the Micro F1 score rise to 43%.

Performance metrics across different stages of the pipeline on the Viznet dataset.

Key Insights

  • Contextual Prompting: Including ground-truth labels in the prompt was essential for generating accurate rules. This provides the LLM with the necessary context to define the semantic boundaries of a type.
  • Efficiency: The system achieved competitive results using only approximately 1.3% of the labeled data typically required for full supervision.
  • Scalability Challenges: While the "Stacked" approach makes weak supervision viable for many classes, performance dropped significantly on the highly complex WikiTable dataset (Micro F1 of 0.065), indicating that simple rules struggle as the label space becomes increasingly crowded.

Conclusion and Future Work

This research highlights the potential of LLMs to automate the "tedious" parts of weak supervision. Future work will focus on developing more sophisticated "ML-based LFs"—where the LLM generates small, explainable models like decision trees—and refining label space partitioning to better handle overlapping semantic types like "Name" and "City."

Summary updated

BibTeX
@inproceedings{li2024llm,
  author = {Chenjie Li and Dan Zhang and Jin Wang},
  title = {{LLM-assisted Labeling Function Generation for Semantic Type Detection}},
  booktitle = {Workshops @ VLDB},
  year = {2024},
  url = {https://openreview.net/forum?id=gfepBvGv3I},
}
Figure