Representing Rule-based Chatbots with Transformers

Dan Friedman, Abhishek Panigrahi, Danqi Chen
7/15/2024
cs.CLcs.AIcs.LG

No official code found. Best implementation: princeton-nlp/ELIZA-Transformer (23 stars, MIT, last commit 2025-02-09).

Abstract

What kind of internal mechanisms might Transformers use to conduct fluid, natural-sounding conversations? Prior work has illustrated by construction how Transformers can solve various synthetic tasks, such as sorting a list or recognizing formal languages, but it remains unclear how to extend this approach to a conversational setting. In this work, we propose using ELIZA, a classic rule-based chatbot, as a setting for formal, mechanistic analysis of Transformer-based chatbots. ELIZA allows us to formally model key aspects of conversation, including local pattern matching and long-term dialogue state tracking. We first present a theoretical construction of a Transformer that implements the ELIZA chatbot. Building on prior constructions, particularly those for simulating finite-state automata, we show how simpler mechanisms can be composed and extended to produce more sophisticated behavior. Next, we conduct a set of empirical analyses of Transformers trained on synthetically generated ELIZA conversations. Our analysis illustrates the kinds of mechanisms these models tend to prefer--for example, models favor an induction head mechanism over a more precise, position-based copying mechanism; and using intermediate generations to simulate recurrent data structures, akin to an implicit scratchpad or Chain-of-Thought. Overall, by drawing an explicit connection between neural chatbots and interpretable, symbolic mechanisms, our results provide a new framework for the mechanistic analysis of conversational agents.

View on arXivView PDF

Code Implementations(1)

MIT

[NAACL 2025] Representing Rule-based Chatbots with Transformers

234Shell, PythonJul 11, 20241 years agoMIT

Similar Papers

Cite this paper

@article{friedman2024representing,
  title  = {Representing Rule-based Chatbots with Transformers},
  author = {Dan Friedman and Abhishek Panigrahi and Danqi Chen},
  year   = {2024},
  eprint = {2407.10949},
  archivePrefix = {arXiv},
  url    = {http://arxiv.org/abs/2407.10949v2}
}

Add a badge to your README

Shows whether official code is linked for this paper.

Code of Paper badge
[![Code of Paper](https://codeofpaper.com/badge/2407.10949.svg)](https://codeofpaper.com/paper/2407.10949)

Discussion