ナレッジエージェント:構造の改善で最先端モデルを凌駕する(18 分読)
TLDR AI は、単なる推論能力の向上ではなく「構造化」こそが次世代モデルを凌駕する鍵であると指摘し、知識エージェントの実装戦略を詳述している。
キーポイント
構造化による性能向上
Frontier モデル(最先端モデル)との差は推論能力だけでなく、タスクの分解や状態管理といった「構造化」によって決定されるという主張。
知識エージェントの定義
単なるチャットボットではなく、長期記憶、計画立案、外部ツール連携を自律的に行う能動的なシステムとしてのエージェントへの移行が不可欠である。
実装戦略とアーキテクチャ
モノリス型のプロンプトから脱却し、明確な役割分担を持つ複数のサブエージェントや、状態遷移図に基づく制御フローの導入を推奨している。
影響分析・編集コメントを表示
影響分析
この記事は、LLM のベンチマークスコア競争から、実世界でのタスク遂行能力(構造化と自律性)へのパラダイムシフトを告げる重要な示唆を含んでいます。開発者やアーキテクトに対し、単なるプロンプトエンジニアリングの限界を超え、システム設計レベルでエージェントを構築する必要性を強く認識させる内容です。
編集コメント
最先端モデルの性能差が縮まる中、実装アーキテクチャの質が勝敗を分けるという本質的な指摘は、開発者にとって極めて示唆に富んでいます。
Anthropic は最近、米国政府の命令により Mythos/Fable を撤回せざるを得なくなりました。Mythos は Opus よりも一段階上でしたが、私はエージェントモデルにおいてむしろ「小さく」する方向へ積極的に移行しており、一部の最大規模のフロンティアモデルと同等の出力品質を達成しています。
使用例は、「ヘッジファンドレベル」(より適切な表現が見つからないためこのように表現します)の市場分析や財務管理、AI パーソナルアシスタントといった難易度の高いものから、困難な医療状況にある友人たちを支援するに至るまで多岐にわたります。私はこのパターンを「ナレッジエージェント」と呼び、誰でも利用可能な汎用テンプレート を用意しています。これは AI エージェントに適切な知識を literally 注入する仕組みです。私のテンプレートがなくても、誰にでもこれを実行できます。
私の README が誇らしげに宣言している通り(はい、私は間違いなく AI にドキュメント作成を任せています—あなたは包括的な技術ドキュメントの作成が好きですか?):
**この手法は、市場におけるジェームズ・ワングの思考プロセスを再現することを目的とした「市場知識エージェント」の開発および実戦テストを通じて確立されました。約 10,000 ページに及ぶスキャンされた金融市場の参考資料と約 100 のウェブ記事を用い、ハイブリッド BM25(BM25)+セマンティック検索(semantic search)により、381 の概念ドキュメントおよび 54 の論文ドキュメントを生成しました。さらにこの手法は、企業固有のポリシー文書(「企業知識エージェント」用)やジェームズの背景に由来する希少研究分野(女性の性健康など)といった他の専門知識領域でもテストされ、大きな成果を上げました。ここで紹介する一般化されたバージョンは、ドメインに依存しない手法として記述されており、あらゆる主題に応用可能です。
これらは最初の試みでしたが、現時点では私には他エージェントからの問い合わせや、私自身からの問い合わせに対応できる 12 の専門「知識エージェント」が存在します。あるいはもちろん、私自身が直接利用することもできます。新しい機能をコーディングする際、特に専門知識を要する場合、私は新規フォルダを作成する代わりに、*知識エージェント用のフォルダ内で Claude Code を起動*し、その中に含まれる専門知識を活用して計画を立てます。特に特殊な機械学習アルゴリズムや経済モデルにおいては、「ドメインに依存しない」モデル—even a really big frontier model(非常に大規模な最先端モデル)—を用いる場合よりも、この方法によって*はるかに優れた結果*を得られます。
読者の方々から、インフォグラフィックが有用であるというフィードバックをいただきました。これはおそらく自明のことのように思えますが、もしお気に召すようであれば、ぜひお知らせください!
一般的に、私はこれらのナレッジエージェントの「ハネス」(この AI の周囲にある「超構造」を説明する一つの表現) で Claude Opus を使用してきました。つまり、非常に大きなモデルに、ハネスから注入された知識を組み合わせているのです。しかし、はるかに小さなモデルでも、非常に優れた結果が得られることがわかりました。LLM は単なる「エンジン」であり、すべての専門知識は私のナレッジエージェントシステムから提供され、必要なタイミングで関連する知識を提示します。
もちろん、「関連性」が鍵です。ご存知の通り、10,000 ページものドキュメントをチャットウィンドウにドラッグ&ドロップしてはいけません。仮にそれができたとしても、LLM が無関係な情報の洪水に飲み込まれ、混乱するだけです。実際には、プラットフォームがそれを許可する場合でも、コンテキスト容量の限界に達し、回答を得ることはできないでしょう。
この仕組みのおかげで、私は多くのエージェントを Anthropic の Claude から、ローカルで動作するオープンウェイトの Qwen モデルへ移行しました。これは、月額 2,000 ドル以上のコストがかかるBilling変更 が実施される前に、そしてその 変更が当面延期された 後に行われたものです。これはフラッグシップモデルである Claude Opus のサイズのごく一部に過ぎず、自宅で接続しているハードウェア上で動作可能です。私がこの文章を入力している今、その装置は私の足元のすぐそばにあります。
(余談ですが、Claude 以外のエージェントを使用する場合は、CLAUDE.md を指し示すか、AGENTS.md にコピーする必要があります。非 Claude システムでは AGENTS.md が一般的に採用されており、「エージェントがまずこれらの指示を読む必要がある」という同等の役割を果たします)
私の以前の投稿 で、古い 3090 Ti でも Qwen 3.6 27B を実行できると言及しました。実は、ローカルエージェントを頻繁に活用できるようになったため、(右側を)5090 にアップグレードしました。これはやりすぎでしょうか?はい、おそらくそうです。また、これがゲーミングセットアップに見えるのも当然です。なぜなら、コンシューマー向け GPU はまさにその目的で設計されているからです。
簡潔な答えは前述の通り、適切なタイミングで AI エージェントに正しい、具体的な知識を注入できる点にあります。より詳しい説明については、まず LLM における知識の「形態」についてお話ししましょう。
まず、最先端モデルの膨大なフットプリントの大部分は「知識」です。確率的であり、正しい答えを保証するものではないため、「疑似知識」と呼ぶかもしれません。しかし、最大規模のモデルは極めて広範なデータセットで訓練されています。これは数値的な重みとして「パラメトリック知識」として捉えられています。Claude Opus や GPT-5.5 に対して何気なくある話題を尋ねる場合には非常に有用ですが、参照したいデータを既に持っている場合や、そもそもそのデータが公開されていない場合には全く無関係です。後者のケースは、専門分野(医学研究の領域)、秘密主義(高度な金融)、または独自技術(最先端かつ企業固有の材料科学)といった分野では非常に一般的です。もし私がそれを必要としないなら……モデルがあらゆるランダムな主題を網羅するために巨大なサイズになっていることの多くは、大きな無駄です。
2 つ目の形式は、コンテキストウィンドウ内(つまりプロンプトやクエリ)に提供されるデータです。このデータは、重み駆動型の「知識」とは同じではありません。コンテキストウィンドウに注入された知識(必要に応じてこちらで復習できます)は、ハルシネーション(幻覚・虚偽生成)を不可能にするものではありませんが、パラメトリック知識とはメカニズム的に異なります。そして一般的に、*関連性の高い*知識(理論上、良いシステムは*無関係な*知識ではなく*関連性の高い*知識を注入すべきです)を注入している場合、その知識は*そこにあり*、より多く利用される可能性が高くなります。不可能ではないものの、現代のフロンティアモデルに対して、実際に貼り付けたテキストの要約を求めた場合にハルシネーションが発生することは一般的ではありません。
そして繰り返しになりますが、LLM が広範なインターネットから学習したパラメトリック知識において欠如しているか稀な知識の場合、良い回答を得るためには、その知識をモデルに与えることが*必須*となります。
この基本概念はRAG(Retrieval-Augmented Generation:検索拡張生成)です。技術に詳しくない方にとっては、要するにクエリに関連する大量のデータやコンテキストを貼り付けたという、少し高度な言い換えに過ぎません。
これは一見すると自明のように思えますが、難易度は「関連情報を提供すること」ではなく、どのようにして実際にそれを行い、良い回答のために適切なものを引き出すかという点にあります。非常に難しい質問であっても同様です。実はこれはかなり本格的な学術研究の分野でもあります。私の独自のソリューションが絶対的に最善であるとは限りませんが、非常に良く機能します。私が興味を持つトピック領域における市販ライブラリの多くを凌駕しており、そこには多くの情報源にまたがる極めて困難で独自性の高い知識(例えば金融・取引、医学の特殊な分野など)が多く含まれています。
視覚的な学習者の方のために、完全なインフォグラフィックを用意しました。個人的には、この方が文章よりも複雑に見えるように思えますが……
これらの他の側面の一つ目は埋め込みです。単純なテキスト検索では多くの場合、重要な情報を見逃してしまいます。「プードル」に関する概念を検索した場合、「犬」に関連するものが非常に重要である可能性があります。「プードルの餌」を検索しても「犬の餌」に関する情報が山ほどあるにもかかわらず何も表示されないようなシステムは、ひどいものです。
これは何年も前から自然言語処理の一部となっていますが、この概念は明らかに大規模言語モデル(LLM: large language models)にも関連性があります。単語(正確にはトークン)を数値表現に変換する変換層の一つは、それらの単語や単語の部分が何を指しているかという点です。これが埋め込みモデルの役割です。
酷い結果を避けるためには、少なくとも厳密な一致を必要としない基礎的な関連概念が浮かび上がってくる必要があります。私の知識エージェントでは、文字通りの検索 *および* 埋め込み(embedding)を用いた検索の両方を使用しています。
埋め込みの計算には現在、ローカルの埋め込みモデル (BGE-M3) を使用していますが、OpenAI は API キーだけで簡単に使えるものも提供しています (text-embedding-3-small)。コストは非常に安価で、極めて大規模な利用があったとしても(新しい知識を追加する際に埋め込みモデルを実行すれば十分です)、スターバックスのコーヒー 1 杯分の費用を超えることはあり得ないほどの努力が必要になるでしょう。
私が自分のマシン上で埋め込みモデルに切り替えるまで、数千文書のプロセスを処理してきた私の経験では、コストは 1 ドル未満でした。私のテンプレートを使用する場合、OpenAI の API キーを .env.example に設定し、拡張子「.example」を削除してください。
検索(埋め込みで強化されたもの)が私に必要なものを正確に提供してくれれば素晴らしいですが、実際には*どれほど*の情報が本当に必要なのでしょうか?もし検索が単にその文が含まれる文句を引き出すだけなら、それは十分ではないかもしれません。少なくとも周囲の文が必要でしょう?しかし、周囲の文さえも不十分な場合、例えば学術論文全体が必要になることもあるかもしれません。それを明確に言うのはしばしば難しいことです。
その場合、なぜ論文全体を呼び出さないのでしょうか?実は、*多くの論文*が見つかった場合にこの問題が生じます。もし内容が*非常に長い*のであれば、さらに大きな課題となります。私の知識エージェントの一部では、*書籍全体*(私自身の著書を含む)を読み込ませています。これは基本的に私が書いたものを何でも引き出す知識エージェントであり、あるいは……いや、読者に対してこれを行ったわけではありませんが……以前に私が述べた内容を基に私として質問に答えるようなものです。しかし、書籍全体を返却する検索結果として考えるには*あまりにも長すぎます*。
ここで問われるのは、データをどのようにチャンク化(分割)するかです。はい、これが技術用語です。どのようにして関連性のある「チャンク」に分解すればよいのでしょうか?
これは実際には*非常に難しく*、私自身も多くの試行錯誤を繰り返しました。私の目的においては、特定の用途のために*要約されたサブドキュメント*を参照するアプローチが機能することがわかりました。私は3種類のドキュメントを持っています。いや、実際のソースを含めれば4種類です:
- ソース抽出—これらはマークダウン形式の生データです。私のワークフローにおいて最もトークンコストがかかる部分の一つは、ハネス内のモデルが画像やチャートの内容を詳細に記述させることです。そのため、元々画像・チャート・表が多いファイルであっても、「純粋なテキスト」のみを含む「生」ファイルを扱います。
- 概念—これらは当社の標準的なナレッジベースのための「百科事典エントリ」です。基礎となる概念が必要であり、これがそれです。
- 論文(Theses)—これらはより意見が強く、複数のソースを横断的に統合した合成物です。特定のテーマが浮上してきた場合、それを論文として記録する必要があります。
- PRIMER.md—これは「要約」であり、起動時にエージェントの方向性を示す自己更新型ガイドです。覚えておいてください。AI エージェントは初期状態では記憶を持っていません。このファイルにより、少なくともナレッジ・リトリバル(知識検索)機能を持つこのナレッジ・エージェント・ハネス内で、どのような専門家として振る舞うべきかの基礎が与えられます。
この抽出プロセスと構造は極めて重要であり、正直に言って—これはトークンコストが*非常に高額*です。新しいデータを追加するたびに、概念への参照を追加したり、新たな論文を作成する必要が生じる可能性があります。ソースには画像やチャートが多い場合、トークンを大量消費する要因となります。しかし、横断的な概念と論文の方がさらに多くのトークンを必要とします。
コンピュータサイエンスや統計学を専攻する方ならお分かりいただけるでしょう。これは組み合わせの問題です。AI モデルがこのプロセスを実行する際、個々の文書は理論的には*すべての他の文書*に対して参照される必要があります。これにより計算量が爆発的に増加し、あっという間に莫大なコストがかかります。しかし、検索時に適切なチャンクを提供するためには、特に次のステップにおいて、これが鍵となります。
この特定のステップ自体は知識抽出ほどコストがかかりませんが、最良の結果を得るためには、さらに多くのトークンを消費する必要があると私は実際に発見しました。概念や論文の抽出が完璧であっても、時には非常に難しいトピックに対して複数の検索が必要になることがあります。知識エージェントには常にソースを読む選択肢がありますが、時には*全く異なる検索*が必要となる場合もあります。
なぜでしょうか?例を挙げましょう。「アジア通貨危機時のタイ中央銀行の貸借対照表を説明し、今日における米国への教訓や転用可能なアイデアを教えてください」という、とてつもないクエリがあったとします。
エージェントは何を検索すべきでしょうか?もちろん「タイ銀行」と「アジア通貨危機」です。しかし、「米国」は検索範囲が広すぎます。十分に賢いモデル(つまり、OpenAI のミニモデルや Claude Haiku をこのタスクに投げつけることはできません)であれば、最初の検索から「タイ銀行」がタイの*中央銀行*であることを理解し、米国の対応する機関は連邦準備制度(Federal Reserve)であると気づくでしょう。また、タイではタイバーツを使用していますが、アジア通貨危機も通貨危機であったため、対応するものとして米ドル(USD)が必要になります。
さて、すでに第 2 レベルの検索が行われていますが、エージェントがさらに多くの情報を読み込むにつれて、基軸通貨(米ドル)であることがどのような違いを生むのかを理解する必要があり、*また*連邦準備制度の背後にある金融インフラ、すなわちマネー市場などがどのように機能するかをより深く理解する必要があることに気づきます。さらに、中央銀行による金保有量の増加という最近のトピックについても追加ポイントが得られます。
これらすべてがあなたにとって意味が通じるかどうかにかかわらず、私はこれを深い知識なしには適切に回答できない質問として設計しました。結局のところ、それがナレッジエージェント(Knowledge Agent)の目的です。もし私が簡単なクエリで要約を得るだけであれば、基本的な検索エンジンでも十分でしょう。
ここでエージェントの指示に明記されている概念は、*複数回のパス*を実行しなければならないという点です。では、何回でしょうか?実はここが私が経験的に工夫した部分です。事前知識がない場合、エージェントには*適切な検索回数がどれくらいか全く分かりません*。1 回では少なすぎますし、10 回だと知識ベース全体を引き込んでしまう恐れがあります。私は最終的に 3 回と決めました。一般的にこれなら、エージェントが溺れることなく十分な広がりを持たせることができます。4 回や 5 回でもおそらく問題ないでしょうが、私は概ね良好な結果が得られる最小限の回数である 3 回に固定しました。
ただし、簡単なクエリ(例:「タイ銀行とは何ですか?」)では、このプロセスをショートカットする必要があります。これも AI エージェントによる「ゲームタイムでの判断」が必要ですが、これは私が必ずしも好ましいとは思わない点です。しかし、指示には明記されています。多パス処理の結果は、簡単なクエリに対して常にひどいものになるわけではありませんが、多パス処理を行うと不要な情報が大量に流れ込みやすく、簡単な質問でも文章が冗長で脱線した内容になりがちです。
さて、結果はご自身でお確かめください。ただし、ここで注意すべきニュアンスがあります。
もちろん、これらに対する客観的な評価基準はありません。そのため、私は 3 つの最先端モデルからなるパネルを使って回答を採点しました(Opus が Opus を採点するだけではダメです…あるいは Sonnet も同様で、同じファミリーのモデルは自らのファミリーからの回答を好む傾向があります)。Codex (GPT-5.5) は中立として扱い、DeepSeek v4 Pro も使用して、Opus 以外の多様性と、もう一つの「自己採点」モデルを追加しました。私はまた個人的に回答をチェックし、おおむね同意しました。
私は、大恐慌と日本の教訓を金融政策にどう活かすかという、比較的シンプル(少なくともその範囲内では)な質問を投げかけました。これらは私が半ば寝ぼけ眼で語ってもおかしくないほどシンプルなトピックです。いずれにせよ、Claude Opus や同規模のモデル(最近の DeepSeek v4 Pro など)には *確実に* 含まれています。
実は、本当に、もしこれらのトピックに興味があるなら、*Lords of Finance* と *The Holy Grail of Macroeconomics* をお勧めします。 *Lords of Finance* の著者である Liaquat Ahamed氏は、最近開催されたソノマ・バレー作家祭のスピーカーとしても予定されていました。彼が来られず、私が若き日に愛読した本の一つにサインをしてもらえなかったことは、本当に残念でした!そういえば、もし私が祭りで講演を聴きたいなら、今ではオンラインで視聴可能です!https://svauthorsfest.org/virtual-festival/
私のタイ銀行に関する質問は、米国のクエリに関連するものでした。これは、私は「痛みこそが最良の教師である」と信じているため、若く新参のアナリストに拷問のように課すような質問です。なぜなら、良い教師になるためには厳しくあることが必要であり、私は優しい人間だからです。これらの情報の一部は秘密や機密情報ではありません……しかし、確かにこれらすべてのピースをまとめるのは非常に困難です。
ある意味、私たちの結果は、なぜ現在 Anthropic が絶好調なのかという物語を語っています。私なら、良い人間のアナリストでも一貫した回答を与えるのにやや面倒くさい/難しいと感じるような非常に困難(あるいは愚かな)クエリに対して、Claude Opus 4.8 は驚くほどよく対応しました。右側のチャートでお分かりいただける通り、知識エージェントは基本的にほとんど役立ちませんでした。実際、簡単なクエリにおいては、知識エージェントはむしろ*悪影響*を与えており、おそらくその組み込みのパラメトリック知識(parametric knowledge)がより関連性の高い情報を提供したためでしょう。
Sonnet(Anthropic の「最も困難な問題」向け Opus に対する、「日常使い」の Claude バージョン)もよく機能しました。私の前回の記事で Qwen 3.6 27B と比較して不利に評価したにもかかわらず。私にとって最大の失望は、Claude Opus と同じ重量クラスを想定されている DeepSeek v4 Pro があまりにもひどい結果だったことです。
それでも、真の物語は知識エージェント・ハネス(harness)なしでそれぞれがどう振る舞ったかという点ではなく、*あり*た場合にどう振る舞ったかという点にあります。右側のチャートは、このハネスによって「知識エージェント」として強化されたモデルにどれほどの効果があったかを示しています。
左側のグラフは、ハネスがモデル**を基本的に同等のものにしたことを示しています。覚えておいてください。そのモデルは、消費者向けハードウェアで家庭でも実行できるほど十分に小さいのです。
*そして、ご質問される前に申し上げますが、知識エージェント・ハネスありの場合に左側で Sonnet が Opus より「数値上」優れているという事実は、実質的には引き分けと捉えるべきです。*
私の本をお読みいただいた方なら、私が何を指しているのかよくご存知のことと思います。知識ベース AI(KBAI)— あるいは記号 AI や「昔ながらの AI」とも呼ばれるものは、私たちの前世代であり、1980 年代に最後の AI 投資ブームを引き起こしました。今日の AI とは異なり、それは決して間違った答えを出したり、幻覚を起こしたりしません。なぜなら、知識ベースから情報を引き出し、ルールを適用する厳格なプロセスを持っていたからです。もし間違いがあったとしても、それは知識の欠陥か、あるいは不十分なルールの記述によるものでした。
当時の AI の「本当の仕事」はしばしば「知識工学」と呼ばれていました。これはある意味で重要な示唆を含んでいます。残念ながら、このアプローチは非常に柔軟性に欠けることが証明されました。現実世界は非常に複雑であり、既存の知識やルールをそのまま適用して容易に計算できるような状況が、既存の知識が暗示する範囲を超えて「再ミックス」したり、それを越えたりすることなく、頻繁に訪れることはめったにありません。
私が「数値的重み」をパラメータ知識として議論したように、今日の AI ははるかに自由です。私はよく、事実を暗記しているがそれを広く応用できない学生と、多くの事実を覚えていないものの、「要点」をつかむ(そして時には「正しい」と感じるものをでっち上げる)ことができるもう一人の学生の例え話をします。KBAI が前者に相当し、現代のディープラーニング(特に大規模言語モデル:LLM)が後者に相当します。
この構造は穴を埋めようとしているのです。なぜなら、私が著書で述べているように、現代の AI の有用性を損なうことなく、幻覚(hallucinations)を完全に排除することは決してできないからです。ある意味では、これはハイブリッドシステムであり、まさにそれが私に「ナレッジエージェント(knowledge agents)」という名称を思いつかせた理由でもあります。
Anthropic のポリシー変更や、小規模モデルの性能向上に対する不満から、Anthropic のサブスクリプションを解約する人々が相次いでいます。しかし、これはそのような話ではありません。
もし Anthropic が、claude-p(ヘッドレスの Claude Code インスタンス—私が AI エージェントを利用する主な方法です こちら)を、依然としてサブスクリプション料金のままではなく、API 価格で課金することを提案していなかったら、私はこれについて調べることは決してなかったでしょう。月額でトークン利用料が 2,000 ドルから 3,000 ドルかかることになるためです。彼らが当初 2026 年 6 月 15 日に予定されていた変更を延期したことはありますが、それでも最終的にはその方針を実行に移すだろうと私は予想しています。
私は、これらのエージェントがなくても、月額200ドルのサブスクリプションを正当化するために、Claude Opus を十分に利用しています。非常に使いやすく設計された Claude Code を使えるのは素晴らしいことです。100万トークンのコンテキストウィンドウ(ただし、コンテキストローテーションのためにこれを埋め尽くさないよう努めています)を備えているのも便利で、リソースが尽きることを常に心配する必要もありません。また、設定をほとんど行わずに、完璧ではない指示で特定の課題を投げつけるだけで、合理的な結果(少なくとも私がすぐに修正できる軽微な問題を含む結果)を期待できるのも魅力的です。Anthropic の株価がこれほどまでに高騰しているのには理由があります。
しかし、ソフトウェアの改善とともに、小規模モデルがいかに飛躍的に進化したかは驚くべきことです。オープンウェイトモデル(Open-weight models)が格差を大幅に縮めたことは素晴らしいことです。また、Anthropic や OpenAI が自社のモデルへのアクセスを閉鎖した場合や、政府がそのように強制した場合でも、より多くの労力を要するものの同様の結果を得られることがわかっているのは、ある種の解放感をもたらします。
Devansh もまた、「ステートフルスウォーム(stateful swarms)」と呼ぶプロジェクトを通じて同様の成果を示しました。より多くの労力と、いわばハーンネス(harness)が必要ですが、「弱い」モデルでも大幅に優れた結果が得られます。
ある程度、私のタイトルはクリックベイトです——少なくとも Opus のような「真の」フロンティアモデルを相手にする限りにおいて。しかし、Sonnet もまた「フロンティア」モデルの一つですが(最大規模のものではありません)、私たちはしばしばそれを追いつき、あるいは凌駕することができます。知識エージェントは、特に独自データの場合、あらゆるモデルを劇的に強化します。もし Claude Opus のトークンを無制限に自由に使用できるなら……なぜしないのですか?しかし、確かにそれはより小さなモデルにとって大きな向上をもたらします。単なるキュレーションされた知識であっても、真の独自知識であっても同様です。
私の知識エージェントテンプレートを使って何かを構築した場合は、ぜひ教えてください!その報告を聞けることを楽しみにしています。また、テンプレートについてや、自分でこれらを作成することについてご質問がある場合は、どこで私を見つけられるかご存知でしょう。
この記事をお楽しみいただけたことを願っています。AI の過去・現在・未来をわかりやすく学びたいとお考えの場合は、私が執筆した『What You Need to Know About AI』という書籍があります。
この本は現在、Amazon Prime Day 期間中(6月26日まで)に販売中です——ペーパーバック版が通常価格$19.99から$9.99、電子書籍版が通常価格$9.99から$3.99です。こちらでチェックしてください。
P.S. もしあなたがアメリカ国外にお住まいの場合でも、現地の通貨で同様の割引価格にて Amazon でご購入いただけます。
原文を表示
Anthropic recently had to pull Mythos/Fable due to an edict from the US government. While Mythos was a step up from Opus, I’ve been actively moving *smaller* in terms of my agentic models—and matching the quality of output of some of the largest frontier models.
The use cases have spanned from hard “hedge fund level” (for want of a better description) market analysis, financial management, and AI personal assistants to even helping a few friends in difficult medical situations. I’ve called this pattern “knowledge agents” with a generic template available to everyone here. They literally inject the right knowledge into the AI agent plugged into it. Anyone can do this, with or without my template.
As my README proudly declares (yes, I absolutely do have AI write my documentation—do *you* like writing comprehensive technical documentation?):
This methodology was developed and battle-tested on a markets knowledge agent, meant to replicate James Wang’s thought process in markets: ~10,000 pages of scanned financial market reference materials + ~100 web articles, producing 381 concept documents and 54 thesis documents with hybrid BM25 + semantic search. This was further tested on other specialized knowledge areas—including company-specific policy docs (for a “corporate knowledge agent”) and rare research areas (women’s sexual health, given James’s background)—to great effect. The generalized version here captures a domain-agnostic methodology so it can be applied to any subject.
These were the first, but at this point I have twelve of these specialist “knowledge agents” that handle queries from other agents. Or, obviously, from me. When I’m coding new things that require specialist knowledge, I often start Claude Code *in a knowledge agent folder* instead of making a new folder and have it benefit from the expert knowledge within it to plan. Especially for specialized machine learning algorithms or economic models, I get *far* better results this way than with a “subject-agnostic” model—even a really big frontier model.
In general, I have used Claude Opus in these knowledge agent “harnesses” (one way to describe this “superstructure” around the AI). As such, it’s pairing the really big model *with* injected knowledge from the harness. However, I’ve found that I get very, very good results even with far smaller models. The LLM is merely the “engine”—all of the expert knowledge is provided from my knowledge agent system, which surfaces the relevant knowledge at the right time.
Relevant, of course, is key. As most of you know, you can’t just drag 10,000 pages of documents into your chat window. Even if you could, you’d get a mess of irrelevant information drowning the LLM. In practicality, you’ll probably run out of context and never get an answer if the platform even lets you do it.
This has allowed me to move many of my agents from Anthropic’s Claude (ahead of a billing change that would have cost me $2k+ per month that now got delayed) to a locally run open-weight Qwen model. It’s a tiny fraction of the size of Claude Opus (the flagship model) and is able to run on hardware I have plugged in at home. It’s next to my feet right now as I’m typing.
*(As a random note, you do have to point your non-Claude agent at CLAUDE.md or copy it into AGENTS.md—AGENTS.md is often the convention for non-Claude systems as the equivalent “agent needs to read these instructions first”)*
The simple answer, as said, is that it injects the right, specific knowledge into the AI agent at the right time. The longer answer? Let’s first talk about the *forms* that knowledge takes in LLMs.
First, a significant portion of frontier models’ huge footprint is “knowledge.” I might call it pseudo-knowledge, since it’s probabilistic and there’s no guarantee it’ll give you the right answer... but the biggest models have been trained on an enormously broad set of data. This is captured in numerical weights as “parametric” knowledge. While that’s very useful if you’re casually asking Claude Opus or GPT-5.5 about some random topic, it’s entirely irrelevant if you either already have the data you want to reference or the data isn’t publicly available anyway—so it could never train on it. The latter is quite common in fields that are specialist (areas of medical research), secretive (high finance), or proprietary (frontier, company-specific materials science). If I don’t need it... well, a lot of the massive size of the model to cover every random subject matter is a huge waste.
The second form is data provided in the context window—in other words, your prompt/query. That data is not the same as weight-driven “knowledge.” Injected knowledge in the context window (refresher on that if needed) does not make it impossible to have hallucinations, but it is mechanistically different from parametric knowledge. And, in general, if you’re injecting *relevant* knowledge (in theory, a good system should do that vs. *irrelevant* knowledge) it’s *right there* and more likely to be used. While not impossible, you generally don’t get hallucinations when you ask a modern frontier model to summarize text that you literally paste into it.
And, again, in the case of knowledge that is either absent or rare in parametric knowledge that LLMs ate from the broader internet, you are *required* to give it the knowledge in order to get a good answer.
This base concept is RAG (retrieval-augmented generation). For less technical folks, it’s basically a fancy way of saying you pasted in a bunch of relevant data/context in your query.
This seems kind of obvious, but the difficulty is not “give relevant information.” It’s how to actually do it and surface the right thing for a good answer—even with extremely difficult questions. This is actually an area of pretty serious academic research. My particular homebrew solution may not be the absolute best, but it works *very well*—beating a lot of the off-the-shelf libraries for the topic areas I’m interested in, which usually involve a lot of extremely difficult, proprietary knowledge that spans a ton of sources (e.g., finance/trading, esoteric areas of medicine).
The first of these other aspects is embedding. A naive text search is going to often miss things. If I search up a concept about a “poodle,” things that relate to “dog” might be highly relevant. It would be a terrible system if searching “poodle food” brings up nothing even with oodles of information about “dog food.”
This has been a part of natural language processing for years, but the concept obviously has relevance to LLMs (large *language* models) as well. One of the layers of transformation of words (well, tokens) into numerical representations is what those words, or word parts, are *related to*. That’s the job of the embedding model.
To not be awful, we need to have, at minimum, base-level related concepts come up that don’t need literal matches. In my knowledge agents, I use both literal search *and* search using embeddings.
For calculating embeddings, I now use a local embedding model (BGE-M3), but OpenAI has an easy one to use with just an API key (text-embedding-3-small). It’s cheap enough that I think even with extraordinarily heavy use—and you only need to run the embedding model with new knowledge added—it’d be a herculean effort to ever exceed the cost of a Starbucks coffee.
In all my time using it, processing thousands of documents, before I switched to an embedding model on my own machine... it cost me less than a dollar. If you use my template, put your OpenAI API key into .env.example and remove “.example”.
While it’d be nice to just have a search (enhanced by embedding) give me exactly what I need, *how much* is actually needed? If a search merely brings up the sentence it’s in... well, that might not be enough. We’d at least need the surrounding sentences, right? But what if the surrounding sentences aren’t enough and we actually need the entire, say, academic paper? It’s often hard to say.
In that case, why don’t we just bring up the entire paper? Well, this becomes an issue if we find *a lot of papers*. It’s an even bigger one if stuff is just *really long*. In some of my knowledge agents, I’ve fed them *entire books* (including my own, for one that is basically a knowledge agent that brings up anything I’ve written—or... and no, I haven’t done this with any readers... answer questions as me based on what I’ve said before). An entire book is *way* too long to be a reasonable search result to return.
The question here is how do we chunk our data? Yes, that is the technical term. How do we break it up into (as it sounds like) chunks that are relevant?
This is actually *quite hard* and took me a lot of trial and error. For my purposes, having referenced *summarized subdocuments* for certain purposes ended up working. I have three types of documents. Well, four if you include the actual sources:
- Source extractions—these are the raw sources in markdown. One of the costliest (in tokens) parts of my workflow is that I have a model in the harness describe in detail what’s in images and charts. As such, we work with “raw” files that are pure text, even when they started out image-, chart-, or table-heavy.
- Concepts—these are the “encyclopedia entries” for our canonical knowledge base. We need grounding concepts... and these are it.
- Theses—these are more opinionated, cross-cutting syntheses of multiple sources. If certain themes emerge, we should capture them in theses.
- PRIMER.md—this is the “summary” and self-updating guide that helps orient the agent on startup. Remember, AI agents start with no memory—so this gives them at least a basis for what kind of expert they are (with knowledge retrieval) within this knowledge agent harness.
This extraction process and structure is key and I’m not going to lie—it’s *extraordinarily costly in tokens.* Every time you add new data, you may need to add new references in concepts and have more theses. Sources can be heavy token hogs if they have a lot of images/charts. But cross-cutting concepts and theses are even more.
Computer science and statistics majors would understand. This is a combinatorics problem. Each individual document needs to be referenced against *all the other documents* (at least in theory) by the AI model running the process. This blows up combinatorially and gets ridiculously costly, fast. But it’s also key to giving you the right chunks when you search, especially with the next step.
While this particular step isn’t as costly as knowledge extraction, I have indeed found that to get the best results, we need to set even more tokens on fire. Even with perfect concept and thesis extraction, sometimes we have a really, really hard topic that requires multiple searches. While the knowledge agent always has the option of reading sources, sometimes you need a *completely different search.*
Why? Let’s bring up an example. If I have a totally insane query, say, “Describe the Bank of Thailand’s balance sheet during the Asian Financial Crisis and tell me what lessons or transferable ideas there are for the US today.”
What should the agent search? Well, obviously “Bank of Thailand” and “Asian Financial Crisis.” But US? Too broad a search. A smart enough model (so, no, you can’t throw one of OpenAI’s mini models or Claude Haiku at this thing) would realize from the first search that “Bank of Thailand” is the *central bank* of Thailand. The analog in the US is the Federal Reserve. Also, Thailand uses the Thai Baht, but the Asian Financial Crisis was also a currency crisis, so an analog would need to be USD.
Ok, we already have a second level of searches. But as the agent reads more... it realizes it actually needs to understand how being the reserve currency (USD) makes a difference. *And* also better understand the underlying financial plumbing of the Fed system, how money markets, etc. work... and bonus points for recent events in terms of gold accumulation by central banks as a recent topic.
Regardless of if *any of that* made sense to you, I designed it as a question that cannot be answered well without a *lot* of deep knowledge. That, after all, is the point of a knowledge agent. If I just needed to get a summary with *easy* queries... well, any basic search would do it.
The concept here, which is written into the instructions for the agent, is it must do *multiple passes*. How many? Well... this is where I did an empirical kludge. Without pre-knowledge, the agent has *no idea how many searches are appropriate.* One is too few. Ten could start to pull in the whole knowledge base. I landed on three. In general, that gives enough breadth without drowning the agent. Four or five is likely fine, but I kept it to the minimum where I could see generally good results.
Easy queries (e.g., “What is the Bank of Thailand?”) need to short-circuit this though—which also needs to be an AI agent “gametime call,” which I don’t love, but is written in the instructions. While the results of multi-pass aren’t always horrible for easy queries, multi-pass does dump a lot of extraneous information in and tends to make easy questions really wordy and meandering.
Well, see the results for yourself. There is a nuance here that you should notice, however.
I threw a fairly simple (well, as far as it goes) question about lessons from the Great Depression and Japan for monetary policy. These are simple topics that I could probably ramble on about half-asleep. Regardless, they’re *definitely* in Claude Opus and similarly sized models (like the recent DeepSeek v4 Pro).
Actually, seriously, if you’re curious about the topics, I suggest Lords of Finance and The Holy Grail of Macroeconomics. Liaquat Ahamed, author of Lords of Finance, was also slated to be a speaker at the recent Sonoma Valley Authors Festival—I was super disappointed he didn’t make it and sign one of my favorite books from when I was young! Speaking of, if you want to hear my talk during the Festival, it’s now online here! https://svauthorsfest.org/virtual-festival/
My Bank of Thailand related to the US query? It’s the kind of question I’d torture young, new analysts with because I believe pain is the best teacher, it’s kind to be a good teacher, and I’m a kind person. None of the information is secret or proprietary... but it is definitely hard to pull together the pieces.
In a way, our results do tell a story as to why Anthropic is riding high right now. For such a hard (stupid) query that I would expect even a good human analyst would find somewhat annoying/difficult to give a coherent answer to, Claude Opus 4.8 did remarkably well. As you can see on the righthand chart, the knowledge agent basically didn’t really help it. In fact, on the easy query, the knowledge agent actually *hurt* it, probably because its built-in parametric knowledge gave more relevant information.
Even Sonnet (Anthropic’s “everyday” version of Claude vs. Opus for the “hardest problems”) did well, despite me comparing it unfavorably to Qwen 3.6 27B in my last article. Perhaps the biggest disappointment for me was how poorly DeepSeek v4 Pro did—since it’s meant to be broadly in the same weight class as Claude Opus.
Nevertheless, the real story is less how they each did without the knowledge agent harness. It’s how they did *with* it. The righthand chart gives the story of how much of a lift the harness gave the now empowered “knowledge agents.”
The left shows that the harness basically equalized the models, including Qwen 3.6 27B. Remember, that model is literally small enough to run at home with consumer hardware.
*And, before you ask, Sonnet being “numerically” better than Opus on the left with the knowledge agent harness is really more of a tie.*
Those of you who’ve read my book likely know exactly what I’m talking about. Knowledge-based AI (KBAI)—also known as symbolic AI or “good ol’ fashioned AI”—was our prior generation and caused our last AI investment boom in the 1980s. Unlike today’s AI, it never got an answer wrong or hallucinated, because it had a strict process of drawing from a knowledge base and applying rules. If it got something wrong, it was because of either faulty knowledge or poorly written rules.
The “real” work of AI was often referred to back then as “knowledge engineering,” which tells you something. Unfortunately, this approach proved highly inflexible. The real world is quite complex… and it rarely graces us with circumstances similar enough to easily compute through existing knowledge and rules without “remixing” or going beyond what our existing knowledge implies.
Today’s AI, as I discussed with the “numerical weights” for its parametric knowledge, is much more free. I usually give the analogy of a student who has memorized facts but isn’t able to apply them broadly and another student who really doesn’t remember many facts but is able to “get the gist” (and sometimes makes things up that “feel” right). KBAI is the former, and modern deep learning (especially LLMs) is the latter.
This structure is attempting to plug the hole, because, as I lay out in the book, we can *never* totally remove hallucinations without destroying the utility of modern AI. It is, in a way, a hybrid system—which is what inspired my naming of them: “knowledge agents.”
There have been a spate of people canceling their Anthropic subscriptions due to annoyance about Anthropic’s policy changes or improvements in smaller models. This is not one of those stories.
If Anthropic had never brought up making claude -p (headless Claude Code instances—the main way I use AI agents) charged at API prices instead of still being on the subscription, which, once again, would cost me $2,000 to $3,000 in tokens per month, I would have never looked into this. Even though they’ve delayed the change that was originally scheduled for June 15th, 2026, I still expect they’ll eventually go through with it.
I still use Claude Opus enough to justify a $200 per month subscription, even without these agents. It’s nice to use Claude Code, which is quite ergonomic. It’s nice to have a million-token context window (though I try not to fill it up due to context rot) and never really worry about running out. It’s also nice to not do much setup and just throw certain problems over the wall with less-than-perfect instructions and still expect reasonable results (or at least results with minor problems I can quickly correct). Anthropic shares haven’t been flying around as one of the hottest things ever for no reason.
But it’s still remarkable how far small models have come, especially with software improvements. It’s great that open-weight models have closed the gap a lot more. And it’s liberating to know that even if Anthropic and OpenAI close off access to their models—or, say, a government forces them to close off their models—we can still get similar results, just with more work.
Devansh also demonstrated something similar with a project of his that used what he called “stateful swarms.” More work and a harness of sorts, but substantially better results with “weaker” models.
To some degree, my title is clickbait—at least for the *true* frontier models like Opus, we’re looking to match. But Sonnet, also a “frontier” model (but not the biggest of the big), we can often match or even beat. Knowledge agents do genuinely, especially in proprietary data cases, vastly enhance *any* model. If you can freely use infinite Claude Opus tokens... why not? But it obviously gives a bigger lift to smaller ones, even in cases with merely curated knowledge versus truly proprietary knowledge.
If you build something with my knowledge agent template, let me know! I’d love to hear about it. Additionally, if you have any questions, either on the template or building one of these yourself, you know where to find me.
I hope you enjoyed this article. If you’d like to learn more about AI’s past, present, and future in an easy-to-understand way, I’ve published a book titled *What You Need to Know About AI*.
The book is on sale now during Amazon Prime Day (through June 26th)—$9.99 for paperback (usually $19.99) and $3.99 for eBook (usually $9.99). Check it out here.
P.S. If you’re outside the US, it’s available on Amazon at a similar discount in your local currency.
関連記事
GLM-5.2 OpenAI 互換 API:推論努力、関数呼び出し、長文コンテキスト検索のハンズオンガイド
Zhipu AI が提供する GLM-5.2 モデルの OpenAI 互換 API を使用し、推論努力制御や関数呼び出し機能を実践的に検証するチュートリアルを公開した。
Claude Code の「拡張思考」出力のテキストは真正ではない(3 分読了)
Anthropic は Claude Code の「拡張思考」機能における推論プロセスを暗号化しており、ユーザー端末には鍵が提供されない。API が返すのは推論の要約のみであり、完全な思考出力を得るには企業向け契約が必要である。
Claude Sonnet 5(1 分で読める)
Anthropic が新モデル「Claude Sonnet 5」を発表しました。このモデルは、前世代よりも推論能力や複雑なタスクの処理性能が向上しています。
今日のまとめ
AI日報で今日の重要ニュースをまとめ読み