Interactive Data Harmonization with LLM Agents

Aécio S. R. Santos, Eduardo H. M. Pena, Roque Lopez, Juliana FreirearXiv 2025

TL;DR

Data harmonization—the process of merging disparate datasets into a unified format—is a notorious bottleneck in scientific research. This paper introduces Harmonia, a system that uses LLM-based agents to interactively synthesize data pipelines by orchestrating specialized integration algorithms and generating custom code, significantly outperforming traditional automated baselines.

The Challenge: Semantic Mismatches in Data Integration

In fields like biomedicine, researchers often need to combine data from multiple independent studies to achieve a statistically significant sample size. However, these datasets rarely "speak the same language." They use different column names (schema mismatch), different units, and varying terminologies. For example, one study might use "FIGO grade 1" while another uses "G1 Well differentiated," both of which must be mapped to a standard vocabulary.

Example of semantic and value mapping challenges in clinical data harmonization.

Traditionally, this is solved by writing bespoke, one-off Python scripts or manually editing spreadsheets. This process is time-consuming, error-prone, and non-reproducible, as these custom scripts are rarely published, making it difficult for other scientists to replicate the study.

Methods: The Harmonia System

The authors propose an agentic data harmonization approach through their prototype, Harmonia. The system consists of three main pillars:

  • Harmonization Primitives: Instead of asking an LLM to perform the entire task, Harmonia uses bdi-kit, a library of specialized, efficient algorithms for tasks like schema matching and value mapping.
  • LLM Agent (The Orchestrator): Using a ReAct (Reasoning and Acting) framework, a GPT-4o agent decomposes a user's natural language request into a series of steps. It decides when to call a specific algorithm, when to generate custom Python code (via Pandas), and when to ask the user for clarification.
  • Interactive UI: A chat-based interface allows the agent to show its reasoning, present "best guesses" for mappings, and let the human expert provide the final "ground truth" for ambiguous cases.
The Harmonia system architecture, showing the interaction between the user interface, the LLM agent, and the data integration primitives.

Crucially, the system generates a declarative mapping specification (in JSON). This allows the entire harmonization process to be reproduced later without needing to re-run the expensive and potentially non-deterministic LLM.

Key Insights and Results

LLMs serve as semantic bridges, possessing vast "general knowledge" about specialized fields. For example, an LLM knows that "FIGO grade" relates to cancer staging, allowing it to catch mapping errors that a purely mathematical algorithm would miss. One of the most effective uses of the LLM in Harmonia is as an evaluator, flagging low-confidence pairs from matching algorithms.

In a preliminary evaluation comparing Harmonia against baseline automated methods using real-world clinical data:

  • Schema Matching: Harmonia achieved a 1.00 F1 score, compared to 0.78 for the baseline. It successfully corrected a mistake where the baseline incorrectly mapped Histologic_type to roots instead of primary_diagnosis.
  • Value Mapping: Harmonia improved the F1 score from 0.57 to 0.68, particularly excelling at identifying that "FIGO grade 1" should map to the standard "G1" label.

Limitations and Future Work

The system faces context window constraints with large tables and occasional LLM inconsistency. Future work includes improving robustness and evolving the UI toward "action-oriented" visual representations to help experts verify complex data mappings more quickly.

Summary updated

BibTeX
@misc{santos2025interactive,
  author = {Aécio S. R. Santos and Eduardo H. M. Pena and Roque Lopez and Juliana Freire},
  title = {{Interactive Data Harmonization with LLM Agents}},
  year = {2025},
  eprint = {2502.07132},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2502.07132},
}
Figure