In plain words: A language model writing SQL is checked token by token by a parser that rejects any word that would break valid code, so only legal code can come out. Applied to a fine-tuned text-to-SQL model, this turned middling results into the best reported ones.
Abstract · PICARD: Parsing Incrementally for Constrained Auto-Regressive Decoding from Language Models
Large pre-trained language models for textual data have an unconstrained output space; at each decoding step, they can produce any of 10,000s of sub-word tokens. When fine-tuned to target constrained formal languages like SQL, these models often generate invalid code, rendering it unusable. We propose PICARD (code and trained models available at https://github.com/ElementAI/picard), a method for constraining auto-regressive decoders of language models through incremental parsing. PICARD helps to find valid output sequences by rejecting inadmissible tokens at each decoding step. On the challenging Spider and CoSQL text-to-SQL translation tasks, we show that PICARD transforms fine-tuned T5 models with passable performance into state-of-the-art solutions.
Torsten Scholak, Nathan Schucher, Dzmitry Bahdanau
arXiv:2109.05093 · cs.CL, cs.PL · submitted Sep 10, 2021
abstract · pdf · html · Accepted to EMNLP 2021. 7 pages