You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

127 lines
2.6 KiB
Markdown

# Prompt and LLM Policy
## 1. 역할 정의
LLM은 다음 역할만 수행한다.
- 문맥 분류
- 이벤트의 질 평가
- guidance 톤 분류
- one-off 의심 플래그
- 수요/가격결정력/고객확대/구조변화 문맥 추출
LLM이 하지 말아야 할 것:
- 숫자 계산
- 컨센서스 추정치 생성
- 문서에 없는 factual claim 생성
- 포지션/매수/매도 추천
## 2. 입력 설계
입력은 다음 3개 블록으로 제한:
1. 문서 메타데이터
2. 정규화 문서 본문 또는 핵심 section
3. rule parser가 추출한 structured hints
절대 포함하지 말 것:
- 미래 수익률
- 이후 가격 반응 요약
- 목표 레이블
- 백테스트 결과
## 3. 출력 설계
출력은 반드시 JSON Schema에 맞춰야 한다.
필수 출력 필드:
- event_type
- event_direction
- guidance_direction
- quality_assessment
- oneoff_suspicion
- demand_strength
- pricing_power
- management_tone
- confidence_overall
- evidence_refs
- parse_warnings
## 4. Prompt versioning
필수 메타데이터:
- `prompt_name`
- `prompt_version`
- `model_name`
- `model_provider`
- `temperature`
- `max_tokens`
- `response_format`
캐시 키 권장 구성:
```text
sha256(
normalized_text_hash +
parser_hint_hash +
prompt_version +
model_name +
schema_version
)
```
## 5. 비용 통제
반드시 구현:
- 동일 문서 재호출 방지 캐시
- 긴 문서 section slicing
- low-priority 문서의 rule-only 모드
- confidence 기반 selective retry
권장 순서:
1. 규칙 파서만 실행
2. 검수 가치가 있는 문서만 LLM 호출
3. confidence 낮은 경우 1회 재시도
4. 그래도 불명확하면 review queue
## 6. 오류 처리
### 모델 오류
- 타임아웃, rate limit, validation error를 구분
- 재시도는 최대 2회
- 실패해도 전체 파이프라인은 rule-only 결과로 진행 가능해야 함
### schema 오류
- structured repair prompt 1회 허용
- repair도 실패하면 parse_failed 저장
## 7. 재현 가능성
필수 저장:
- raw prompt
- raw response
- normalized response
- schema validation 결과
- token usage
- elapsed_ms
민감사항:
- 프롬프트에 외부 비밀값 포함 금지
- PII 불필요 포함 금지
## 8. 골드셋 평가
gold set에 대해 최소 평가:
- event_type accuracy
- guidance_direction accuracy
- oneoff precision/recall
- quality_assessment macro F1
- evidence presence ratio
## 9. 모델 교체 정책
모델을 바꾸더라도 아래는 고정:
- 출력 schema
- provenance 필드
- review queue 기준
- null/unknown 정책
즉 모델 교체는 implementation detail이지 data contract 변경이 아니어야 한다.