Learning to Transpile AMR into SPARQL

Mihaela Bornea, Ramón Fernandez Astudillo, Tahira Naseem, Nandana Mihindukulasooriya, Ibrahim Abdelaziz, Pavan Kapanipathi, Radu Florian, Salim Roukos

Abstract: We propose a transition-based system to transpile Abstract Meaning Representation (AMR) into SPARQL for Knowledge Base Question Answering (KBQA). This allows to delegate part of the abstraction problem to a strongly pre-trained semantic parser, while learning transpiling with small amount of paired data. We departure from recent work relating AMR and SPARQL constructs, but rather than applying a set of rules, we teach the BART model to selectively use these relations. Further, we avoid explicitly encoding AMR but rather encode the parser state in the attention mechanism of BART, following recent semantic parsing works. The resulting model is simple, provides supporting text for its decisions, and outperforms recent progress in AMR-based KBQA in LC-QuAD (F1 53.4), matching it in QALD (F1 30.8), while exploiting the same inductive biases.

Introduction

Knowledge Base Question Answering (KBQA) involves translating natural language questions (e.g., "What sports are played in Maharashtra?") into structured SPARQL queries for databases like DBpedia or Wikidata. Traditionally, this task faces two major hurdles: data scarcity and brittleness. Mapping human language directly to rigid code requires massive labeled datasets, and rule-based systems often fail when faced with complex logic or novel phrasing.

Researchers at IBM have developed TransQA, a system that addresses these issues by using Abstract Meaning Representation (AMR) as a semantic middleman. By leveraging existing, high-quality AMR parsers, the task shifts from full natural language understanding to "transpiling" a semantic graph into a database query. This approach achieves state-of-the-art performance while requiring significantly less training data.

Methodology: The TransQA Framework

The core of TransQA is a transition-based transpiler that processes an AMR graph step-by-step to generate SPARQL. Instead of a "black box" translation, the system utilizes a state machine driven by a fine-tuned BART model.

Mapping Semantic Constructs

To bridge the gap between semantics and queries, the authors identified specific mapping patterns between AMR and SPARQL constructs. These include mapping unknown variables, Knowledge Graph (KG) entities, and intermediate variables that link different parts of a query.

Mapping patterns between AMR nodes and SPARQL components, including unknown variables (?s), KG entities, and intermediate variables (?i).

Transition-Based Transpilation

The system operates through a series of actions (e.g., generating a SELECT header, identifying a relation, or closing the query) guided by a BART model. A key innovation is the use of constrained cross-attention. Rather than feeding the entire AMR graph into the transformer, the model's attention is masked to focus only on the specific words in the original question that correspond to the current path being processed in the AMR graph. This implicitly encodes the transpiler's state into the attention mechanism.

The TransQA pipeline: a question is parsed into an AMR graph, which is then transpiled into SPARQL through a series of actions guided by BART's encoder-decoder architecture and a path stack.

Constrained Decoding

At inference time, TransQA employs constrained decoding to ensure the model only suggests relations that actually exist in the Knowledge Graph for a given entity. This grounding prevents the model from "hallucinating" non-existent database properties, a common failure mode in purely generative models.

Experimental Setup and Results

The model was evaluated on four major KBQA benchmarks: LC-QuAD 1.0 and QALD-9 (for DBpedia), and WebQSP-WD and SWQ-WD (for Wikidata). The researchers utilized the APT parser for AMR generation and BLINK for entity linking.

TransQA significantly outperformed previous state-of-the-art systems:

  • LC-QuAD 1.0: Achieved a 54.5 F1 score, a 10-point improvement over the previous best (44.5).
  • QALD-9: Reached 31.4 F1, demonstrating robustness on complex, real-world questions.
  • Ablation Studies: Removing constrained decoding led to a performance drop from 56.5 to 46.3 on LC-QuAD, highlighting the importance of grounding the model in the database schema.

Discussion and Insights

TransQA demonstrates that AMR is a powerful intermediate representation that simplifies the learning process by allowing the model to focus on mapping structured representations rather than learning English grammar from scratch. Furthermore, the system provides explainability; because it points to "supporting text" for every generated SPARQL component, it offers a clear audit trail for its decisions.

However, limitations remain. The system's performance is capped by the accuracy of upstream tools like the AMR parser and BLINK. Future work will focus on expanding support for complex SPARQL features (like reified relations), improving schema-visibility for the model, and extending the framework to multilingual contexts.

Summary updated

Abstract

We propose a transition-based system to transpile Abstract Meaning Representation (AMR) into SPARQL for Knowledge Base Question Answering (KBQA). This allows to delegate part of the abstraction problem to a strongly pre-trained semantic parser, while learning transpiling with small amount of paired data. We departure from recent work relating AMR and SPARQL constructs, but rather than applying a set of rules, we teach the BART model to selectively use these relations. Further, we avoid explicitly encoding AMR but rather encode the parser state in the attention mechanism of BART, following recent semantic parsing works. The resulting model is simple, provides supporting text for its decisions, and outperforms recent progress in AMR-based KBQA in LC-QuAD (F1 53.4), matching it in QALD (F1 30.8), while exploiting the same inductive biases.
BibTeX
@misc{bornea2021learning,
  author = {Mihaela Bornea and Ramón Fernandez Astudillo and Tahira Naseem and Nandana Mihindukulasooriya and Ibrahim Abdelaziz and Pavan Kapanipathi and Radu Florian and Salim Roukos},
  title = {{Learning to Transpile AMR into SPARQL}},
  year = {2021},
  eprint = {2112.07877},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2112.07877},
}
Figure