NeurIPS 2026Coming to NeurIPS?Explore papers, orals & directions

Knowledge Graph-based Question Answering with Electronic Health Records

Junwoo Park, Youngwoo Cho, Haneol Lee, Jaegul Choo, Edward Choi

Introduction

Electronic Health Records (EHRs) contain vital patient information but are often locked within complex, highly normalized relational databases. Accessing this data typically requires expertise in Structured Query Language (SQL). While Natural Language Question Answering (NLQA) systems aim to bridge this gap by translating English questions into SQL (NLQ2SQL), they face significant hurdles in real-world clinical settings.

Hospital databases are designed for storage efficiency, leading to fragmented schemas where a single patient's data is spread across dozens of tables. Answering even basic questions can require multiple JOIN operations. Autoregressive sequence-to-sequence models frequently struggle with these long, syntactically rigid SQL queries, leading to cascading errors. This research explores an alternative: converting EHRs into Knowledge Graphs (KGs) and querying them using SPARQL.

Methodology: From Tables to Graphs

The core of this approach is the transformation of relational data into a graph structure, shifting the paradigm from NLQ2SQL to NLQ2SPARQL.

Figure 1: Conversion process from relational database tables to a Knowledge Graph structure.

The researchers developed an algorithm to map the MIMIC-III database into a KG. In this model, primary and foreign keys are represented as entities (nodes), while non-key columns become literal values. The relationships defined by the database schema are preserved as edges between these nodes.

To evaluate this approach, the authors created four datasets based on the MIMIC-III database:

  • MIMICSQL: A baseline using a simplified 5-table schema and SQL.
  • MIMICSQL*: A more realistic dataset using the original, complex 9-table schema and SQL.
  • MIMIC-SPARQL: A graph-based version of the simplified schema.
  • MIMIC-SPARQL*: A graph-based version of the complex 9-table schema.

By keeping the model architectures (standard Seq2Seq and TREQS) constant and only changing the target logical form, the study isolated the impact of the query language itself.

Analysis of Query Complexity

A primary advantage of SPARQL over SQL in this context is its structural similarity to natural language. While SQL requires verbose syntax to link tables (INNER JOIN ... ON ...), SPARQL navigates the database by "hopping" between nodes in the graph.

Figure 3: Distribution of query lengths for complex schemas. SPARQL queries (red) are consistently shorter than SQL queries (blue).

As shown in the query length distribution, SPARQL queries remain significantly shorter than their SQL counterparts, especially as schema complexity increases. This brevity reduces the search space for autoregressive models and minimizes the potential for error propagation during the generation process. SPARQL effectively "immunizes" the QA system against increasing schema complexity; while SQL query length explodes with more required joins, SPARQL query length remains relatively stable.

Experimental Results

The transition to a graph-based representation yielded substantial performance gains, particularly on realistic, complex schemas:

  • Structural Accuracy: Using a standard Seq2Seq model on the complex MIMIC-SPARQL* dataset resulted in a 34% improvement in structural accuracy over the SQL-based MIMICSQL*.
  • State-of-the-Art Performance: When applied to the TREQS model, the SPARQL approach achieved a 5.1% boost in structural accuracy and a 3.6% increase in execution accuracy (retrieving the correct final answer).
  • The Complexity Gap: The performance difference between SPARQL and SQL widened most dramatically for complex questions requiring three or more JOIN operations in the relational version.

Conclusion and Future Directions

This research demonstrates that Knowledge Graphs provide a more effective foundation for EHR question answering than traditional relational databases. By simplifying the target logical form from SQL to SPARQL, models can more accurately capture the intent of natural language questions without getting bogged down in schema-specific syntax.

However, challenges remain. While SPARQL queries are easier to generate, executing them on massive graphs can be computationally expensive compared to optimized SQL. Future work will focus on improving the scalability of graph retrieval and expanding the dataset to encompass the full breadth of the MIMIC-III database.

Summary updated

BibTeX
@inproceedings{park2021knowledge,
  author = {Junwoo Park and Youngwoo Cho and Haneol Lee and Jaegul Choo and Edward Choi},
  title = {{Knowledge Graph-based Question Answering with Electronic Health Records}},
  booktitle = {MLHC},
  year = {2021},
  url = {https://openreview.net/forum?id=3cO77Z5ngb0},
}
Figure