DSPy: Compiling Declarative Language Model Calls into Self-Improving Pipelines

要約

ML コミュニティは、言語モデル (LM) をプロンプトし、複雑なタスクを解決するパイプラインに言語モデルをスタックするための技術を急速に研究しています。
残念なことに、既存の LM パイプラインは通常、ハードコーディングされた「プロンプト テンプレート」、つまり試行錯誤によって発見された長い文字列を使用して実装されています。
LM パイプラインの開発と最適化のためのより体系的なアプローチに向けて、LM パイプラインをテキスト変換グラフ、つまり LM が宣言モジュールを通じて呼び出される命令型計算グラフとして抽象化するプログラミング モデルである DSPy を紹介します。
DSPy モジュールはパラメータ化されており、プロンプト、微調整、拡張、および推論技術の組み合わせを適用する方法を (デモンストレーションを作成および収集することによって) 学習できることを意味します。
特定のメトリックを最大化するために DSPy パイプラインを最適化するコンパイラーを設計します。
私たちは 2 つのケーススタディを実施し、簡潔な DSPy プログラムが、数学の文章問題を推論し、マルチホップ検索に取り組み、複雑な質問に答え、エージェント ループを制御する高度な LM パイプラインを表現および最適化できることを示します。
コンパイルから数分以内に、DSPy の数行により、GPT-3.5 および llama2-13b-chat が標準の少数ショット プロンプト (通常、それぞれ 25% および 65% 以上) および専門家が作成したパイプラインよりも優れたパフォーマンスを発揮するパイプラインを自己ブートストラップできるようになります。
デモンストレーション(それぞれ最大 5 ~ 46% および 16 ~ 40%)。
その上、770M パラメータ T5 や llama2-13b-chat のようなオープンで比較的小規模な LM にコンパイルされた DSPy プログラムは、独自の GPT-3.5 用に専門家が作成したプロンプト チェーンに依存するアプローチと競合します。
DSPy は https://github.com/stanfordnlp/dspy で入手できます。

要約(オリジナル)

The ML community is rapidly exploring techniques for prompting language models (LMs) and for stacking them into pipelines that solve complex tasks. Unfortunately, existing LM pipelines are typically implemented using hard-coded ‘prompt templates’, i.e. lengthy strings discovered via trial and error. Toward a more systematic approach for developing and optimizing LM pipelines, we introduce DSPy, a programming model that abstracts LM pipelines as text transformation graphs, i.e. imperative computational graphs where LMs are invoked through declarative modules. DSPy modules are parameterized, meaning they can learn (by creating and collecting demonstrations) how to apply compositions of prompting, finetuning, augmentation, and reasoning techniques. We design a compiler that will optimize any DSPy pipeline to maximize a given metric. We conduct two case studies, showing that succinct DSPy programs can express and optimize sophisticated LM pipelines that reason about math word problems, tackle multi-hop retrieval, answer complex questions, and control agent loops. Within minutes of compiling, a few lines of DSPy allow GPT-3.5 and llama2-13b-chat to self-bootstrap pipelines that outperform standard few-shot prompting (generally by over 25% and 65%, respectively) and pipelines with expert-created demonstrations (by up to 5-46% and 16-40%, respectively). On top of that, DSPy programs compiled to open and relatively small LMs like 770M-parameter T5 and llama2-13b-chat are competitive with approaches that rely on expert-written prompt chains for proprietary GPT-3.5. DSPy is available at https://github.com/stanfordnlp/dspy

arxiv情報

著者 Omar Khattab,Arnav Singhvi,Paridhi Maheshwari,Zhiyuan Zhang,Keshav Santhanam,Sri Vardhamanan,Saiful Haq,Ashutosh Sharma,Thomas T. Joshi,Hanna Moazam,Heather Miller,Matei Zaharia,Christopher Potts
発行日 2023-10-05 17:37:25+00:00
arxivサイト arxiv_id(pdf)

提供元, 利用サービス

arxiv.jp, Google

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