Semantic parsing is the task of mapping natural language utterances to machine-interpretable meaning representations. These representations may be logical forms (lambda calculus expressions, first-order logic), database queries (SQL, SPARQL), programming language code, or domain-specific formalisms (AMR, DCS). Semantic parsing connects the linguistic analysis of meaning to computation: the output of a semantic parser can be executed against a database, knowledge base, or environment to produce an answer or action, making it essential for question answering, task-oriented dialogue, and instruction following.
Approaches and Architectures
Logical form: lambda x. capital(x, France)
SQL: SELECT capital FROM countries WHERE name = 'France'
Execution: → "Paris"
Grammar-based: x → z via synchronous grammar
Seq2seq: z = decoder(encoder(x))
Weakly supervised: z* = argmax_z P(z|x) · 1[execute(z) = y]
Grammar-based semantic parsers use synchronous grammars (CCG, SCFG) that jointly generate the natural language string and its logical form. Zettlemoyer and Collins (2005) learned CCG lexicons for mapping sentences to lambda-calculus expressions. Seq2seq parsers treat semantic parsing as a sequence-to-sequence translation problem, encoding the utterance with a Transformer and decoding the logical form token by token. Constrained decoding ensures the output is well-formed according to the target grammar. In-context learning with large language models has emerged as a competitive approach, with few-shot prompting achieving strong results on SQL generation benchmarks.
Training Paradigms
Semantic parsers can be trained with different levels of supervision. Fully supervised training uses utterance-logical form pairs, which are expensive to annotate. Weakly supervised training uses only the final answer (denotation) as supervision, searching over the space of logical forms that produce the correct answer. This approach, pioneered by Clarke et al. (2010) and refined by Liang et al. (2011), dramatically reduces annotation cost but introduces the challenge of spurious programs -- logically incorrect forms that happen to produce the right answer. Interactive and self-play methods use human feedback or execution feedback to iteratively improve the parser.
Text-to-SQL, the task of translating natural language questions into SQL queries, is the most commercially important application of semantic parsing. The Spider benchmark (Yu et al., 2018) tests generalization to unseen databases with complex queries involving joins, aggregation, and nested subqueries. State-of-the-art systems use schema-linking (connecting question mentions to database columns and tables) combined with Transformer encoders and grammar-constrained decoding. Large language models like GPT-4 and Codex achieve competitive accuracy with few-shot prompting, though they still struggle with complex compositional queries.
Meaning Representations
The choice of meaning representation critically affects semantic parsing. Abstract Meaning Representation (AMR) provides graph-structured representations that abstract away from syntactic variation, capturing semantic roles, coreference, and negation. SQL provides a practical target for database question answering. The Overnight dataset introduced domain-specific representations across eight domains. Lambda DCS (Liang, 2013) simplifies compositional semantics for question answering by using tree-structured logical forms without explicit variables. Each formalism offers different tradeoffs between expressiveness, executability, and learnability.
Current research in semantic parsing focuses on compositional generalization (handling novel combinations of known primitives), cross-database and cross-domain transfer, conversational semantic parsing (interpreting utterances in dialogue context with ellipsis and coreference), and grounding in embodied environments where the parser must map language to robotic actions. The convergence of semantic parsing with large language model capabilities is rapidly advancing the field, with models increasingly able to generate executable code from natural language specifications.