시스템 메시지로 동작 제어하기

Claude 모델 입문

Nikhil Rangarajan

Data Scientist

시스템 메시지란?

  • 지원 봇
  • 요구사항:
    • 공손한 표현
    • 간결한 응답
    • 모든 답변의 끝에 "Is there anything else I can help you with today?" 추가

A bot

Claude 모델 입문

시스템 메시지란?

  • 시스템 메시지는 Claude의 전반적인 동작 규칙을 설정
  • 단일 응답이 아닌 전체 대화에 적용됨
  • 어조, 제약, 출력 형식, 페르소나 제어

A bot asking “Is there anything else I can help you with today?”

Claude 모델 입문

효과적인 시스템 프롬프트 작성하기

  • 행동과 제약을 구체적으로 명시
  • Claude가 맡을 역할 정의
system_msg = "Be helpful." # Weak

system_msg = "You are a technical writer. Use active voice, under 100 words, actionable advice only." # Strong
messages = [{"role": "user", "content": "How do I improve documentation?"}] response = client.messages.create(model="claude-sonnet-4-6", max_tokens=150, system=system_msg, messages=messages)
Claude 모델 입문

일반적인 시스템 메시지 패턴

  • 역할 기반: Claude의 역할 정의

$$

  • 제약 기반: 길이 또는 형식에 제한 설정

$$

  • 어조 기반: 감정 스타일 조절

$$

  • 작업 특화: 전문적인 지침을 제공
# Role-based
"You are a customer service rep."

# Constraint-based  
"Respond in exactly 3 bullet points,
max 50 words."

# Tone-based
"Use enthusiastic, encouraging tone."

# Task-specific
"Debug Python code. Always ask for 
error messages first."
Claude 모델 입문

시스템 메시지 테스트 및 반복 개선

  • 다양한 사용자 입력으로 테스트하고 엣지 케이스 찾기
  • 원치 않는 출력이나 동작 변화 모니터링
  • 필요 시 더 구체적인 표현으로 다듬기
# System message causing issues
"Be concise and helpful."

# Problem: Responses too short, 
# missing context
"Provide helpful responses in 2-3 
sentences. Include relevant context 
but avoid unnecessary details."

# Test with various prompts 
Claude 모델 입문

고급 시스템 메시지 기법

$$

  • 명확한 우선순위로 지침을 결합
  • 시나리오에 조건부 로직 사용
  • 시스템 메시지에 예시 포함
  • 퓨샷 프롬프트와 함께 활용
system_msg = """Code reviewer. 
Priority: 1) Security 2) Performance 
3) Style
If no issues: "Code looks good" 
+ suggest improvement
Example: "Security: No issues. 
Performance: Consider caching here."
"""

messages = [{"role": "system", 
             "content": system_msg},
    {"role": "user", 
     "content": "Review: [code]"}]
Claude 모델 입문

연습해 볼까요?

Claude 모델 입문

Preparing Video For Download...