mcpField
C
crisis-detection-intervention-ai

crisis-detection-intervention-ai

github.com/curiositechその他257217 回インストール2 日前に更新
リポジトリ

crisis-detection-intervention-ai について

アプリや支援プラットフォーム向けに、メンタルヘルス危機の検出と安全なエスカレーションを案内するスキルです。人による確認、即時の相談先案内、データ保護、自動検出の限界を重視します。

主な機能

  1. 01メンタルヘルス特化のシグナル検出
  2. 02人による確認とエスカレーション
  3. 03相談窓口とリソースの即時案内
  4. 04機微データの保護方法
  5. 05NLPモデルの選定ガイダンス

活用シーン

  1. 01日記の懸念内容を確認対象として抽出
  2. 02支援グループの投稿をリスク監視
  3. 03セラピストによるメッセージの優先度判断
  4. 04相談員へのエスカレーション手順の設計

インストール

コマンドをコピーしてターミナルで実行します。

$npx skills add https://github.com/curiositech/some_claude_skills --skill crisis-detection-intervention-ai

インストール後、Claude Code で/crisis-detection-intervention-aiを入力して読み込まれたか確認します。

同梱ファイル

SKILL.md と一緒にインストールされる参考資料やスクリプト。

.claude-plugin/
plugin.json
references/
intervention-protocols.md
mental-health-nlp.md
crisis-resources.md
scripts/
model_evaluator.ts
crisis_detector.ts

詳細

危機の検出と介入 AI

メンタルヘルスの危機を検出し、安全で倫理的な介入プロトコルを実施するエキスパートです。

⚠️ 倫理に関する免責事項

このスキルは危機の検出を支援するものであり、危機への対応を行うものではありません。

✅ 適切な用途:

  • 懸念されるコンテンツにフラグを付け、人間による確認を促す
  • ユーザーを専門的な支援リソースにつなぐ
  • 危機カウンセラーにエスカレーションする
  • すぐに利用できるホットライン情報を提供する

❌ 次の代わりにはなりません:

  • 資格を持つセラピスト
  • 緊急サービス(911)
  • 医学的診断
  • 専門的なメンタルヘルス治療

必ず危機相談窓口を案内してください:全米自殺予防ライフライン:988


使用する場面

✅ 次の用途に使用します:

  • メンタルヘルスのジャーナリングアプリ
  • 回復支援コミュニティのプラットフォーム
  • サポートグループのモニタリング
  • オンラインセラピーのプラットフォーム
  • 危機相談テキストラインとの連携

❌ 次の用途には使用しません:

  • 一般的な感情分析(標準ツールを使用してください)
  • 医学的診断(資格がありません)
  • 人間による確認を伴わない自動応答
  • 専門的な危機カウンセラーの代替

簡易判断フローチャート

Detected concerning content?
├── Immediate danger? → Escalate to crisis counselor + show 988
├── Suicidal ideation? → Flag for review + show resources
├── Substance relapse? → Connect to sponsor + resources
├── Self-harm mention? → Gentle check-in + resources
└── General distress? → Supportive response + resources

技術の選定

メンタルヘルス向け NLP モデル(2024年)
モデル最適な用途精度レイテンシ
MentalBERTメンタルヘルス関連テキスト89%50ms
GPT-4 + Few-shot危機の検出92%200ms
RoBERTa-Mentalうつ病の検出87%40ms
カスタムファインチューニング済み BERT特定分野向け90%+60ms

タイムライン:

  • 2019年:メンタルヘルス向けに BERT をファインチューニング
  • 2021年:MentalBERT をリリース
  • 2023年:GPT-4 がゼロショットでの危機検出において高い性能を示す
  • 2024年:特定の症状に特化したモデル

よくあるアンチパターン

アンチパターン 1:汎用的な感情分析を使う

初心者の考え方:「否定的な感情 = 危機」

問題:メンタルヘルスに関する表現は微妙なニュアンスを含み、文脈に左右されます。

誤ったアプローチ:

// ❌ Generic sentiment misses mental health signals
const sentiment = analyzeSentiment(text);

if (sentiment.score < -0.5) {
  alertCrisis();  // Too broad!
}

誤りの理由:「疲れた」と「生きることに疲れた」は、同じ感情として分析されても意味は異なります。

正しいアプローチ:

// ✅ Mental health-specific model
import { pipeline } from '@huggingface/transformers';

const detector = await pipeline('text-classification', 'mental/bert-base-uncased');

const result = await detector(text, {
  labels: ['suicidal_ideation', 'self_harm', 'substance_relapse', 'safe']
});

if (result[0].label === 'suicidal_ideation' && result[0].score > 0.8) {
  await escalateToCrisisCounselor({
    text,
    confidence: result[0].score,
    timestamp: Date.now()
  });

  // IMMEDIATELY show crisis resources
  showCrisisResources({
    phone: '988',
    text: 'Text "HELLO" to 741741',
    chat: 'https://988lifeline.org/chat'
  });
}

時代背景:

  • 2015年:ルールベースのキーワードマッチング
  • 2020年:メンタルヘルス向けの BERT ファインチューニング
  • 2024年:文脈理解を備えたマルチラベルモデル

アンチパターン 2:人間による確認なしで自動応答する

問題:AI は共感の代わりにはなれず、苦痛を増大させるおそれがあります。

誤ったアプローチ:

// ❌ AI auto-responds to crisis
if (isCrisis(text)) {
  await sendMessage(userId, "I'm concerned about you. Are you okay?");
}

誤りの理由:

  • 機械的で、気持ちを否定されたように感じる
  • 苦痛を増大させる可能性がある
  • 人間による判断がない

正しいアプローチ:

// ✅ Flag for human review, show resources
if (isCrisis(text)) {
  // 1. Flag for counselor review
  await flagForReview({
    userId,
    text,
    severity: 'high',
    detectedAt: Date.now(),
    requiresImmediate: true
  });

  // 2. Notify on-call counselor
  await notifyOnCallCounselor({
    userId,
    summary: 'Suicidal ideation detected',
    urgency: 'immediate'
  });

  // 3. Show resources (no AI message)
  await showInAppResources({
    type: 'crisis_support',
    resources: [
      { name: '988 Suicide & Crisis Lifeline', link: 'tel:988' },
      { name: 'Crisis Text Line', link: 'sms:741741' },
      { name: 'Chat Now', link: 'https://988lifeline.org/chat' }
    ]
  });

  // 4. DO NOT send automated "are you okay" message
}

人間による確認の流れ:

AI Detection → Flag → On-call counselor notified → Human reaches out

アンチパターン 3:すぐに利用できる支援リソースを提供しない

問題:危機にあるユーザーには、後でではなく、今すぐ支援が必要です。

誤ったアプローチ:

// ❌ Just flags, no immediate help
if (isCrisis(text)) {
  await logCrisisEvent(userId, text);
  // User left with no resources
}

正しいアプローチ:

// ✅ Immediate resources + escalation
if (isCrisis(text)) {
  // Show resources IMMEDIATELY (blocking modal)
  await showCrisisModal({
    title: 'Resources Available',
    resources: [
      {
        name: '988 Suicide & Crisis Lifeline',
        description: 'Free, confidential support 24/7',
        action: 'tel:988',
        type: 'phone'
      },
      {
        name: 'Crisis Text Line',
        description: 'Text support with trained counselor',
        action: 'sms:741741',
        message: 'HELLO',
        type: 'text'
      },
      {
        name: 'Chat with counselor',
        description: 'Online chat support',
        action: 'https://988lifeline.org/chat',
        type: 'web'
      }
    ],
    dismissible: true,  // User can close, but resources shown first
    analytics: { event: 'crisis_resources_shown', source: 'ai_detection' }
  });

  // Then flag for follow-up
  await flagForReview({ userId, text, severity: 'high' });
}

アンチパターン 4:危機に関するデータを安全でない方法で保存する

問題:危機に関するコンテンツは、非常に機微な保護対象保健情報(PHI)です。

誤ったアプローチ:

// ❌ Plain text storage
await db.logs.insert({
  userId: user.id,
  type: 'crisis',
  content: text,  // Stored in plain text!
  timestamp: Date.now()
});

誤りの理由:データ侵害により、最も脆弱な瞬間がさらされます。

正しいアプローチ:

// ✅ Encrypted, access-logged, auto-deleted
import { encrypt, decrypt } from './encryption';

await db.crisisEvents.insert({
  id: generateId(),
  userId: hashUserId(user.id),  // Hash, not plain ID
  contentHash: hashContent(text),  // For deduplication only
  encryptedContent: encrypt(text, process.env.CRISIS_DATA_KEY),
  detectedAt: Date.now(),
  reviewedAt: null,
  reviewedBy: null,
  autoDeleteAt: Date.now() + (30 * 24 * 60 * 60 * 1000),  // 30 days
  accessLog: []
});

// Log all access
await logAccess({
  eventId: crisisEvent.id,
  accessedBy: counselorId,
  accessedAt: Date.now(),
  reason: 'Review for follow-up',
  ipAddress: hashedIp
});

// Auto-delete after retention period
schedule.daily(() => {
  db.crisisEvents.deleteMany({
    autoDeleteAt: { $lt: Date.now() }
  });
});

HIPAA の要件:

  • 保存時および転送時の暗号化
  • アクセスログの記録
  • 保持期間終了後の自動削除
  • 必要最小限のアクセス

アンチパターン 5:エスカレーションプロトコルがない

問題:検出から人間による介入へつなぐ明確な経路がありません。

誤ったアプローチ:

// ❌ Flags crisis but no escalation process
if (isCrisis(text)) {
  await db.flags.insert({ userId, text, flaggedAt: Date.now() });
  // Now what? Who responds?
}

正しいアプローチ:

// ✅ Clear escalation protocol
enum CrisisSeverity {
  LOW = 'low',        // Distress, no immediate danger
  MEDIUM = 'medium',  // Self-harm thoughts, no plan
  HIGH = 'high',      // Suicidal ideation with plan
  IMMEDIATE = 'immediate'  // Imminent danger
}

async function escalateCrisis(detection: CrisisDetection): Promise<void> {
  const severity = assessSeverity(detection);

  switch (severity) {
    case CrisisSeverity.IMMEDIATE:
      // Notify on-call counselor (push notification)
      await notifyOnCall({
        userId: detection.userId,
        severity,
        requiresResponse: 'immediate',
        text: detection.text
      });

      // Send SMS to backup on-call if no response in 5 min
      setTimeout(async () => {
        if (!await hasResponded(detection.id)) {
          await notifyBackupOnCall(detection);
        }
      }, 5 * 60 * 1000);

      // Show 988 modal (blocking)
      await show988Modal(detection.userId);
      break;

    case CrisisSeverity.HIGH:
      // Notify on-call counselor (email + push)
      await notifyOnCall({ severity, requiresResponse: '1 hour' });

      // Show crisis resources
      await showCrisisResources(detection.userId);
      break;

    case CrisisSeverity.MEDIUM:
      // Add to review queue for next business day
      await addToReviewQueue({ priority: 'high' });

      // Suggest self-help resources
      await suggestResources(detection.userId, 'coping_strategies');
      break;

    case CrisisSeverity.LOW:
      // Add to review queue
      await addToReviewQueue({ priority: 'normal' });
      break;
  }

  // Always log for audit
  await logEscalation({
    detectionId: detection.id,
    severity,
    actions: ['notified_on_call', 'showed_resources'],
    timestamp: Date.now()
  });
}

実装パターン

パターン 1:複数のシグナルによる検出
interface CrisisSignal {
  type: 'suicidal_ideation' | 'self_harm' | 'substance_relapse' | 'severe_distress';
  confidence: number;
  evidence: string[];
}

async function detectCrisisSignals(text: string): Promise<CrisisSignal[]> {
  const signals: CrisisSignal[] = [];

  // Signal 1: NLP model
  const nlpResult = await mentalHealthNLP(text);
  if (nlpResult.score > 0.75) {
    signals.push({
      type: nlpResult.label,
      confidence: nlpResult.score,
      evidence: ['NLP model detection']
    });
  }

  // Signal 2: Keyword matching (backup)
  const keywords = detectKeywords(text);
  if (keywords.length > 0) {
    signals.push({
      type: 'suicidal_ideation',
      confidence: 0.6,
      evidence: keywords
    });
  }

  // Signal 3: Sentiment + context
  const sentiment = await sentimentAnalysis(text);
  const hasHopelessness = /no (hope|point|reason|future)/i.test(text);

  if (sentiment.score < -0.8 && hasHopelessness) {
    signals.push({
      type: 'severe_distress',
      confidence: 0.7,
      evidence: ['Extreme negative sentiment + hopelessness language']
    });
  }

  return signals;
}
パターン 2:安全なキーワードマッチング
const CRISIS_KEYWORDS = {
  suicidal_ideation: [
    /\b(kill|end|take)\s+(my|own)\s+life\b/i,
    /\bsuicide\b/i,
    /\bdon'?t\s+want\s+to\s+(live|be here|exist)\b/i,
    /\bbetter off dead\b/i
  ],
  self_harm: [
    /\b(cut|cutting|hurt)\s+(myself|me)\b/i,
    /\bself[- ]harm\b/i
  ],
  substance_relapse: [
    /\b(relapsed|used|drank)\s+(again|today)\b/i,
    /\bback on\s+(drugs|alcohol)\b/i
  ]
};

function detectKeywords(text: string): string[] {
  const matches: string[] = [];

  for (const [type, patterns] of Object.entries(CRISIS_KEYWORDS)) {
    for (const pattern of patterns) {
      if (pattern.test(text)) {
        matches.push(type);
      }
    }
  }

  return [...new Set(matches)];  // Deduplicate
}
パターン 3:GPT-4 の Few-Shot 検出
import Anthropic from '@anthropic-ai/sdk';

const client = new Anthropic({ apiKey: process.env.ANTHROPIC_API_KEY });

async function detectWithClaude(text: string): Promise<CrisisDetection> {
  const response = await client.messages.create({
    model: 'claude-3-5-sonnet-20241022',
    max_tokens: 200,
    messages: [{
      role: 'user',
      content: `You are a mental health crisis detection system. Analyze this text for crisis signals.

Text: "${text}"

Respond in JSON:
{
  "is_crisis": boolean,
  "severity": "none" | "low" | "medium" | "high" | "immediate",
  "signals": ["suicidal_ideation" | "self_harm" | "substance_relapse"],
  "confidence": 0.0-1.0,
  "reasoning": "brief explanation"
}

Examples:
- "I'm thinking about ending it all" → { "is_crisis": true, "severity": "high", "signals": ["suicidal_ideation"], "confidence": 0.95 }
- "I relapsed today, feeling ashamed" → { "is_crisis": true, "severity": "medium", "signals": ["substance_relapse"], "confidence": 0.9 }
- "Had a tough day at work" → { "is_crisis": false, "severity": "none", "signals": [], "confidence": 0.95 }`
    }]
  });

  const result = JSON.parse(response.content[0].text);
  return result;
}

本番環境向けチェックリスト

□ Mental health-specific NLP model (not generic sentiment)
□ Human review required before automated action
□ Crisis resources shown IMMEDIATELY (988, text line)
□ Clear escalation protocol (severity-based)
□ Encrypted storage of crisis content
□ Access logging for all crisis data access
□ Auto-deletion after retention period (30 days)
□ On-call counselor notification system
□ Backup notification if no response
□ False positive tracking (improve model)
□ Regular model evaluation with experts
□ Ethics review board approval

使用する場面と避ける場面

シナリオ適切か
回復支援のジャーナリングアプリ✅ はい - 再発をモニタリング
サポートグループのチャット✅ はい - 懸念される投稿にフラグを付与
セラピープラットフォームのメッセージ✅ はい - セラピストを支援
一般公開のソーシャルメディア❌ いいえ - プライバシー上の懸念
人間のカウンセラーの代替❌ 決して使用しない - AI は支援するものであり、代替するものではありません
医学的診断❌ 決して使用しない - 資格がありません

参考資料

  • /references/mental-health-nlp.md - メンタルヘルス向け NLP モデル
  • /references/intervention-protocols.md - エビデンスに基づく介入戦略
  • /references/crisis-resources.md - ホットライン、テキスト相談窓口、支援サービス

スクリプト

  • scripts/crisis_detector.ts - リアルタイムの危機検出システム
  • scripts/model_evaluator.ts - テストケースを使用した検出精度の評価

このスキルがガイドする分野:危機検出 | メンタルヘルス向け NLP | 介入プロトコル | 自殺予防 | HIPAA 準拠 | 倫理的な AI

コメント