
Unveiling the Black Box of PLMs with Semantic Anchors:
Towards Interpretable Neural Semantic Parsing
Lunyiu Nie1*†, Jiuding Sun1*, Yanlin Wang2‡, Lun Du3,
Lei Hou1, Juanzi Li1, Shi Han3, Dongmei Zhang3, Jidong Zhai1
1Department of Computer Science and Technology, Tsinghua University
2School of Software Engineering, Sun Yat-sen University 3Microsoft Research Asia
{nlx20, sjd22}@mails.tsinghua.edu.cn, wangylin36@mail.sysu.edu.cn,
{lun.du, shihan, dongmeiz}@microsoft.com, {houlei,lijuanzi, zhaijidong}@tsinghua.edu.cn
Abstract
The recent prevalence of pretrained language models (PLMs)
has dramatically shifted the paradigm of semantic parsing,
where the mapping from natural language utterances to struc-
tured logical forms is now formulated as a Seq2Seq task. De-
spite the promising performance, previous PLM-based ap-
proaches often suffer from hallucination problems due to
their negligence of the structural information contained in
the sentence, which essentially constitutes the key seman-
tics of the logical forms. Furthermore, most works treat PLM
as a black box in which the generation process of the target
logical form is hidden beneath the decoder modules, which
greatly hinders the model’s intrinsic interpretability. To ad-
dress these two issues, we propose to incorporate the cur-
rent PLMs with a hierarchical decoder network. By taking the
first-principle structures as the semantic anchors, we propose
two novel intermediate supervision tasks, namely Semantic
Anchor Extraction and Semantic Anchor Alignment, for train-
ing the hierarchical decoders and probing the model inter-
mediate representations in a self-adaptive manner alongside
the fine-tuning process. We conduct intensive experiments on
several semantic parsing benchmarks and demonstrate that
our approach can consistently outperform the baselines. More
importantly, by analyzing the intermediate representations of
the hierarchical decoders, our approach also makes a huge
step toward the intrinsic interpretability of PLMs in the do-
main of semantic parsing.
1 Introduction
Semantic parsing refers to the task of converting natural
language utterances into machine-executable logical forms
(Kamath and Das 2019). With the rise of pretrained lan-
guage models (PLMs) in natural language processing, most
recent works in the field formulate semantic parsing as a
Seq2Seq task and develop neural semantic parsers on top of
*These authors contributed equally.
†Work done during internship at Microsoft Research Asia.
‡Yanlin Wang is the corresponding author. Work done during
the author’s employment at Microsoft Research Asia.
Copyright © 2023, Association for the Advancement of Artificial
Intelligence (www.aaai.org). All rights reserved.
the latest PLMs like T5 (Raffel et al. 2020), BART (Lewis
et al. 2020), and GPT-3 (Brown et al. 2020), which sig-
nificantly reduces the manual effort needed in designing
compositional grammars (Liang, Jordan, and Klein 2011;
Zettlemoyer and Collins 2005). By leveraging the extensive
knowledge learned from the pretrain corpus, these PLM-
based models exhibit strong performance in comprehending
the semantics underlying the source natural language utter-
ance and generating the target logical form that adheres to
specific syntactic structures (Shin and Van Durme 2022; Yin
et al. 2022).
Despite the promising performance, current PLM-based
approaches most regard both input and output as plain text
sequences and neglect the structural information contained
in the sentences (Yin et al. 2020; Shi et al. 2021), such as
the database (DB) or knowledge base (KB) schema that es-
sentially constitutes the key semantics of the target SQL or
SPARQL logical forms. As a result, these PLM-based mod-
els often suffer from the hallucination issue (Ji et al. 2022)
and may generate incorrect logical form structures that are
unfaithful to the input utterance (Nicosia, Qu, and Altun
2021; Gupta et al. 2022). For example, as shown in Figure 1,
the PLM mistakenly generates a relationship “product” in
the SPARQL query, which is contradictory to the “company
produced” mentioned in the natural language.
To prevent the PLMs from generating hallucinated struc-
tures, many works propose execution-guided decoding
strategies (Wang et al. 2018; Wang, Lapata, and Titov 2021;
Ren et al. 2021) and grammar-constrained decoding algo-
rithms (Shin et al. 2021; Scholak, Schucher, and Bahdanau
2021). However, manipulating the decoding process with
conditional branches can significantly slow down the model
inference (Post and Vilar 2018; Hui et al. 2021). More im-
portantly, in these methods, the DB/KB schema is employed
extrinsically as a posteriori correction afterward the model
fine-tuning, whereas the inherent ignorance of logical form
structures still remains unsolved in the PLMs.
Therefore, another concurrent line of work further
pretrains the PLMs with structure-augmented objectives
(Herzig et al. 2020; Deng et al. 2021). Specifically, these
arXiv:2210.01425v2 [cs.CL] 4 Dec 2022