ChatPaper.aiChatPaper

少数ショットは長文脈で機能するか? デモンストレーション生成のための文脈の再利用

Can Few-shot Work in Long-Context? Recycling the Context to Generate Demonstrations

June 19, 2024
著者: Arie Cattan, Alon Jacovi, Alex Fabrikant, Jonathan Herzig, Roee Aharoni, Hannah Rashkin, Dror Marcus, Avinatan Hassidim, Yossi Matias, Idan Szpektor, Avi Caciularu
cs.AI

要旨

大規模言語モデル(LLM)の最近の進展にもかかわらず、長文脈を伴うタスクにおけるその性能は最適とは言えません。このような状況で、Few-shot例を用いたIn-Context Learning(ICL)はLLMの性能を向上させる魅力的な解決策となる可能性があります。しかし、長文脈を含むICL例を単純に追加することは、各Few-shot例に対して大幅なトークンオーバーヘッドが生じるだけでなく、デモンストレーションとターゲットクエリ間の文脈の不一致といった課題を引き起こします。本研究では、長文脈QAタスク向けのFew-shot例を文脈の再利用によって自動生成することを提案します。具体的には、長い入力文脈(1-3kトークン)とクエリが与えられた場合、与えられた文脈から追加のクエリ-出力ペアをFew-shot例として生成し、文脈を一度だけ導入します。これにより、デモンストレーションがターゲットクエリと同じ文脈を活用しつつ、プロンプトに追加されるトークン数を最小限に抑えることができます。さらに、各デモンストレーションを強化するために、モデルに明示的に関連する段落を特定するよう指示し、これにより性能が向上するとともに、回答の出典に対する細かい帰属情報を提供します。本手法を複数のLLMに適用し、長文脈を伴う様々なQAデータセットにおいて、特に回答が文脈の中央にある場合に、大幅な改善(モデル全体で平均+23%)を得ました。驚くべきことに、シングルホップのICL例のみを導入しているにもかかわらず、本アプローチを用いることでLLMはマルチホップの長文脈QAにもうまく汎化することができました。
English
Despite recent advancements in Large Language Models (LLMs), their performance on tasks involving long contexts remains sub-optimal. In-Context Learning (ICL) with few-shot examples may be an appealing solution to enhance LLM performance in this scenario; However, naively adding ICL examples with long context introduces challenges, including substantial token overhead added for each few-shot example and context mismatch between the demonstrations and the target query. In this work, we propose to automatically generate few-shot examples for long context QA tasks by recycling contexts. Specifically, given a long input context (1-3k tokens) and a query, we generate additional query-output pairs from the given context as few-shot examples, while introducing the context only once. This ensures that the demonstrations are leveraging the same context as the target query while only adding a small number of tokens to the prompt. We further enhance each demonstration by instructing the model to explicitly identify the relevant paragraphs before the answer, which improves performance while providing fine-grained attribution to the answer source. We apply our method on multiple LLMs and obtain substantial improvements (+23\% on average across models) on various QA datasets with long context, especially when the answer lies within the middle of the context. Surprisingly, despite introducing only single-hop ICL examples, LLMs also successfully generalize to multi-hop long-context QA using our approach.

Summary

AI-Generated Summary

PDF51November 29, 2024