Memory-Based Semantic Parsing

Parag Jain, Mirella Lapata

In the world of Natural Language Processing (NLP), "semantic parsing"—the art of turning a human sentence like "Show me flights to Chicago" into a machine-readable SQL query—is a well-studied problem. However, most models treat every question as if it were asked in a vacuum. In reality, human conversation is a thread: we ask a question, get an answer, and then follow up with "What about before noon?" or "Are any on United?"

A recent paper from Parag Jain and Mirella Lapata at the University of Edinburgh, titled "Memory-Based Semantic Parsing," introduces a novel way to handle these multi-turn interactions by giving the parser a dedicated, manageable "working memory."

TL;DR

This paper introduces MemCE, a model that uses an external memory matrix and a specialized controller to track context across multi-turn conversations. Instead of just "copying" previous SQL queries, MemCE maintains a persistent representation of the conversation's meaning, leading to state-of-the-art performance on complex text-to-SQL benchmarks like ATIS, SParC, and CoSQL.

What Problem Does This Paper Address?

Most existing text-to-SQL models struggle with context-dependency. In a dialogue, users frequently use:

  • Ellipsis: Omitting information mentioned earlier (e.g., "Before noon?" instead of "Show me flights to Chicago before noon?").
  • Coreference: Using pronouns like "they" or "those" to refer to previously mentioned entities.
  • Focus Shifts: Changing the constraints of a search (e.g., changing the destination from Seattle to Chicago).

Previous approaches tried to solve this by allowing the decoder to "copy" or "edit" the SQL query from the immediate previous turn. The authors argue this is too limited. Context isn't just the last thing said; it’s a cumulative "gist" of the entire interaction. They sought a way to represent this evolving context explicitly without relying on task-specific "copy-paste" hacks.

Methods

The authors propose the Memory-based ContExt (MemCE) model. Its architecture consists of four main parts:

  1. Utterance Segmentation: Inspired by cognitive psychology, the model doesn't just look at raw tokens. It breaks sentences into "phrases" (propositions) using a chunker and a set of rules. For example, "flights from Chicago to Seattle" becomes distinct units: [flights], [from Chicago], [to Seattle].
  2. The Memory Matrix: An external matrix where each row (slot) stores a piece of contextual information.
  3. The Memory Controller: This is the "brain" of the system. For every new phrase, the controller uses a Siamese network to calculate similarity with existing memory slots.
  4. If a phrase provides new information, the controller finds an empty or least-used slot to store it.
  5. If a phrase conflicts with old information (e.g., changing "before 10am" to "before noon"), the controller updates the specific slot containing the old constraint.
  6. The Decoder: A standard LSTM decoder that uses an attention mechanism to look at both the current utterance and the memory matrix to generate the final SQL.

Datasets

The model was evaluated on three major semantic parsing benchmarks:

  • ATIS (Airline Travel Information System): Known for long, complex interactions (average 7 turns) focused on flight bookings.
  • SParC: A cross-domain dataset for complex, multi-turn text-to-SQL.
  • CoSQL: A conversational version of the popular Spider dataset, including clarification questions and dialogue-centric interactions.

The authors also introduced a specific split called SParC-DI to test domain-independent performance, ensuring the model wasn't just memorizing specific database schemas.

Key Insights and Ideas

  • Granularity Matters: One of the most interesting findings was that phrase-level segmentation outperformed both token-level and full-sentence processing. Tokens are too noisy; full sentences are too coarse. Phrases hit the "Goldilocks zone" for updating memory.
  • Explicit Conflict Resolution: By using a similarity module to detect conflicts, the model mimics human "belief updating." It doesn't just add more data; it actively replaces outdated constraints, which is crucial for handling "Focus Shifts."
  • Interpretability: Unlike "black box" neural models, MemCE’s memory is somewhat inspectable. The authors could visualize which slots held which constraints (e.g., "from Chicago" in Slot 2) and see exactly when the controller decided to overwrite them.

Key Results

MemCE consistently outperformed strong baselines across all datasets:

  • ATIS: Achieved 69.8% strict denotation accuracy on the test set, outperforming previous state-of-the-art models like HE-SnipCopy (69.2%) and HE-EditBased (68.1%).
  • SParC & CoSQL: The model showed significant gains in "Interaction Accuracy"—a metric that requires every single turn in a conversation to be parsed correctly. On the SParC-DI split, it improved interaction accuracy by over 6% compared to standard hierarchical encoders.
  • Qualitative Success: Analysis showed the model was particularly adept at handling "Focus Shifts" (80.4% accuracy) and "Ellipsis" (69.4% accuracy), areas where traditional models often fail.

Limitations and Future Work

While powerful, the authors noted a few areas for improvement:

  • Heuristic Segmentation: The current model relies on a fixed set of regex rules and a pre-trained chunker to segment phrases. A fully learned, end-to-end segmentation module might be more flexible.
  • Rigid Updates: The memory management can sometimes be too "all-or-nothing." If a user provides a very fine-grained update, the controller might overwrite more info than intended.
  • Scaling: While it works well for flight bookings and database queries, scaling this to open-domain conversation with massive amounts of context remains a challenge.

In summary, MemCE proves that for machines to truly understand us, they don't just need to listen to what we just said—they need a reliable way to remember what we've been talking about all along.

Summary updated

BibTeX
@article{jain2021memory,
  author = {Parag Jain and Mirella Lapata},
  title = {{Memory-Based Semantic Parsing}},
  journal = {Trans. Assoc. Comput. Linguistics},
  year = {2021},
  doi = {10.1162/tacl\_a\_00422},
}

Loading related content...

Figure