AIKernel.NET
version: 0.0.2 / status: Refactor / edition: Draft / published: 2026-05-16 / updated: 2026-05-16

コンテキスト分離仕様

AIKernel は、LLM に渡す前に情報をカテゴリ単位で厳密に分離します。本仕様は注意(attention)を保護し、推論能力を最大化するためのものです。


1. 分離すべき項目

次の情報を推論コンテキストへ混在させてはなりません。

  • examples / samples
  • RAG fragments
  • stylistic instructions
  • past history
  • noisy information

これらは attention pollution の主因であり、推論純度を破壊します。


2. 理論的背景(Attention Pollution)

アップロード済み文書より:

"An LLM's inference capability depends on attention purity. When attention is drawn to surface structures, inference halts and the system falls into surface-mode." — Attention Pollution Theory

注意資源は有限です。抽象構造・目的・制約に集中させる必要があります。

examples、style、RAG fragments、history、noise を混在させると、次が発生します。

  • inference halt
  • surface-mode
  • hallucination の増加
  • purpose の喪失

3. Failure Modes

コンテキスト分離を強制しない場合、次の失敗が発生します。

3.1 Surface-mode

アップロード済み文書より:

"LLMs fall into surface-mode when exposed to examples. This means loss of inference capability." — Risks of Surface-Mode Failure

特徴:

  • style-only mimicry
  • no inference
  • no structural understanding
  • loss of purpose

3.2 Inference halt

  • structure に注意が向かない
  • reasoning depth が崩壊する
  • chain-of-thought が途切れる

3.3 Increased hallucination

  • RAG と context の混在が factuality を壊す

3.4 Broken deterministic replay

  • history と question の混在が再現性を壊す

4. 分離方法(3-Context Model)

AIKernel は情報を 3 つのコンテキストに分離します。


4.1 OrchestrationContext(推論用)

推論に必要な情報のみを含めます。

  • purpose
  • constraints
  • abstract structure
  • reasoning patterns

examples、style、RAG を含めてはなりません。


4.2 ExpressionContext(表現用)

— 推論完了後にのみ適用

ExpressionContext は推論が完了した後にのみ適用されます。

AIKernel は、推論(Orchestration)と表現(Expression)を物理的に分離した二段階プロセスとして扱います。

これにより、style、examples、metaphors が推論を汚染することを防ぎ、surface-mode を回避します。

ExpressionContext に含める内容:

  • style
  • examples
  • explanatory text
  • metaphors

4.3 MaterialContext(素材用)

— 構造化が必須

MaterialContext 内の RAG fragments や外部情報は、OrchestrationContext へ生のまま渡してはなりません。

Material 処理手順:

  1. Retrieval(RAG / Provider)
  2. Normalization(不要データの除去)
  3. Structuring(分解・抽象化・意味の単位化)
  4. 必要部分のみを OrchestrationContext へ転送

これは、RAG を生で LLM へ渡すアプローチと本質的に異なります。構造化は hallucination 抑制の中核です。


5. History の扱い

— Material と Orchestration の境界

history は主要な attention polluter であり、慎重に扱う必要があります。


5.1 history を Material として扱う場合

  • 過去の事実を参照する場合
  • history を外部データとして扱うべき場合
  • history の抽象化・要約が必要な場合

この場合、history は MaterialContext に置き、構造化してから OrchestrationContext へ転送します。


5.2 history を Orchestration として扱う場合

  • 現在の purpose や constraints に直接影響する場合
  • 会話継続に必要な最小コンテキストのみが必要な場合

この場合でも、生の history を渡してはなりません。


5.3 禁止事項

  • 生の history を OrchestrationContext に混在させない
  • 未処理の長い history を LLM に渡さない

AIKernel は history を「material」と「最小 orchestration context」に分離し、混在を避けることで deterministic replay を保護します。


6. AIKernel における実装保証

Kernel / Pipeline / Context Isolation は、この仕様を構造的に強制するよう設計されています。

  • Kernel は 3 つのコンテキストを分離する
  • Pipeline は各ステップでコンテキストを明示する
  • ProviderRouter は MaterialContext を直接渡さない
  • LlmController は推論時に ExpressionContext を混在させない

これにより、カテゴリ混在を構造的に不可能にします。


7. 目的(Why)

コンテキスト分離の目的:

  • inference purity の最大化
  • attention pollution の防止
  • surface-mode の回避
  • LLM の抽象推論能力の最大化
  • deterministic replay の保証
  • OS レベル整合性の維持

8. 関連文書


変更履歴

  • v0.0.0 / v0.0.0.0: 初期ドラフト
  • v0.0.1 (2026-05-06): ドキュメント規約に基づくバージョン更新
Source: architecture/2.CONTEXT_ISOLATION_SPEC-jp.md