🚨 03. 例外処理とLLMによる知識注入

Exception Handling and Knowledge Injection with LLM


本節では、従来の制御系では困難だった 例外的状況や未知の事象への対応 について、
LLMを活用して「知識ベース制御」や「意味的補完」を行うアプローチを紹介します。

This section introduces an approach to handling exceptional or unknown situations in control systems by leveraging LLMs for knowledge-based control and semantic augmentation.


🔧 例外処理とは? / What is Exception Handling?


🧠 LLMが担う役割 / Role of LLMs

項目 / Function 内容 / Description
状況理解 / Situation Understanding 自然言語的異常記述を文脈理解(例:「ブザー音が鳴っている」)
Understands abnormal conditions described in natural language
原因推定 / Cause Estimation 過去知識から原因を推測(例:「過熱異常の可能性がある」)
Infers possible causes from prior knowledge
対応策提案 / Action Proposal 適切な行動を提案(例:「電源を落として30秒待ってください」)
Suggests appropriate actions
FSM補完 / FSM Integration 例外パスとして状態遷移に挿入(例:回復状態 → 通常復帰)
Adds exception paths to FSM transitions

👉 LLMは クラウド型(ChatGPT等)組み込み型(軽量LLM) の両方で利用可能です。前者は設計支援・知識参照に、後者はリアルタイムでの異常推定に強みがあります。


📘 実装例(LLM利用) / Implementation Example (with LLM)

def handle_exception(observation_text):
    prompt = f"異常が発生しました:{observation_text}。原因と対応策を述べてください。"
    return llm_respond(prompt)  # API or local embedded LLM

入力例 / Input Example

「センサが全く反応しない」「温度が急上昇している」

出力例(LLM) / Output Example (LLM)

「センサ断線の可能性があります。機器を停止し、センサ接続を確認してください。」

💬 FSMへの統合イメージ / FSM Integration Concept


🔒 安全性と制約 / Safety and Constraints


🔚 まとめ / Summary


📁 次へ / Next

📄 04_goal_reasoning.md


⬅️ 02_scenario_control.md
🏠 Part 9 トップに戻る / Back to Part 9 Top