勉強にとRAG実装を味見できるようにしたので、続けてトライします。LLMにはollamaを介してgemma3:4b-it-qatを利用します。このまま、GPT-4.1使っても動作するように準備しています。ローカルLLMの方で気楽に挑戦します。
今回はこの論文を参考にRAGを作ってみます。
”Retrieval-Augmented Generation with Conflicting Evidence”
Han Wang Archiki Prasad Elias Stengel-Eskin Mohit Bansal
retrieved documentsにしばしば含まれる対立した情報の解決にマルチエージェントを利用する方法です。誤情報やノイズをエージェントに議論させます。それを数ラウンド回して答えを得るというものです。
この時、エージェントに個性を持たせておいて、retrieved documentsはそれぞれのdocumentを各エージェントが一回は解釈するようにプログラムします。論文そのままを作りこむのは大変なので、簡略化して実装します。
- retrieved documentsを収得する
- それぞれのAgentにdocumentsを割り当て議論。
- 議論の結果から有益な情報をまとめる。
- 2,3を繰り返してAgentがすべてのdocumentsを見るようにする。
- 最終的な答えをとりまとめる。
Qwen2,2,5, 3のテクニカルレポートをpdfの中に混ぜておいて以下のような問と答えが得られました。
Query: What is Qwen3?
Final Answer
Summary: Qwen3 is a collection of open-weight large language models (LLMs) with parameters ranging from 0.6 billion to 235 billion, utilizing both dense and Mixture-of-Experts (MoE) architectures, and operating in ‘thinking’ and ‘non-thinking’ modes. It was pre-trained on 36 trillion tokens across 119 languages and dialects.Explanation: The agents converge on several key aspects of Qwen3. All agree it's a collection of LLMs. Parameter ranges consistently state 0.6 billion to 235 billion. Most importantly, they all confirm the use of Mixture-of-Experts (MoE) architectures, ‘thinking’ and ‘non-thinking’ modes, and a significant training dataset (36 trillion tokens) across 119 languages. The fact that it's open-weight is also confirmed by multiple agents. Therefore, the final answer combines the most consistent and salient details.
この問いには、しっかり答えてくれました。各ラウンドの答えの差もあまりなかったので、この方法じゃなくてもいい感じでしょうか。
What is Qwen?
Final Answer
Summary: Qwen is an open-weight series of large language models (LLMs), including Qwen3, pre-trained on over 7 trillion tokens and designed for various applications.Explanation: The agents provide several confirmations of Qwen's core characteristics. Multiple agents (1, 2, 4, 6, 8, 9, 10) state it's a series of LLMs. Agent 1 corrects the token count from 7 trillion to over 7 trillion. Agent 4 and 8 specify it’s ‘dense.’ Agent 9 notes it’s a ‘foundation model family’. Considering all statements, the most accurate and comprehensive summary is that Qwen is an open-weight series of LLMs, pre-trained on a substantial amount of data (over 7 trillion tokens), built for diverse applications, and represents a significant step in the LLM landscape.
Qwen3は36trilliontokensを学習させているので、7 trillion tokensとするのは間違いですが、エージェントがover 7 trillionと訂正させていてかろうじて間違いを回避しています(笑)確かに多角的な分析がプラスに働いているように見えます。
retrieved documentsはchunkした細切れの文章です。情報の対立と云うより意味が通らない時もあるでしょう。そんな時には、こんな簡単な実装でも一定の効果がありそうです。ただ、context lengthが長いモデルが増えてきています。各社のAPIであれば結構なcontext lengthが確保できます。その場合は、retrieved documentsをざっくり各Agentsに投入し、評価させて議論させてしまう方が手っ取り早そうです。従来のMuti-Agentと変わらないようになりますが、対立した情報の取捨選択をプロンプトに入れつつ、各エージェントの性格付けをすることで、対ノイズ性を向上させることができるのではと考えました。
と、楽しく考えてみました。
今回作成したもの