Semantic parsers convert natural language to logical forms, which can be evaluated on knowledge bases (KBs) to produce denotations. Recent semantic parsers have been developed with sequence-to-sequence (seq2seq) pre-trained language models (PLMs) or large language models, where the models treat logical forms as sequences of tokens. For syntactic and semantic validity, the semantic parsers use grammars that enable constrained decoding. However, the grammars lack the ability to utilize large information of KBs, although logical forms contain representations of KB elements, such as entities or relations. In this work, we propose a grammar augmented with candidate expressions for semantic parsing on a large KB with a seq2seq PLM. The grammar defines actions as production rules, and our semantic parser predicts actions during inference under the constraints by types and candidate expressions. We apply the grammar to knowledge base question answering, where the constraints by candidate expressions assist a semantic parser to generate valid KB elements. We also introduce two special rules, sub-type inference and union types, and a mask caching algorithm. In particular, sub-type inference and the mask caching algorithm greatly increase the decoding speed of our semantic parser. We experimented on two benchmarks, KQA Pro and Overnight, where the constraints by candidate expressions increased the accuracy of our semantic parser, whether it was trained with strong supervision or weak supervision. In addition, our semantic parser had a fast decoding speed in the experiments. Our source code is publicly available at https://github.com/daehwannam/candexpr-sp.git.
翻译:语义解析器将自然语言转换为逻辑形式,可在知识库(KB)上求值以生成指称。近年来的语义解析器多基于序列到序列(seq2seq)预训练语言模型(PLM)或大语言模型开发,这些模型将逻辑形式视为词元序列。为确保句法和语义有效性,语义解析器采用支持约束解码的语法。然而,尽管逻辑形式包含知识库元素(如实体或关系)的表示,现有语法却无法充分利用知识库的丰富信息。本研究提出一种增强型语法,通过整合候选表达式,在大型知识库上实现基于seq2seq预训练语言模型的语义解析。该语法将动作定义为产生式规则,我们的语义解析器在类型与候选表达式的双重约束下预测推理动作。我们将此语法应用于知识库问答任务,其中候选表达式的约束能辅助语义解析器生成有效的知识库元素。此外,我们引入两种特殊规则(子类型推断与联合类型)及一种掩码缓存算法。特别地,子类型推断与掩码缓存算法显著提升了语义解析器的解码速度。我们在KQA Pro和Overnight两个基准数据集上进行了实验,结果表明:无论采用强监督还是弱监督训练,候选表达式的约束均能提升语义解析器的准确率。同时,我们的语义解析器在实验中展现出高效解码速度。源代码已公开于https://github.com/daehwannam/candexpr-sp.git。