Chain of Code: Reasoning with a Language Model-Augmented Code Emulator

要約

コードは、コード インタプリタと組み合わせることで、複雑なプログラムを構築し、正確な計算を実行するための一般的な構文構造を提供します。言語モデル (LM) は、コード記述を活用して、論理タスクや算術タスクだけでなく、思考連鎖推論を改善できると仮説を立てています。
セマンティックなもの (特に、両方が混在したもの) の場合。
たとえば、エッセイ内で皮肉を検出した回数をカウントするコードを書くように LM に促すことを検討してください。LM は、インタプリタによって実行できる (エッジ ケースの処理に) ‘detect_sarcasm(string)’ の実装を書くのに苦労するかもしれません。
乗り越えられないでしょう)。
ただし、LM がコードを記述するだけでなく、「detect_sarcasm(string)」の予期される出力を生成することによってインタプリタを選択的に「エミュレート」する場合、LM は依然として有効な解決策を生成する可能性があります。
この研究では、LM コード駆動の推論を改善する、シンプルでありながら驚くほど効果的な拡張機能である Chain of Code (CoC) を提案します。
重要なアイデアは、LM がプログラム内のセマンティック サブタスクを柔軟な疑似コードとしてフォーマットすることを奨励し、インタプリタが未定義の動作を明示的にキャッチして LM でのシミュレーションに (「LMulator」として) 渡すことができるようにすることです。
実験では、コードチェーンがさまざまなベンチマークにわたって思考チェーンやその他のベースラインよりも優れていることが実証されています。
BIG-Bench Hard では、Chain of Code は 84% を達成し、Chain of Thought よりも 12% 向上しました。
一言で言えば、CoC は、LM が「コードで考える」ことで回答できる推論の質問の範囲を広げます。

要約(オリジナル)

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’.

arxiv情報

著者 Chengshu Li,Jacky Liang,Andy Zeng,Xinyun Chen,Karol Hausman,Dorsa Sadigh,Sergey Levine,Li Fei-Fei,Fei Xia,Brian Ichter
発行日 2024-07-29 20:21:37+00:00
arxivサイト arxiv_id(pdf)

提供元, 利用サービス

arxiv.jp, Google

カテゴリー: cs.AI, cs.CL, cs.LG, cs.RO パーマリンク