Unveiling the Black Box of PLMs with Semantic Anchors: Towards Interpretable Neural Semantic Parsing

Lunyiu Nie, Jiuding Sun, Yanlin Wang, Lun Du, Shi Han, Dongmei Zhang, Lei Hou, Juanzi Li, Jidong Zhai

Pretrained Language Models (PLMs) such as T5 and BART have fundamentally changed the landscape of semantic parsing—the process of translating natural language into machine-executable code like SQL or SPARQL. Despite their impressive performance, these models often operate as "black boxes," prone to "hallucinating" logical structures or schema terms that do not exist in the target database. A recent study by researchers from Tsinghua University and Microsoft Research Asia introduces a novel hierarchical decoder architecture that utilizes "Semantic Anchors" to guide these models, enhancing both accuracy and interpretability.

The Challenge: Hallucination and Opacity

Traditional Seq2Seq models treat semantic parsing as a direct text-to-text translation task. This approach overlooks the structural constraints of the underlying database or knowledge base. Consequently, models often suffer from two critical flaws:

  1. Hallucination: Models may generate plausible-sounding but technically incorrect schema items. For instance, a model might use the term product when the database schema specifically requires production_company.
  2. Lack of Interpretability: When a model fails, it is difficult to discern whether the error stemmed from a misunderstanding of the natural language question or a failure to grasp the database schema.
Figure 1: An illustration of the semantic parsing task across relational databases and knowledge bases. The 'Pred. SPARQL' example highlights a common hallucination error where the model incorrectly predicts <product> instead of the correct <production_company> relation.

Proposed Solution: Semantic Anchors

To address these issues, the researchers propose a hierarchical decoder that incorporates intermediate supervision tasks focused on "Semantic Anchors." These anchors are the fundamental building blocks of a query, such as specific entities, relations, tables, or columns. The framework introduces two primary tasks:

  • Semantic Anchor Extraction (SAE): This task requires the model to explicitly identify which schema items from the database are relevant to the user's natural language input.
  • Semantic Anchor Alignment (SAA): This task guides the model to arrange these extracted anchors into their correct relative positions within the final logical form.

Instead of supervising only the final output, the researchers employ a self-adaptive weighting mechanism. This allows the model to determine which of its internal layers are most effective for extraction versus alignment, effectively "unveiling" the latent knowledge stored within the decoder's layers.

Key Insights: Cognitive Mirroring in Decoders

One of the most significant findings of the study is that the model's internal behavior mirrors human logical processing. By probing the decoder, the researchers discovered that lower layers tend to focus on Extraction (understanding and identifying relevant components), while upper layers focus on Alignment (structuring those components into a valid query).

Unlike "post-hoc" correction methods that attempt to fix a query after it has been generated, this hierarchical approach builds structural awareness directly into the model's architecture. This intrinsic awareness significantly reduces the likelihood of the model "drifting" and inventing non-existent schema terms.

Performance and Results

The proposed framework was evaluated on three major benchmarks: OVERNIGHT (multi-domain), KQA Pro (complex multi-hop reasoning), and WikiSQL (Text-to-SQL). The results demonstrated consistent improvements over standard PLM baselines:

  • Accuracy: On the KQA Pro dataset, the BART-based implementation achieved 91.72% execution accuracy, surpassing specialized models like GraphQ IR.
  • Error Reduction: The method led to a substantial decrease in hallucination errors: 5.76% on OVERNIGHT, 10.99% on KQA Pro, and 11.38% on WikiSQL.
  • Efficiency: By integrating structural knowledge during the fine-tuning phase, the model avoids the need for slow, execution-guided decoding strategies often required by other high-performing systems.

Conclusion and Future Directions

By transforming the "black box" of neural semantic parsing into a more transparent "glass box," this research provides a viable path toward more trustworthy AI systems. While the current method relies on mapping text to a provided schema, future work may explore scaling this approach to massive, multi-million-node knowledge graphs where extraction becomes more complex. Additionally, extending this hierarchical logic to other structured outputs, such as general-purpose code generation or mathematical reasoning, remains a promising frontier.

Summary updated

BibTeX
@inproceedings{nie2023unveiling,
  author = {Lunyiu Nie and Jiuding Sun and Yanlin Wang and Lun Du and Shi Han and Dongmei Zhang and Lei Hou and Juanzi Li and Jidong Zhai},
  title = {{Unveiling the Black Box of PLMs with Semantic Anchors: Towards Interpretable Neural Semantic Parsing}},
  booktitle = {AAAI Conference on Artificial Intelligence},
  year = {2023},
  doi = {10.1609/aaai.v37i11.26572},
}
Figure