AI2026년 3월 20일2분 읽기

AI Guardrails — LLM 출력의 안전성 확보

YS
YoungSam
조회 702

Guardrails 패턴

class LLMGuardrails {
  async validate(output: string): Promise<ValidationResult> {
    const checks = await Promise.all([
      this.checkToxicity(output),
      this.checkHallucination(output),
      this.checkPII(output),
      this.checkPromptInjection(output),
    ]);
    return {
      safe: checks.every(c => c.safe),
      violations: checks.filter(c => !c.safe),
    };
  }
}

프롬프트 인젝션 방어

// 사용자 입력과 시스템 프롬프트 분리
const messages = [
  { role: "system", content: systemPrompt },
  { role: "user", content: sanitize(userInput) },
];

입력/출력 양쪽 모두에서 검증하는 것이 중요합니다.

AIGuardrailsSafety

댓글 0

아직 댓글이 없습니다.