Skip to main content
QUICK REVIEW

[論文レビュー] WatChat: Explaining perplexing programs by debugging mental models

Kartik Chandra, Collins, Katherine M.|arXiv (Cornell University)|Mar 8, 2024
Software Engineering ResearchComputer Science被引用数 3
ひとこと要約

WatChat は、JavaScript プログラムの予期しない振る舞いを、言語の意味論に関するユーザーの誤った理解を診断・是正することで説明するシステムである。逆プログラム合成を用いて誤ったメンタルモデルを推定し、対照的で因果的かつ社会的に適切な説明を生成する。`[] + []` が "" を返すような驚きの振る舞いの説明において、有効性を示している。

ABSTRACT

Often, a good explanation for a program's unexpected behavior is a bug in the programmer's code. But sometimes, an even better explanation is a bug in the programmer's mental model of the language or API they are using. Instead of merely debugging our current code ("giving the programmer a fish"), what if our tools could directly debug our mental models ("teaching the programmer to fish")? In this paper, we apply recent ideas from computational cognitive science to offer a principled framework for doing exactly that. Given a "why?" question about a program, we automatically infer potential misconceptions about the language/API that might cause the user to be surprised by the program's behavior -- and then analyze those misconceptions to provide explanations of the program's behavior. Our key idea is to formally represent misconceptions as counterfactual (erroneous) semantics for the language/API, which can be inferred and debugged using program synthesis techniques. We demonstrate our framework, WatChat, by building systems for explanation in two domains: JavaScript type coercion, and the Git version control system. We evaluate WatChatJS and WatChatGit by comparing their outputs to experimentally-collected human-written explanations in these two domains: we show that WatChat's explanations exhibit key features of human-written explanation, unlike those of a state-of-the-art language model.

研究の動機と目的

  • コードのバグによるものではなく、言語の意味論に関する誤った理解モデルによって引き起こされる予期しない振るまいを説明するプログラミングツールの欠落を埋めるため。
  • ユーザーの誤解を反事後的意味論としてモデル化することで、人間らしい役立つ説明を生成するシステムを設計すること。
  • 誤解の診断に役立つ説明生成と教育的例の合成を両立するフレームワークを構築すること。
  • 対照性、選択性、因果性、社会的文脈といった認知科学の原則を、プログラミング向けの自動説明システムに統合すること。
  • プログラミング環境が受動的なデバッグツールではなく、協働的で認知的パートナーとして機能できるようにすること。

提案手法

  • JavaScript の意味論に関する誤った解釈を表す反事後的意味論として、ユーザーのメンタルモデルをモデル化する。
  • 逆プログラム合成を適用し、プログラムが予期しない振るまいを示すような妥当な誤解(すなわち「誤解を引き起こすもの」)を推定する。
  • これらの反事後的意味論におけるバグを特定・是正することで説明を生成し、対照的で選択的な説明の認知科学的原則に一致させる。
  • JavaScript 意味論の形式的定義とシンボリック実行エンジン(Rosette)を用い、2^32 個の潜在的誤解の空間をミリ秒未塔で効率的に探索する。
  • 説明プロセスを逆転させ、学習者の特定の誤解をテスト・是正できる診断用のプログラム例を合成する。
  • ユーザーの期待(例:「空の配列を予想しましたか?」)を尋ねることで、文脈に応じた説明生成を実現し、適応的で会話的な相互作用を可能にする。
Figure 1: System overview. Panel “A” shows WatChat’s model of how programmers come to ask “why?” questions. Panel “B” shows how an explainer reasons over the model in Panel “A” to find a good explanation.
Figure 1: System overview. Panel “A” shows WatChat’s model of how programmers come to ask “why?” questions. Panel “B” shows how an explainer reasons over the model in Panel “A” to find a good explanation.

実験結果

リサーチクエスチョン

  • RQ1プログラミングツールは、コードの修正ではなく、言語の意味論に関するユーザーの誤った理解の診断と是正によって、予期しない振るまいをどのように説明できるか?
  • RQ2対照性、選択性、因果性といった認知的原則は、プログラミング環境における人間らしい説明の生成をどのように導くか?
  • RQ3プログラム合成技術を逆転させることで、プログラミング言語の振るまいに関する誤った理解モデルを推定・デバッグすることは可能か?
  • RQ4このようなシステムは、特定の誤解を標的とした教育的に有用な診断例をどれほど効果的に生成できるか?
  • RQ5説明システムは、ユーザーの期待や背景に応じて、どのように文脈に応じて適応的かつ社会的に適合するように設計できるか?

主な発見

  • WatChat は、型変換や配列から文字列への変換に関する誤解を特定・是正することで、`[] + []` が "" を返すような驚きの JavaScript 振るまいを推定・説明できる。
  • システムは 2^32 個の潜在的メンタルモデルの空間を 1 ミリ秒未塔で探索でき、リアルタイムの説明生成を可能にする。
  • WatChat が生成する説明は対照的で選択的であり、期待と実際の振るまいの主な差異(例:配列の文字列化における括弧の不在)に焦点を当てる。
  • ユーザーの出力予想を尋ねることで、期待をモデル化し、適応的で会話的なメンタルモデルのデバッグを可能にする。
  • このフレームワークは逆転可能であり、配列の連結や文字列変換の誤解といった特定の誤解を標的とした高精度な教育的例を生成できる。
  • WatChat は、GPT-4 などのベースライン LLM よりも説明の質が優れており、対照的で因果的かつ社会的に適切な説明を生成し、冗長または誤ったステップバイステップのトレースを避ける。
Figure 2: WatChat’s user interface. The user enters an expression in a REPL, which offers a “WAT?” button alongside the output. When clicked, WatChat clarifies what the user expected, and offers an explanation. Panel “B” shows a case where multiple possible explanations were found. (The dialogs are
Figure 2: WatChat’s user interface. The user enters an expression in a REPL, which offers a “WAT?” button alongside the output. When clicked, WatChat clarifies what the user expected, and offers an explanation. Panel “B” shows a case where multiple possible explanations were found. (The dialogs are

この論文を読む

Nubintのビューアで原文を開き、読みながら気になる箇所をすぐに質問できます。

Nubintでこの論文を読む

このレビューはAIが論文の原文をもとに作成しました。引用する前に原文をご確認ください。