Evaluating Large Language Models in Semantic Parsing for Conversational Question Answering over Knowledge Graphs

Phillip Schneider, Manuel Klettner, Kristiina Jokinen, Elena Simperl, Florian Matthes

This paper explores the intersection of two hot topics in AI: Knowledge Graphs (KGs) and Large Language Models (LLMs). Specifically, it investigates how well LLMs can act as "semantic parsers"—translating multi-turn human conversations into structured SPARQL queries to retrieve facts from a database like Wikidata.

TL;DR

While general-purpose LLMs struggle to generate complex graph queries out of the box (zero-shot), they become remarkably proficient with few-shot prompting and lightweight fine-tuning. In fact, a specialized 7B-parameter model can outperform GPT-3.5-Turbo on many conversational tasks, though complex logical reasoning remains a significant hurdle for all models.

What Problem Does This Paper Address?

Conversational Question Answering (CQA) over Knowledge Graphs is difficult because it requires a model to bridge two very different worlds: the messy, ambiguous nature of human dialogue and the rigid, logical structure of graph query languages (like SPARQL).

To succeed, a model must handle "dialogue phenomena" like:

  • Coreference: Understanding that "his" in the second turn refers to "Albert Einstein" mentioned in the first.
  • Ellipsis: Filling in missing information when a user asks a follow-up like "And his birthplace?"
  • Schema Mapping: Correcting mapping natural language relations (e.g., "native country") to specific database IDs (e.g., P17).

Traditionally, this required complex, task-specific neural architectures. This paper asks: Can we just use a general LLM instead?

Methods

The researchers compared four LLM configurations:

  1. GPT-3.5-Turbo: The industry benchmark for conversational AI.
  2. LLaMA-7B: A popular open-source base model.
  3. Vicuna-7B: An instruction-tuned version of LLaMA.
  4. LoRA-7B: A LLaMA model fine-tuned by the authors using Low-Rank Adaptation (LoRA) on 30,000 task-specific examples.

They tested these models using two prompting strategies: Zero-shot (just instructions) and Few-shot (instructions plus three labeled examples). They also performed a qualitative human evaluation to categorize why models fail, identifying eight specific error types like "Syntax Error," "Deviating Entities," and "Cutoff" (where the query is too long for the model's output limit).

Datasets

The study used the SPICE dataset, a large-scale benchmark for conversational question answering over Wikidata.

  • Scale: 197,000 dialogues (average 9.5 turns).
  • Complexity: Includes simple questions, logical reasoning, quantitative (counting), and comparative questions.
  • Preprocessing: The authors mapped Wikidata IDs (like Q30) to lexical labels ("United States") to ensure the models weren't just relying on memorized facts but were actually parsing the logic of the conversation.

Key Insights and Ideas

  • Fine-tuning Trumps Scale: The fine-tuned LoRA-7B model consistently outperformed the much larger GPT-3.5-Turbo on simple and coreference-heavy questions. This suggests that for structured output tasks, "specialization" is more efficient than "generalization."
  • The Few-Shot "Negative Bias": Interestingly, adding few-shot examples hurt the performance of the fine-tuned LoRA model. The authors hypothesize that the examples introduced "information bias" that conflicted with the patterns the model had already learned during fine-tuning.
  • Reasoning vs. Syntax: GPT-3.5-Turbo showed a high "Alternative Query" rate. It often generated valid SPARQL that looked different from the ground truth but still returned the correct answer. This highlights its deep understanding of query logic, even when it doesn't follow a specific template.
  • The "Context Wall": All models struggled with ellipsis (omitted words). While they could handle "Who is he?", they failed more often when the user's intent was implied rather than stated.

Key Results

  • Simple Questions: The LoRA-7B model achieved an impressive 0.97 Accuracy/F1 in zero-shot settings, significantly beating GPT-3.5's 0.32.
  • Logical Reasoning: GPT-3.5-Turbo reclaimed the lead here with a 0.91 F1 in few-shot settings, showing its superior ability to handle complex boolean and set-based logic.
  • The Complexity Gap: For "Comparative Reasoning" (e.g., "Which city has more inhabitants?"), all models performed poorly, with most scores falling below 0.10. This indicates that generating multi-step, comparative SPARQL is still an open challenge for LLMs.

Limitations and Future Work

The authors noted several constraints:

  • Token Limits: Many complex queries were "cutoff" because the output limit was set to 128 tokens. Increasing this limit improved performance but didn't solve the underlying logic issues.
  • Language Bias: The study was limited to English. LLMs are expected to perform worse on morphologically rich languages where entity linking is harder.
  • Future Directions: The authors suggest integrating rule-based syntax checkers to "clean up" LLM outputs and exploring how these models handle different graph query languages beyond SPARQL.

Summary updated

BibTeX
@inproceedings{schneider2024evaluating,
  author = {Phillip Schneider and Manuel Klettner and Kristiina Jokinen and Elena Simperl and Florian Matthes},
  title = {{Evaluating Large Language Models in Semantic Parsing for Conversational Question Answering over Knowledge Graphs}},
  booktitle = {ICAART},
  year = {2024},
  url = {https://openreview.net/forum?id=Oj8SQMqZlk},
}
Figure