[論文レビュー] Chain of Code: Reasoning with a Language Model-Augmented Code Emulator
Chain of Code (CoC) は言語モデルにコードを生成させ、コードが実行できない場合にはLMulatorでコード実行を模倣させる。これにより状態を持つ推論を生み出し、BBHタスクでChain of Thoughtを上回り、モデルサイズに応じてスケールする。
Code provides a general syntactic structure to build complex programs and perform precise computations when paired with a code interpreter - we hypothesize that language models (LMs) can leverage code-writing to improve Chain of Thought reasoning not only for logic and arithmetic tasks, but also for semantic ones (and in particular, those that are a mix of both). For example, consider prompting an LM to write code that counts the number of times it detects sarcasm in an essay: the LM may struggle to write an implementation for "detect_sarcasm(string)" that can be executed by the interpreter (handling the edge cases would be insurmountable). However, LMs may still produce a valid solution if they not only write code, but also selectively "emulate" the interpreter by generating the expected output of "detect_sarcasm(string)". In this work, we propose Chain of Code (CoC), a simple yet surprisingly effective extension that improves LM code-driven reasoning. The key idea is to encourage LMs to format semantic sub-tasks in a program as flexible pseudocode that the interpreter can explicitly catch undefined behaviors and hand off to simulate with an LM (as an "LMulator"). Experiments demonstrate that Chain of Code outperforms Chain of Thought and other baselines across a variety of benchmarks; on BIG-Bench Hard, Chain of Code achieves 84%, a gain of 12% over Chain of Thought. In a nutshell, CoC broadens the scope of reasoning questions that LMs can answer by "thinking in code".
研究の動機と目的
- 意味論的および数値的タスクに対処するために、コードベースの推論と言語モデル推論を組み合わせる必要性を動機づける。
- Chain of Code (CoC) を2段階のプロセスとして提案する:コード生成と実行(インタプリタを介して)または実行が失敗した場合のLMulatorシミュレーション。
- Pythonの実行とLMベースのシミュレーションを交互に行うことが、さまざまなタスクで性能を向上させることを示す。
- モデルサイズを超えてスケーラブルであることを示し、汎用推論の指標としてクロスタスク prompting を評価する。
提案手法
- LMはまず、部分問題を構成するために、コード、疑似コード、または自然言語の形式で推論を生成する。
- 可能な場合はPythonインタプリタを用いて行ごとにコード実行を行う。そうでない場合はLMulatorが未解決の行の実行効果を模倣する。
- 各行の実行または模倣の後に共有プログラム状態が更新され、コードとLM出力の交互実行を可能にする。
- LMulatorはコード実行が失敗した場合に、中間状態の迹を生成するためにLM自身の推論(場合によってはChain-of-Thoughtを使用)を活用する。
- このアプローチは、BBHタスクおよびGSM8Kにおいて、Direct QAやChain of Thoughtを含むベースラインと比較して評価され、要素を分離するための複数のアブレーション(例:Pythonのみ、LMのみ、LM状態など)を実施する。
実験結果
リサーチクエスチョン
- RQ1CoCは、基準手法と比較して、多様な難易度の高い推論タスク全体でどのように性能を示すか。
- RQ2どのタスクタイプ(アルゴリズム的、意味的、混合)の恩恵がCoCから最も大きいか。
- RQ3各CoC成分(Python実行、LMulation、交互実行)が性能に与える影響はどれか。
- RQ4CoCはモデルサイズとクロスタスク promptingによる一般的な推論能力としてのスケーリングはどうなるか。
- RQ5ツールの有無に関係なく、命令チューニング済みのチャットモデルと比較してCoCはどうか。
主な発見
- CoCはBIG-Bench Hardで84%を達成し、総合的にChain of Thoughtを上回り、いくつかのタスクで人間ベースラインをも上回る。
- Python有効化されたCoCの派生は、コードが実行可能な場合には複数のタスクでほぼ100%に達するか、または100%に達する。LMulator駆動の派生は、コードの実行が難しい意味的タスクを可能にする。
- CoCはアルゴリズム的タスクと意味的タスクの双方でベースラインを上回り、モデルサイズとともにスケールし、小型モデルにも改善が見られる。
- CoCを用いたクロス・タスク prompting は競争力を維持し、スケール時には人間の性能に近づく。汎用的推論器としての潜在を示す。
- アブレーションは、インタプリタ実行とLMベースのシミュレーションを交互に行い、プログラム状態を維持することが最高性能のために極めて重要であることを示す。
より良い研究を、今すぐ始めましょう
論文設計から論文執筆まで、研究時間を劇的に削減しましょう。
クレジットカード登録不要
このレビューはAIが作成し、人間の編集者が確認しました。