プライバシーを保護する腫瘍学臨床意思決定支援のための二層マルチエージェントフレームワーク「OncoAgent」の提案
本文の状態
日本語全文を表示中
詳細モードで約26分の本文を読めます。
同じ出来事の情報源
この情報源を基点に整理
Hugging Face Blog
研究者らが、患者データを秘匿しながら腫瘍学の臨床判断を支援する二層構成のマルチエージェントシステム「OncoAgent」を開発し、その有効性を示した。
Source Article
元記事を日本語で読む
本文に関係しない購読案内、埋め込み通知、サイト内プロモーションは除いています。
著者:
- ユーザー:oncoagent-research
タグ:
- 腫瘍学 (oncology)
- マルチエージェント (multi-agent)
- LangGraph
- RAG
- QLoRA
- AMD
- オープンソース (open-source)
- クリニカル AI (clinical-ai)
- ヘルスケア (healthcare)
OncoAgent:プライバシーを保護する腫瘍学臨床意思決定支援のための二層マルチエージェント・フレームワーク
*技術プレプリント · 2026 年 5 月 · OncoAgent 研究グループ*
概要
私たちは、腫瘍学向けのオープンソースかつプライバシーを保護する臨床意思決定支援システム「OncoAgent」を発表します。OncoAgent は、二層のファインチューニング済み大規模言語モデル (LLM) アーキテクチャと、最先端のマルチエージェント LangGraph トポロジーを組み合わせています。さらに、70 以上の医師グレードの NCCN および ESMO ガイドラインを対象とした 4 つの段階からなる補正型 RAG パイプラインと、厳格なゼロ PHI(患者個人識別情報)ポリシーを強制する 3 層のリフレクション安全性検証器を搭載しています。
本システムは、臨床問い合わせを加法複雑性スコアラーにルーティングし、9B パラメータの速度最適化モデル (Tier 1) または 27B パラメータの深層推論モデル (Tier 2) のいずれかに振り分けます。両モデルとも、Unsloth フレームワークを用いて AMD Instinct MI300X ハードウェア(HBM3 192 GB)上で QLoRA によりファインチューニングされており、実症例と合成データを組み合わせた 266,854 の腫瘍学ケースのコーパスを学習しています。
MI300X 搭載環境におけるシーケンスパッキングにより、フルデータセットのファインチューニングを約 50 分 で完了させることに成功しました。これは API ベースの生成と比較して 56 倍 のスループット向上です。修正後、CRAG(Corrective RAG)によるドキュメント評価は 100% の成功率を達成し、平均 RAG 信頼スコアは 2.3+ を記録しました。
本システムは完全オープンソースであり、オンプレミスでのデプロイが可能です。これにより、独自クラウド API への依存が不要となり、患者データの主権(データ所有権)を維持することが可能になります。
キーワード: クリニカル・ディシジョンサポート、腫瘍学 AI、マルチエージェントシステム、検索拡張生成 (RAG)、QLoRA、AMD ROCm、オープンソース医療 AI、ヒューマン・イン・ザ・ループ (HITL) 安全性、LangGraph、Corrective RAG
1. イントロダクション
腫瘍学は、臨床医学において最も情報密度が高く、認知負荷の大きい分野の一つです。米国国立総合がんネットワーク(NCCN)から欧州腫瘍内科学会(ESMO)に至るまで、エビデンスに基づくガイドラインの量、多様性、そして急速な進化が、published なエビデンスと実際の臨床現場との間に持続的な知識格差を生み出しています。
AI を活用したクリニカル・ディシジョンサポートシステムには、この格差を埋める変革的な可能性がありますが、現在市販されているシステムの多くは、以下の 3 つの重要な点で失敗しています。
- 根拠のない推奨事項: 検証済みのガイドラインに基づいていないハルシネーション(幻覚)による提案
- クラウド API への依存: プライバシーが敏感な病院環境でのオンプレミスデプロイを妨げる要因
- モノリス型 LLM アーキテクチャ: 複雑な多疾患併存の症例において、コンテキスト飽和を起こしやすい構造
OncoAgent は、以下の 3 つの核心原則に基づいて設計されています。
- アーキテクチャの分解: 臨床推論は、それぞれが限定された監査可能な機能を担う 8 つの専門化された LangGraph ノードに分解されます。
- 根拠に基づく生成: すべてのモデル出力は、4段階の検索パイプラインと明確な関連性ゲートを通じて、キュレーション済みのベクトル知識ベースに紐付けられます。
- ハードウェア主権: 推論およびトレーニングスタック全体が、ROCm とオープンソースフレームワークを用いて AMD Instinct MI300X 上でネイティブに実行されます。これにより、データの外部流出を伴わずに病院での展開が可能になります。
2. 関連研究
2.1 臨床用 LLM と意思決定支援
大規模言語モデルは、診断コード付け、文献の要約、患者とのコミュニケーションといった臨床 NLP タスクにおいて、大きな可能性を示しています。BioMedLM、Med-PaLM 2、ClinicalBERT に代表されるドメイン特化型のファインチューニング手法は、汎用モデルと比較して医療ベンチマークでの性能を一貫して向上させています。OncoAgent はこの研究の流れを継承しつつ、特にハルシネーション(幻覚)の悪影響が甚大となる腫瘍学におけるトリアージと治療経路の推奨という特定のサブドメインに焦点を当てています。
2.2 マルチエージェントアーキテクチャ
分解型マルチエージェントシステムは、複雑な推論タスクに対する原理的なアプローチとして台頭しています。OncoAgent は、4 つの代表的な SOTA パターンを統合しています。
- Claude Code パターン — LLM の推論から分離された、決定論的な安全装置
Hermes Agent パターン:セッションごとのメモリ分離を備えた構造化されたツール呼び出し
Corrective RAG(Shi ら、2024):ドキュメントの関連性評価とクエリ再構成
Reflexion(Shinn ら、2023):フィードバック強化による試行ループでの自己修正生成
2.3 医療分野における検索拡張生成 (RAG)
標準的なバイエンコーダーによる検索は、「チロシンキナーゼ阻害剤」と「TKI」のように用語の精度が極めて重要な臨床領域には不向きです。OncoAgent は、クロスエンコーダーによる再ランク付けを含む多段階パイプラインを実装しており、さらに Hypothetical Document Embeddings (HyDE; Gao ら、2022) を統合することで、自然言語クエリをガイドラインの埋め込み空間に投影し、医療用語の同義語ミスマッチを解消します。
3. システムアーキテクチャ
3.1 概要
OncoAgent は、LangGraph を用いた状態保持型の有向グラフとして実装されています。システムの状態は、11 の論理セクションと約 30 の型付きキーを含む不変の AgentState TypedDict で表現されます。各ノードは特定のキーにデータを追加するだけで、上流データを改変しないため、完全な監査証跡が保持されます。
このシステムのトポロジーには 8 つのノードがあります:
Router → Ingestion → Corrective RAG → Specialist ↔ Critic → HITL Gate → Formatter → END
↓
Fallback → END
主な特徴は以下の通りです:
- 5 つの条件付きエッジ
- 1 つのリフレクション再試行ループ(最大 2 回)
- 高複雑度または低信頼度の出力に対する必須のヒューマン・イン・ザ・ループ (HITL) 割り込み
3.2 複雑度ルーティングとモデルティアリング
専門家の呼び出し前に、加重加算モデルを用いて症例の複雑度を定量化します:
S = w_cancer + w_stage + w_mutations + w_treatment
ここで:
| 要因 | 条件 | 重み付け |
|---|---|---|
| がんの種類 | 希少 | +0.40 |
| がんの種類 | 原発巣不明 | +0.30 |
| 病期 | ステージ IV | +0.25 |
| 病期 | ステージ III | +0.15 |
| 変異 | ≥2 同定済み | +0.30 |
| 変異 | 単一 | +0.15 |
| 既往治療 | 任意のキーワード一致 | +0.10 |
決定境界: S ≥ 0.5 の場合は Tier 2(Qwen 3.6-27Bによる深層推論)、S < 0.5 の場合は Tier 1(Qwen 3.5-9Bによる高速トリアージ)へルーティングします。
検証結果: KRAS と BRCA2 の変異を有するステージ IV 膵癌の症例では S = 0.80 が正しく算出され、Tier 2 へルーティングされました。✅
なお、臨床医は UI を介して手動で階層選択を上書きすることも可能です。
3.3 ドキュメント評価を伴う修正型 RAG(CRAG)
CRAG ノードは、ドキュメントをスペシャリストへ転送する前に、各取得した文書の臨床的関連性を評価します。二値分類で関連性が低いと判断された文書については、自動的にクエリが再構成されます(最大 1 回の試行)。これにより、RAG パイプラインにおける主要なハルシネーションの原因である、「タイトルは妥当だが意味内容が無関係なコンテンツの取得」を排除できます。
評価ステップで Qwen 3.5 から Qwen 2.5 Instruct に移行した結果、成功率が 0% → 100% に向上し、子宮がんトリアージテストにおける RAG の信頼度スコアは 2.3+ を達成しました。
3.4 リフレクション安全ループ(クリティックノード)
クリティックノードは、出力が HITL ガートに到達する前に、3 層の検証カスケードを実行します。
- フォーマットチェック — OncoCoT の出力スキーマに対する構文準拠を検証
- 安全性チェック — 禁止された出力パターン(ガイドライン引用なしの絶対用量、薬物相互作用の省略など)を決定論的なルールベースでスキャン
- LLM 含意チェック — スペシャリストの推奨が、取得した RAG コンテキストによって完全に裏付けられているかを確認
失敗した場合、批評家の具体的なフィードバックは専門家のコンテキストに再投入され、最大2回のリトライが行われます。重要なのは、批評家がLLM 制御ロジックではなく決定論的なコードとして実行される点です。これにより、敵対的なプロンプトによる安全対策の回避を防ぎます。
3.5 ヒューマン・イン・ザ・ループゲートとフォールバック
HITL ゲートは、すべての Tier 2 ケースおよび rag_confidence < 0.3 の出力に対して、臨床医が即座に介入できる必須の機能を提供します。また、回復不能な失敗を検知した際に動作する専用のフォールバックノードが存在し、どのような故障モードにおいても幻覚的な代替案を提示することなく、臨床的に安全な拒否応答である「Información no concluyente en las guías provistas」を返します。
3.6 患者ごとのメモリ分離 (原文の技術表記: "Información no concluyente en las guías provistas")
PatientMemoryStore モジュールは、各患者セッションに一意の thread_id(形式:PT-XXXX)を割り当てます。これは configurable パラメータとして渡されます。
LangGraph のネイティブなチェックポイント機能。
これにより、セッション内での反復的な多回対話が可能になる一方で、患者ごとの厳格なメモリ分離が保証されます。
4. 知識ベースの構築と RAG パイプライン
4.1 ガイドラインの取り込みとサニタイゼーション
知識ベースは、138 の NCCN 詳細ページを 60 秒未満で処理した並行型ウェブスクレイパーによって特定された77 の医師ガイドライン PDFから構築されました。テキスト抽出には PyMuPDF (fitz) を使用し、ブロックレベルの構文解析を行うことで、多段構成の臨床レイアウトにおける意味的な読書順序を保持しています。
取り込み前に、正規表現を用いたサニタイズ処理で機関のブランディングを除去します。患者向け資料はヒューリスティックフィルタリングによって除外されます。その結果得られたコーパスには、肝細胞癌(HCC)、非小細胞肺がん(NSCLC)、乳がん、大腸がん、神経内分泌腫瘍など主要ながん種を含む70 以上の専門的な腫瘍学ガイドラインが網羅されています。
4.2 医療用埋め込みモデルとベクトルストア
一般的な汎用埋め込みモデル(例:all-MiniLM-L6-v2)は、臨床用語の意味表現の精度が低いため採用を見送りました。OncoAgent では以下の構成を採用しています。
- 埋め込みモデル:
pritamdeka/S-PubMedBert-MS-MARCO— PubMed および MS-MARCO でファインチューニングされ、非対称な医療分野のセマンティック検索に最適化されています - ベクトルストア: ローカル環境で動作するChromaDBの永続インデックス — クラウド依存ゼロ、PHI(個人健康情報)非保持準拠
4.3 4段階の検索パイプライン
| ステージ | コンポーネント | 機能 | 設定 |
|---|---|---|---|
| 1. 検索 | PubMedBERT Bi-Encoder | ワイドネット検索 | 上位 15 候補 |
| 2. 距離ゲート | コサイン距離フィルタ | ハルシネーション防止の下限値 | 閾値 = 0.10 |
| 3. リランキング | クロスエンコーダ (MS-MARCO MiniLM) | クエリとドキュメントの関連性評価 | 上位 5 件を返す |
| 4. コンテキストトリミング | 文字数制限機能 | LLM のコンテキストウィンドウ内に収める | 最大 6,000 文字 |
ハルシネーション防止ポリシー: ステージ 2 で照会が失敗した場合、専門家を呼び出すことなく「提供されたガイドラインに結論がない」と返答します。これにより、ドメイン外の臨床入力に対して誤った推奨が行われることを完全に防ぎます。
NCCN コーパスに対する距離閾値の較正結果は以下の通りです。
- 医療クエリの距離:約 0.06〜0.09
- ドメイン外の距離:約 0.11〜0.15
- ハード閾値:0.10
オプションの HyDE モジュールは、仮説的なガイドライン段落を生成し、これをステージ 1 の検索における埋め込みアンカーとして利用します。これにより、「neoplasia pulmonar」と「lung carcinoma」のような同義語の不一致を解消できます。
5. ダブルティア QLoRA 微調整
5.1 学習コーパス:OncoCoT(266,854 サンプル) (原文の技術表記: "Información no concluyente en las guías provistas"、"neoplasia pulmonar"、"lung carcinoma")
| ソース | タイプ | サンプル数 | 備考 |
|---|---|---|---|
| PMC-Patients | 実際の臨床症例 | ~85,000 | PubMed Central の患者報告 |
| Asclepius | 実際の臨床データ | ~85,000 | 編集された医療 QA コーパス |
| OncoCoT Synthetic | 合成データ (Qwen 3.6-27B) | 96,941 | MI300X で生成、時速約 6,800 件・拒否率 0.65% |
| 合計 | — | 266,854 | 90/10 の学習/評価分割・SHA-256 ハッシュ化・重複除去済み |
すべてのケースで、Qwenとの互換性を確保するために ChatML テンプレートを使用しています。JSON の解析破損を防ぐため、思考トークンは無効化しました(chat_template_kwargs: {enable_thinking: False})。
5.2 QLoRA の設定
両方の階層は、BitsAndBytes を介して 4 ビットの NormalFloat4 (NF4) 量子化を採用しており、LoRA アダプターは主要な投影モジュールである q_proj と k_proj に適用されています。
v_proj、o_proj、gate_proj、up_proj、down_proj。
| パラメータ | Tier 1 (Qwen 3.5-9B) | Tier 2 (Qwen 3.6-27B) |
|---|---|---|
| デバイスごとのバッチサイズ | 4 | 2 |
| 勾配累積 | 4 | 8 |
| 実効バッチサイズ | 16 | 16 |
| 学習率 | 2×10⁻⁴ | 1×10⁻⁴ |
| LoRA 階数 (*r*) | 16 | 32 |
| シーケンスパッキング | True, 2048 トークン | True, 2048 トークン |
| 早期打ち切り | Patience = 3 | Patience = 3 |
| 量子化 | NF4 4-bit | NF4 4-bit |
5.3 AMD MI300X の最適化
元の HuggingFace transformers + PEFT パイプラインは、MI300X で以下の2つの独立した問題により失敗しました。
trlv0.24.0 の厳格な EOS 検証とQwen3VLProcessorラッパーとの間のトークナイズ競合- 標準精度でのターゲット有効バッチサイズに対して、VRAM に十分な余裕がないこと
Unsloth's FastLanguageModel へ移行することで、両方の問題が同時に解決されました。
- VRAM の削減: ピーク使用量が約60%減少(OOM から安定した192 GB デバイス上で約64 GB)
- トレーニング速度: 有効バッチサイズ16 で約2倍の向上、1ステップあたり約16秒に短縮
AMD ROCm 固有の適応には以下の対応が必要です。
# 1. Pass inner tokenizer, not the Qwen3VLProcessor wrapper
trainer = SFTTrainer(tokenizer=model.get_tokenizer(), ...)
# 2. Prevent incompatible EOS injection
training_args = SFTConfig(eos_token=None, ...)
# 3. AMD-specific bitsandbytes for ROCm 6.2/gfx942
# pip install bitsandbytes --find-links <amd-continuous-release-wheel>
# 4. BF16 workaround (is_bf16_supported() returns False on ROCm despite hardware support)
training_args = TrainingArguments(fp16=True, ...)
# Final deployment uses native BF16:
model = AutoModelForCausalLM.from_pretrained(..., torch_dtype=torch.bfloat16)
5.4 シーケンスパッキングとスループットの飛躍
SFTConfig の packing=True を使用したシーケンスパッキングにより、複数の短い臨床記録を 2048 トークン単位のシークエンスに結合できます。これにより、パディングのオーバーヘッドが排除され、フォワードパスの実行回数が劇的に削減されます。
Unsloth のカーネルとシーケンスパッキングを MI300X で併用したことで、266,854 サンプルのデータセット全体に対するファインチューニングが、当初の見積もりである 5 時間に対して約 50 分で完了しました。これはトレーニング時間を約 6 倍に圧縮したことになります。GPU の利用率は最大で約 70% に達し、スループットは一貫して 1 反復あたり約 11.3 秒を維持していました。
Checkpoint-1000 の結果:Tier 1 アダプターは 1,339 ステップでトレーニングが完了しました。トレーニング時の損失は約 0.05、アダプターのサイズは 187 MB です。adapter_model.safetensors、adapter_config.json、tokenizer.json を含む 11 ファイルのマニフェストに対して検証済みです。
本システムは適応型推論ルーティングをサポートしており、ROCm が利用可能な場合は LocalModelManager シングルトン経由で BF16 推論を実行し、高可用性を確保するために Featherless.ai API へシームレスにフォールバックします。
6. セーフティおよびプライバシーフレームワーク
6.1 Zero-PHI ポリシー
専用ゼロ PHI リダクションノードがインジェストノード内の最初の処理ステップとして稼働し、テキストが LLM に到達する前に実行されます。このノードは保護対象医療情報(患者名、生年月日、MRN 番号、住所、施設識別子)を特定し、臨床的に中立なプレースホルダーに置換します。リダクションされた表現は AgentState に保存され、元のテキストは破棄されます。
これにより、ローカルまたはリモートに関わらず、いかなる LLM 呼び出しにも PHI が到達しないことを保証し、ポリシーではなく設計段階で HIPAA の非識別化要件を満たします。
6.2 階層型セーフティアーキテクチャ
本システムのセーフティ保証は、4 つの独立したレイヤーで強化されています。いずれかの単一レイヤーで障害が発生しても、全体のセキュリティ姿勢が損なわれることはありません。
| レイヤー | メカニズム | 対応する課題 |
|---|---|---|
| L1: 検索ゲート | 距離ゲート(コサイン閾値 0.10) | ドメイン外のハルシネーション |
| L2: 信頼度ゲート | RAG 信頼スコア < 0.3 → ブロック | 低品質な検索根拠 |
| L3: リフレクション批評家 | フォーマット + セーフティ + LLM 含意(最大 2 回再試行) | 根拠のないまたは安全でないスペシャリスト出力 |
| L4: HITL ゲート | Tier 2 / 警告されたケースにおける必須の臨床医による中断 | 専門家の判断を要する高複雑度ケース |
レイヤー1と2は検索層で動作し、レイヤー3は生成層、レイヤー4は展開層を担当します。すべてのレイヤー3でのチェックはLLMに制御されたロジックではなく決定論的なコードとして実行されるため、敵対的プロンプトによる安全性の回避を防ぎます。
7. クリニカルインターフェース
OncoAgentのUIは、ChatGPT風の会話レイアウトを持つリアルタイムストリーミングGradioアプリケーションとして実装されています。主な機能は以下の通りです。
- 左サイドバー: セッション制御、KPIタイル、証拠ソースタブ
- メインチャットエリア: 各ノードが完了するたびに、エージェントの推論プロセスをライブで更新表示
リアルタイムの透明性は、LangGraph の .stream(stream_mode="updates") API によって実現されます。この API は各ノードが完了するたびに {node_name: node_output} という形式の辞書を出力します。UI では各ノードを、臨床医にとって読みやすいラベルにマッピングしています(例:corrective_rag → "NCCN/ESMO ガイドラインの検索")。これにより、臨床医は以下の情報を得ることができます。
全体パイプラインの可視化。
rag_confidence スコアと取得されたソース数は目立つように表示され、臨床医が各推奨事項の背後にあるガイドラインの根拠の質を即座に把握できるようになります。
インターフェースは WCAG 2.1 AA の基準に合わせて設計されました。Lucide スタイルのインライン SVG アイコン、slate-900 と sky-500 を基調としたダークテーマ、Figtree/Inter のフォントを採用しています。また、prefers-reduced-motion メディアクエリに対応し、すべてのトランジションは 200 ミリ秒以内に収まるよう制限されています。
8. 結果
| コンポーネント | 指標 | 値 |
|---|---|---|
| ナレッジベース | 取り込んだガイドライン | 70+ |
| 解析された PDF 数 | 60 秒未満で 138 件 | |
| インデックス解析エラー | 0 | |
| CRAG パイプライン | ドキュメント評価の成功率(修正後) | 100% |
| RAG 信頼度スコア(子宮がんテスト) | 2.3+(修正前は 0.0) | |
| 並列評価レイテンシ(3〜5 ドキュメント) | < 5 秒 | |
| 複雑度ルーター | ステージ IV 膵臓がん + KRAS + BRCA2 | スコア = 0.80 → Tier 2 ✅ |
| トレーニング(Tier 1, 9B) | フル 266k サンプルのトレーニング時間 | ~50 分(推定値 5 時間と比較) |
| 定常状態のスループット | ~11.3–16 秒/ステップ | |
| GPU 利用率(MI300X) | ~70% ピーク | |
| VRAM 利用率(Unsloth) | ~64 GB / 192 GB | |
| チェックポイント-1000 時点のトレーニング損失 | ~0.05 | |
| 合成データのスループット(MI300X vs. API) | 6,800 vs. 120 件/時(56 倍 ↑) | |
| 合成コーパスの拒否率 | 0.65% | |
| グラフトポロジー | コンパイル済みノードの検証数 | 8 / 8 |
| モジュールテストスイートの合格数 | 6 / 6 | |
| UI | トリアージ中のブラウザタイムアウト | 0 |
| UI レンダリングレイテンシ | < 200 ms |
9. ディスカッション
9.1 ハードウェア主権は臨床現場の必須要件
OncoAgent のスタック全体(トレーニング、推論、RAG、UI)をクラウド API に依存せず、単一の AMD MI300X インスタン上で完結して実行できる能力は、単なるエンジニアリング上の利便性ではありません。HIPAA(米国)、GDPR(EU)、および同様の国内枠組みによって規制される病院環境では、データを制御されたインフラ内に維持する法的・倫理的義務が絶対的なものです。OncoAgent は、この制約の範囲内でも最先端のマルチエージェント型臨床 AI の実現が可能であることを示しています。
9.2 スループットにおける画期的な進展
合成データ生成を約 120 件/時間から約 6,800 件/時間に加速させた 56 倍の性能向上と、トレーニング時間を約 6 倍に短縮した結果は、時間制約のある環境におけるドメイン特化型のファインチューニングの実現可能性に対して、実用的な貢献を果たすものです。これらの結果は、AMD の CDNA3 アーキテクチャが Unsloth の Triton カーネル最適化と SFT シーケンスパッキングを組み合わせることで、標準的な HuggingFace トレーニングパイプラインではまだ十分に活用されていない可能性があることを示唆しています。つまり、根本的なモデルアーキテクチャを変更することなく、このパフォーマンスの差を埋めることが可能なのです。
9.3 限界
いくつかの限界について言及しておく必要があります。
- トレーニング用コーパスは、約 36% が合成データで生成されたケースに依存しています。臨床精度については、認定腫瘍医の判断との検証を大規模に行った実績はまだありません。
現在の知識ベースは主に英語の NCCN ガイドラインを網羅していますが、ESMO や非英語圏の臨床データセットについては今後の課題として残されています。
Tier 1 アダプターは、より長い学習曲線におけるチェックポイント 1000 の時点に相当します。完全な収束と、MedQA や USMLE スタイルのがん分野サブセットを含む下流タスクでの臨床ベンチマーク評価は、今後のリリースで予定されています。
10. 結論
OncoAgent は、最先端のマルチエージェント設計パターン、ドメイン固有のファインチューニング、そして 4 つの段階からなる根拠に基づく検索パイプラインを統合した、がん治療のための完全かつオープンソースでプライバシーを保護する臨床意思決定支援アーキテクチャを実現しました。
このシステムは、本番環境向けの臨床 AI に専用インフラが必須ではないことを示しています。266k サンプルの QLoRA ファインチューニング、70 以上のガイドラインに基づく RAG(検索拡張生成)、8 ノード構成の LangGraph オーケストレーション、3 層構造の反射型安全性検証、リアルタイム臨床ストリーミング UI を含むフルスタックが、単一の AMD Instinct MI300X インスタンス上で ROCm 環境下で動作します。
アーキテクチャ上の貢献、特に Corrective RAG(修正型 RAG)、Reflexion(自己反省)、HITL(人間による監視)ゲート機能を単一の整合性のある安全性スタックに統合した点は、ハルシネーション(幻覚)の結果が生命に関わるドメイン固有の臨床 AI 展開において、再現可能な設計図となっています。
すべてのコード、アダプター重み、および OncoCoT 合成コーパスは、Hugging Face Spaces と GitHub で公開されます。
参考文献
- Singhal, K. et al. (2023). Large language models encode clinical knowledge. *Nature*, 620, 172–180.
Nori, H. 他 (2023). 一般基盤モデルは専門特化型微調整に勝てるか?医療におけるケーススタディ。*arXiv:2311.16452*.
Wang, L. 他 (2024). 大規模言語モデルに基づく自律的エージェントに関する調査。*Frontiers of Computer Science*, 18(6), 186345.
Shi, W. 他 (2024). 修正型検索拡張生成 (Corrective Retrieval Augmented Generation)。*arXiv:2401.15884*.
Shinn, N. 他 (2023). 言語的強化学習を用いた言語エージェント:Reflexion。*NeurIPS 2023*.
Nogueira, R., Cho, K. (2019). BERT を用いたパッセージ再ランク付け。*arXiv:1901.04085*.
Gao, L. 他 (2022)。関連性ラベルなしで正確なゼロショット密度検索を行う方法。*arXiv:2212.10496*.
Hu, E.J. 他 (2021). LoRA:大規模言語モデルの低ランク適応。*arXiv:2106.09685*.
Dettmers, T. 他 (2023)。量子化された LLM の効率的な微調整:QLoRA。*NeurIPS 2023*.
Han, S. 他 (2024). LangGraph:LLM を用いたステートフルなマルチアクターアプリケーションの構築。*LangChain Technical Report*.
OncoAgent は臨床判断を支援するためのツールとして設計されています。すべての出力は、実際の臨床応用を行う前に、資格を持つ医療専門家のレビューが必要です。
原文を表示
authors:
- user: oncoagent-research
tags:
- oncology
- multi-agent
- LangGraph
- RAG
- QLoRA
- AMD
- open-source
- clinical-ai
- healthcare
OncoAgent: A Dual-Tier Multi-Agent Framework for Privacy-Preserving Oncology Clinical Decision Support
*Technical preprint · May 2026 · OncoAgent Research Group*
Abstract
We present OncoAgent, an open-source, privacy-preserving clinical decision support system for oncology. OncoAgent combines a dual-tier fine-tuned LLM architecture with a state-of-the-art multi-agent LangGraph topology, a four-stage Corrective RAG pipeline over 70+ physician-grade NCCN and ESMO guidelines, and a three-layer reflexion safety validator enforcing a strict Zero-PHI policy.
The system routes clinical queries through an additive complexity scorer to either a 9B parameter speed-optimised model (Tier 1) or a 27B deep-reasoning model (Tier 2), both fine-tuned via QLoRA on a corpus of 266,854 real and synthetically generated oncological cases using the Unsloth framework on AMD Instinct MI300X hardware (192 GB HBM3).
Sequence packing on MI300X enabled full-dataset fine-tuning in approximately 50 minutes — a 56× throughput acceleration over API-based generation. Post-fix, CRAG document grading achieved a 100% success rate with a mean RAG confidence score of 2.3+. The complete system is 100% open source and deployable on-premises, eliminating proprietary cloud API dependency and preserving patient data sovereignty.
Keywords: clinical decision support, oncology AI, multi-agent systems, retrieval-augmented generation, QLoRA, AMD ROCm, open-source healthcare AI, HITL safety, LangGraph, Corrective RAG
1. Introduction
Oncology is one of the most information-dense and cognitively demanding domains in clinical medicine. The volume, heterogeneity, and rapid evolution of evidence-based guidelines — from the National Comprehensive Cancer Network (NCCN) to the European Society for Medical Oncology (ESMO) — create a persistent knowledge gap between published evidence and bedside practice.
AI-assisted clinical decision support systems hold transformative potential for closing this gap, yet most commercially available systems fail in three critical ways:
- Hallucinated recommendations not grounded in validated guidelines
- Cloud API dependency that precludes on-premises deployment in privacy-sensitive hospital environments
- Monolithic LLM architectures prone to context saturation under complex multi-comorbidity presentations
OncoAgent is designed around three core principles:
- Architectural decomposition: Clinical reasoning is decomposed across eight specialised LangGraph nodes, each with a bounded, auditable function.
- Grounded generation: All model outputs are anchored to a curated vector knowledge base through a four-stage retrieval pipeline with explicit relevance gating.
- Hardware sovereignty: The full inference and training stack runs natively on AMD Instinct MI300X using ROCm and open-source frameworks — enabling hospital deployment without data exfiltration.
2. Related Work
2.1 Clinical LLMs and Decision Support
Large language models have demonstrated significant promise in clinical NLP tasks including diagnostic coding, literature summarisation, and patient communication. Domain-specific fine-tuning approaches — exemplified by BioMedLM, Med-PaLM 2, and ClinicalBERT — consistently improve performance on medical benchmarks over general-purpose models. OncoAgent extends this line of work by targeting the specific subdomain of oncological triage and treatment pathway recommendation, where hallucination consequences are most severe.
2.2 Multi-Agent Architectures
Decomposed multi-agent systems have emerged as a principled approach to complex reasoning tasks. OncoAgent synthesises four canonical SOTA patterns:
- Claude Code pattern — deterministic safety harnesses separated from LLM reasoning
- Hermes Agent pattern — structured tool-calling with per-session memory isolation
- Corrective RAG (Shi et al., 2024) — document relevance grading and query reformulation
- Reflexion (Shinn et al., 2023) — self-correcting generation via feedback-augmented retry loops
2.3 Retrieval-Augmented Generation in Medicine
Standard bi-encoder retrieval is ill-suited for clinical domains where terminological precision is critical (e.g., "tyrosine kinase inhibitor" vs. "TKI"). OncoAgent implements a multi-stage pipeline with cross-encoder re-ranking, and integrates Hypothetical Document Embeddings (HyDE; Gao et al., 2022) to resolve medical synonym mismatches by projecting natural language queries into the guideline embedding space.
3. System Architecture
3.1 Overview
OncoAgent is implemented as a stateful directed graph using LangGraph. The system state is represented as an immutable AgentState TypedDict containing 11 logical sections and approximately 30 typed keys. Each node appends to specific keys without mutating upstream data, preserving a complete audit trail.
The 8-node topology is:
Router → Ingestion → Corrective RAG → Specialist ↔ Critic → HITL Gate → Formatter → END
↓
Fallback → END
Key properties:
- 5 conditional edges
- 1 reflexion retry loop (max 2 iterations)
- 1 mandatory HITL interrupt for high-complexity or low-confidence outputs
3.2 Complexity Router and Model Tiering
Case complexity is quantified using a weighted additive model prior to specialist invocation:
S = w_cancer + w_stage + w_mutations + w_treatment
Where:
| Factor | Condition | Weight |
|---|---|---|
| Cancer type | Rare | +0.40 |
| Cancer type | Unknown primary | +0.30 |
| Stage | Stage IV | +0.25 |
| Stage | Stage III | +0.15 |
| Mutations | ≥2 identified | +0.30 |
| Mutations | Single | +0.15 |
| Prior treatment | Any keyword match | +0.10 |
Decision boundary: S ≥ 0.5 → Tier 2 (Qwen 3.6-27B deep reasoning) · S < 0.5 → Tier 1 (Qwen 3.5-9B speed triage)
Validation: A Stage IV pancreatic carcinoma case with KRAS + BRCA2 mutations correctly produced S = 0.80, routing to Tier 2. ✅
Clinicians may also manually override the tier selection through the UI.
3.3 Corrective RAG with Document Grading
The CRAG node grades each retrieved document for clinical relevance before forwarding to the Specialist. Documents that fail binary relevance classification trigger automatic query reformulation (max 1 retry). This eliminates the primary hallucination source in RAG pipelines — retrieval of plausibly titled but semantically irrelevant content.
After migrating from Qwen 3.5 to Qwen 2.5 Instruct for the grading step, success rate improved from 0% → 100%, with RAG confidence score reaching 2.3+ on uterine cancer triage tests.
3.4 Reflexion Safety Loop (Critic Node)
The Critic node runs a three-layer validation cascade before any output reaches the HITL gate:
- Formatting check — validates structural compliance with the OncoCoT output schema
- Safety check — deterministic rule-based scan for prohibited output patterns (absolute dosing without guideline citation, drug interaction omissions, etc.)
- LLM entailment check — verifies that the Specialist's recommendation is fully supported by the retrieved RAG context
On FAIL, the Critic's specific feedback is injected back into the Specialist context for a retry (max 2 iterations). Crucially, the Critic runs as deterministic code, not LLM-controlled logic — ensuring safety enforcement cannot be bypassed by adversarial prompting.
3.5 Human-in-the-Loop Gate and Fallback
The HITL gate provides a mandatory clinician interrupt for all Tier 2 cases and any output where rag_confidence < 0.3. A dedicated Fallback node catches unrecoverable failures and returns a clinically safe refusal — "Información no concluyente en las guías provistas" — avoiding hallucinated alternatives under any failure mode.
3.6 Per-Patient Memory Isolation
The PatientMemoryStore module assigns each patient session a unique thread_id (format PT-XXXX), passed as a configurable parameter to LangGraph's native checkpointing system. This enforces strict per-patient memory isolation while enabling iterative multi-turn consultations within a session.
4. Knowledge Base Construction and RAG Pipeline
4.1 Guideline Ingestion and Sanitisation
The knowledge base was constructed from 77 direct physician guideline PDFs identified by a concurrent web scraper that processed 138 NCCN detail pages in under 60 seconds. Text extraction used PyMuPDF (fitz) for block-level structural parsing, preserving the semantic reading order of multi-column clinical layouts.
A regex-based sanitisation step strips institutional branding prior to ingestion. Patient-facing materials are excluded via heuristic filtering. The resulting corpus covers 70+ professional oncological guidelines across all major cancer types including HCC, NSCLC, breast, colorectal, and neuroendocrine tumours.
4.2 Medical Embeddings and Vector Store
Standard general-purpose embedding models (e.g., all-MiniLM-L6-v2) were rejected due to poor clinical terminology semantics. OncoAgent uses:
- Embeddings: pritamdeka/S-PubMedBert-MS-MARCO — fine-tuned on PubMed and MS-MARCO for asymmetric medical semantic search
- Vector store: Local ChromaDB persistent index — zero-cloud, Zero-PHI compliant
4.3 Four-Stage Retrieval Pipeline
| Stage | Component | Function | Configuration |
|---|---|---|---|
| 1. Recall | PubMedBERT Bi-Encoder | Wide-net retrieval | top-15 candidates |
| 2. Distance Gate | Cosine Distance Filter | Anti-hallucination floor | threshold = 0.10 |
| 3. Re-Ranking | Cross-Encoder (MS-MARCO MiniLM) | Joint query-document relevance | top-5 returned |
| 4. Context Trimming | Character-Budget Limiter | Fit within LLM context window | max 6,000 chars |
Anti-Hallucination Policy: Any query failing Stage 2 returns "Información no concluyente en las guías provistas" without invoking the Specialist. This guarantees zero hallucinated recommendations for out-of-domain clinical inputs.
Distance threshold calibration against the NCCN corpus established:
- Medical-query distances: ~0.06–0.09
- Out-of-domain distances: ~0.11–0.15
- Hard threshold: 0.10
An optional HyDE module generates a hypothetical guideline paragraph and uses it as the embedding anchor for Stage 1 retrieval, resolving synonym mismatches (e.g., "neoplasia pulmonar" vs. "lung carcinoma").
5. Dual-Tier QLoRA Fine-Tuning
5.1 Training Corpus: OncoCoT (266,854 Samples)
| Source | Type | Samples | Notes |
|---|---|---|---|
| PMC-Patients | Real clinical cases | ~85,000 | PubMed Central patient reports |
| Asclepius | Real clinical data | ~85,000 | Curated medical QA corpus |
| OncoCoT Synthetic | Synthetic (Qwen 3.6-27B) | 96,941 | Generated on MI300X at ~6,800 cases/hr · rejection rate 0.65% |
| Total | — | 266,854 | 90/10 train/eval split · SHA-256 hashed · deduplicated |
All cases use ChatML template for Qwen compatibility. Thinking tokens were disabled (chat_template_kwargs: {enable_thinking: False}) to prevent JSON parse corruption.
5.2 QLoRA Configuration
Both tiers use 4-bit NormalFloat4 (NF4) quantisation via BitsAndBytes, with LoRA adapters targeting all major projection modules: q_proj, k_proj, v_proj, o_proj, gate_proj, up_proj, down_proj.
| Parameter | Tier 1 (Qwen 3.5-9B) | Tier 2 (Qwen 3.6-27B) |
|---|---|---|
| Per-device batch size | 4 | 2 |
| Gradient accumulation | 4 | 8 |
| Effective batch size | 16 | 16 |
| Learning rate | 2×10⁻⁴ | 1×10⁻⁴ |
| LoRA rank (*r*) | 16 | 32 |
| Sequence packing | True, 2048 tokens | True, 2048 tokens |
| Early stopping | Patience = 3 | Patience = 3 |
| Quantisation | NF4 4-bit | NF4 4-bit |
5.3 AMD MI300X Optimisation with Unsloth
The original HuggingFace transformers + PEFT pipeline failed on the MI300X due to two independent issues:
- Tokenisation conflicts between trl v0.24.0 strict EOS validation and the Qwen3VLProcessor wrapper
- Insufficient VRAM headroom for target effective batch sizes under standard precision
Migration to Unsloth's FastLanguageModel resolved both simultaneously:
- VRAM reduction: ~60% drop in peak usage (from OOM to stable ~64 GB on 192 GB device)
- Training speed: ~2× improvement to ~16 s/step at effective batch 16
AMD ROCm-specific adaptations required:
# 1. Pass inner tokenizer, not the Qwen3VLProcessor wrapper
trainer = SFTTrainer(tokenizer=model.get_tokenizer(), ...)
# 2. Prevent incompatible EOS injection
training_args = SFTConfig(eos_token=None, ...)
# 3. AMD-specific bitsandbytes for ROCm 6.2/gfx942
# pip install bitsandbytes --find-links <amd-continuous-release-wheel>
# 4. BF16 workaround (is_bf16_supported() returns False on ROCm despite hardware support)
training_args = TrainingArguments(fp16=True, ...)
# Final deployment uses native BF16:
model = AutoModelForCausalLM.from_pretrained(..., torch_dtype=torch.bfloat16)
5.4 Sequence Packing and Throughput Breakthrough
Sequence packing via packing=True in SFTConfig concatenates multiple short clinical records into single 2048-token sequences, eliminating padding overhead and drastically reducing forward pass count.
The combined effect of Unsloth kernels and sequence packing on the MI300X enabled full-dataset fine-tuning of the 266,854-sample corpus in approximately 50 minutes — against an initial 5-hour estimate — representing roughly a 6× training time compression. GPU utilisation peaked at ~70%, with consistent throughput at ~11.3 s/iteration.
Checkpoint-1000 results: Tier 1 adapter trained for 1,339 steps · training loss ≈ 0.05 · adapter size 187 MB · verified against 11-file manifest including adapter_model.safetensors, adapter_config.json, and tokenizer.json.
The system supports adaptive inference routing: local BF16 inference via the LocalModelManager singleton when ROCm is available, with graceful fallback to the Featherless.ai API for high availability.
6. Safety and Privacy Framework
6.1 Zero-PHI Policy
A dedicated Zero-PHI redaction node runs as the first processing step in the Ingestion node, before any text reaches an LLM. It identifies and replaces Protected Health Information (patient names, dates of birth, MRN numbers, addresses, facility identifiers) with clinically neutral placeholders. The redacted representation is stored in AgentState; the original text is discarded.
This ensures that no PHI reaches any downstream LLM call — local or remote — and satisfies HIPAA de-identification requirements by design rather than policy.
6.2 Layered Safety Architecture
The system's safety guarantees are enforced at four independent layers. A failure at any single layer does not compromise the overall posture.
| Layer | Mechanism | Addresses |
|---|---|---|
| L1: Retrieval Gate | Distance Gate (cosine threshold 0.10) | Out-of-domain hallucinations |
| L2: Confidence Gate | RAG confidence score Layers 1 and 2 operate at the retrieval layer. Layer 3 at the generation layer. Layer 4 at the deployment layer. All Layer 3 checks run as deterministic code — not LLM-controlled logic — preventing safety bypass via adversarial prompting.
7. Clinical Interface
The OncoAgent UI is implemented as a real-time streaming Gradio application in a ChatGPT-style conversational layout. It features:
- Left sidebar: Session controls, KPI tiles, evidence source tabs
- Main chat area: Live agentic reasoning updates as each node completes
Real-time transparency is achieved via LangGraph's .stream(stream_mode="updates") API, which emits {node_name: node_output} dictionaries as each node completes. The UI maps each node to a human-readable clinical label (e.g., corrective_rag → *"Retrieving NCCN/ESMO guidelines"*), providing clinicians with full pipeline visibility.
The rag_confidence score and retrieved source count are prominently surfaced, giving clinicians immediate visibility into the quality of guideline grounding behind each recommendation.
The interface was designed to WCAG 2.1 AA standards — Lucide-style inline SVG icons, slate-900/sky-500 dark theme, Figtree/Inter typography, prefers-reduced-motion media query, all transitions capped at 200 ms.
8. Results
| Component | Metric | Value |
|---|---|---|
| Knowledge Base | Guidelines ingested | 70+ |
| | PDFs parsed | 138 in
9. Discussion
9.1 Hardware Sovereignty as a Clinical Requirement
The ability to run the complete OncoAgent stack — training, inference, RAG, and UI — on a single AMD MI300X instance without cloud API dependencies is not merely an engineering convenience. In hospital environments governed by HIPAA (US), GDPR (EU), and equivalent national frameworks, the legal and ethical obligation to maintain data within controlled infrastructure is absolute. OncoAgent demonstrates that SOTA multi-agent clinical AI is achievable within this constraint.
9.2 The Throughput Breakthrough
The 56× synthetic data generation acceleration (from ~120 to ~6,800 cases/hr) and the ~6× training time compression together represent a significant practical contribution to the feasibility of domain-specific fine-tuning in time-constrained settings. These results suggest that AMD's CDNA3 architecture, when paired with Unsloth's Triton kernel optimisations and SFT sequence packing, may be substantially underutilised by standard HuggingFace training pipelines — and that the performance gap can be closed without changes to the underlying model architecture.
9.3 Limitations
Several limitations warrant acknowledgement:
- The training corpus relies on approximately 36% synthetically generated cases. Clinical accuracy validation against board-certified oncologist judgments has not yet been performed at scale.
- The current knowledge base covers NCCN guidelines primarily in English; ESMO and non-English clinical corpora remain for future work.
- The Tier 1 adapter represents checkpoint-1000 of a potentially longer trajectory; full convergence and downstream clinical benchmark evaluation (MedQA, USMLE-style oncology subsets) are planned for subsequent releases.
10. Conclusion
OncoAgent establishes a complete, open-source, privacy-preserving clinical decision support architecture for oncology that integrates SOTA multi-agent design patterns, domain-specific fine-tuning, and a four-stage grounded retrieval pipeline.
The system demonstrates that production-grade clinical AI does not require proprietary infrastructure: the full stack — including 266k-sample QLoRA fine-tuning, 70+ guideline RAG, eight-node LangGraph orchestration, three-layer reflexion safety validation, and real-time clinical streaming UI — runs on a single AMD Instinct MI300X instance under ROCm.
The architectural contributions — particularly the synthesis of Corrective RAG, Reflexion, and HITL gating into a single coherent safety stack — represent a replicable blueprint for domain-specific clinical AI deployments where hallucination consequences are life-critical.
All code, adapter weights, and the OncoCoT synthetic corpus will be released publicly on Hugging Face Spaces and GitHub.
References
- Singhal, K. et al. (2023). Large language models encode clinical knowledge. Nature, 620, 172–180.
- Nori, H. et al. (2023). Can generalist foundation models outcompete special-purpose tuning? Case study in medicine. arXiv:2311.16452.
- Wang, L. et al. (2024). A survey on large language model based autonomous agents. Frontiers of Computer Science, 18(6), 186345.
- Shi, W. et al. (2024). Corrective Retrieval Augmented Generation. arXiv:2401.15884.
- Shinn, N. et al. (2023). Reflexion: Language agents with verbal reinforcement learning. NeurIPS 2023.
- Nogueira, R. and Cho, K. (2019). Passage Re-ranking with BERT. arXiv:1901.04085.
- Gao, L. et al. (2022). Precise Zero-Shot Dense Retrieval without Relevance Labels. arXiv:2212.10496.
- Hu, E.J. et al. (2021). LoRA: Low-Rank Adaptation of Large Language Models. arXiv:2106.09685.
- Dettmers, T. et al. (2023). QLoRA: Efficient Finetuning of Quantized LLMs. NeurIPS 2023.
- Han, S. et al. (2024). LangGraph: Building stateful multi-actor applications with LLMs. LangChain Technical Report.
*OncoAgent is intended as a clinical decision support tool. All outputs require review by licensed medical professionals prior to any clinical application.*
関連記事
今日のまとめ
AIデイリーブリーフで今日の重要ニュースをまとめ読み