地平線まで行ってくる。

記録あるいは忘備録。時には検討事項。

メモ:Rag実装してみる。AgentRagだったんだけど・・・。

引き続き、RAG実装で遊んでみます。AgenticRagをChatGPTに読ませて骨子を確認したら、『「Retrieval → Evaluation → Query Refinement → 再検索 → Response Synthesis」という順序が、まさに論文中の処理パイプラインそのものになっています。各フェーズの出力が次フェーズの入力になっているため、DAG(有向非巡回グラフ)としてもきれいに一次元のフローを保っています。と言い張ったので、そのままプロラムをしてみました。もちろん、論文にはもっと有益なことが書かれています。

 

arxiv.org

 

つまり、シンプルな流れで

  1. Query: 入力
  2. Retrieval: 検索
  3. Evaluation: 結果評価
  4. Query Refinement: クエリを改良
  5. Retrieval : 検索
  6. Final Answer:  最終的な結果を返す。

という流れです。これはこれで良さそうなので続けて作りました。

 

Qwenのテクニカルレポート(2,2.5,3)のPDFを利用させて回答をさせました。ollamaで動作させたgemma3:4b-it-qatをLLMとして利用します。

 

Original Query

What is Qwen

この入力がリファインされました。

Refined Query
“Explain what Qwen is, including its different versions like Qwen3 and Qwen2.5, and its key features.”

いい感じですね。最終回答です。

Final Answer
Qwen is the latest version of a large language model family. Qwen3, the most recent iteration, features both thinking and non-thinking modes for dynamic task management. It’s pre-trained on 36 trillion tokens and supports 119 languages. Qwen3 models come in various sizes, including 0.6B, 1.7B, 4B, and 8B parameter versions, and a 235B parameter model. Notably, Qwen3 outperforms larger models like Qwen2.5-14B and DeepSeek-V3 Base on many benchmarks, demonstrating strong performance in areas like code generation, mathematics, and reasoning. Qwen3’s architecture includes dense and Mixture-of-Expert (MoE) models, and it’s designed to be more efficient and cost-effective compared to other models with similar or greater parameter counts.

最終的な答えはQwen3ですが、他の方法だと学習パラメータ数を間違ったりしていたのに対しては良い答えです。

 

github.com