docs: 계획 문서 원칙 준수 정리

- 251017: 완료 섹션 간소화, 상세 내용 제거, 남은 작업만 기록
- 251023: 상세 구현 내용 제거, Phase별 필요 작업만 기록
- 251225: DB 스키마 상세 SQL 제거, 테이블 구조만 요약, Phase별 필요 작업만 기록
- 원칙 준수: 구현 완료 섹션 삭제, troubleshooting 링크만, 아키텍처/Phase/필요작업만
This commit is contained in:
Claude-51124 2026-01-27 10:44:34 +09:00
parent 4561f998b3
commit 76ed2786f3
3 changed files with 46 additions and 105 deletions

View File

@ -1,30 +1,19 @@
# 로빙 의도 파악 개선 플랜 # 로빙 의도 파악 개선 플랜
**날짜**: 2025-10-17 **날짜**: 2025-10-17
**현재**: 정규식 패턴 매칭만 사용 **상태**: 부분 완료 (3단계 아키텍처 완료, 하이브리드 시스템 미구현)
--- ---
## 현재 문제 ## Phase 1: 3단계 아키텍처 (✅ 완료)
### 처리 불가 사례
| 질문 | 현재 처리 | 문제 |
|------|----------|------|
| "오늘 몇일이야?" | UNKNOWN | 시간 질문 패턴 없음 |
| "리버스마운틴 유사 기업 가치평가해줘" | UNKNOWN | 복잡한 멀티스텝 질문 |
| "아까 말한 그 기업 투자 단계는?" | UNKNOWN | 맥락 참조 불가 |
**결론**: 단순 명령만 처리 가능, 복합 질문 처리 불가
---
## 구현 완료 (3단계 구조)
→ 상세: `troubleshooting/251126_happybell80_rb8001_의도_3단계_아키텍처_도입_및_배포.md` → 상세: `troubleshooting/251126_happybell80_rb8001_의도_3단계_아키텍처_도입_및_배포.md`
--- ---
## ⏳ 미구현: 하이브리드 시스템 ## 남은 작업
### 하이브리드 시스템 구현
**구조**: **구조**:
1. 정규식 FastPath (명확한 패턴) → conf ≥ 0.9 즉시 결정 1. 정규식 FastPath (명확한 패턴) → conf ≥ 0.9 즉시 결정
@ -32,15 +21,8 @@
3. LLM 제로샷 분류 → conf < 0.5 CLARIFY 3. LLM 제로샷 분류 → conf < 0.5 CLARIFY
**필요 작업**: **필요 작업**:
- SemanticIntentClassifier 구현: `app/services/brain/semantic_classifier.py`, intent_prototypes 테이블 활용, 임베딩 유사도로 Top-3 후보 선택
**1. SemanticIntentClassifier 구현** - LLM 폴백: Top-3 후보를 LLM에 전달, 확신도 < 0.5 CLARIFY
- 파일: `app/services/brain/semantic_classifier.py`
- intent_prototypes 테이블 활용
- 임베딩 유사도로 Top-3 후보 선택
**2. LLM 폴백**
- Top-3 후보를 LLM에 전달
- 확신도 < 0.5 CLARIFY
--- ---
@ -48,4 +30,4 @@
- `troubleshooting/251126_happybell80_rb8001_의도_3단계_아키텍처_도입_및_배포.md` - `troubleshooting/251126_happybell80_rb8001_의도_3단계_아키텍처_도입_및_배포.md`
- `troubleshooting/251126_intent_3step_db_bayesian_integration.md` - `troubleshooting/251126_intent_3step_db_bayesian_integration.md`
- `311_FastAPI_구조_원칙.md` - `book/300_architecture/311_백엔드_구조_원칙.md`

View File

@ -2,6 +2,7 @@
**날짜**: 2025-10-23 **날짜**: 2025-10-23
**목표**: 임베딩 + 베이지안 + 동적학습 통합 의도 파악 시스템 **목표**: 임베딩 + 베이지안 + 동적학습 통합 의도 파악 시스템
**상태**: 미구현
--- ---
@ -13,39 +14,20 @@ FastPath + 임베딩 Top-K + LLM 재분석 + Beta(α,β) 동적 임계치 하이
## Phase 1: 하이브리드 파이프라인 ## Phase 1: 하이브리드 파이프라인
**파일**: `rb8001/app/services/brain/intent_graph.py` (신규) **필요 작업**:
- FastPath: 정규식 + Naive Bayes, conf ≥ 0.9 즉시 결정 - `rb8001/app/services/brain/intent_graph.py` (신규): FastPath + SemanticIntentClassifier + LLM 재분석 파이프라인
- SemanticIntentClassifier: intent 설명/예시 벡터와 코사인 유사도, Top-K 후보 선택 - `rb8001/app/services/brain/semantic_classifier.py` (신규): intent_prototypes 테이블 활용, 임베딩 유사도로 Top-K 후보 선택
- LLM 재분석: Top-K만 JSON 스키마로 결정, conf < τ는 clarify - `rb8001/app/services/llm/intent_parser.py` (신규): LLM JSON 파서
**파일**: `rb8001/app/services/brain/semantic_classifier.py` (신규) ---
- intent_prototypes 테이블 활용
- 임베딩 유사도로 Top-3 후보 선택
**파일**: `rb8001/app/services/llm/intent_parser.py` (신규)
- LLM JSON 파서
## Phase 2: 베이지안 동적 학습 ## Phase 2: 베이지안 동적 학습
**파일**: `rb8001/app/state/repositories/intent_decision_repository.py` (신규) **필요 작업**:
- `intent_decision_log` 테이블 생성 - `rb8001/app/state/repositories/intent_decision_repository.py` (신규): intent_decision_log 테이블 생성
- 의도/경로별 성공률 추적 (Beta(α,β)) - 의도/경로별 성공률 추적 (Beta(α,β))
- Thompson Sampling으로 임계치 τ 동적 최적화 - Thompson Sampling으로 임계치 τ 동적 최적화
**DB 스키마**:
```sql
CREATE TABLE intent_decision_log (
user_id UUID,
message TEXT,
candidates JSONB,
chosen TEXT,
path TEXT,
success BOOLEAN,
latency_ms INT,
timestamp TIMESTAMPTZ
);
```
--- ---
## 참고 ## 참고

View File

@ -2,8 +2,7 @@
**날짜**: 2025-12-25 **날짜**: 2025-12-25
**작성자**: happybell80 **작성자**: happybell80
**관련 파일**: `rb8001/app/services/llm/gemini_handler.py`, `rb8001/app/services/llm/llm_service.py` **상태**: 미구현
**상태**: 📋 계획 단계
--- ---
@ -11,77 +10,55 @@
프롬프트 DB화를 통한 동적 변경 및 개인화 구현 프롬프트 DB화를 통한 동적 변경 및 개인화 구현
---
## DB 스키마 설계 ## DB 스키마 설계
```sql **테이블**: `prompt_templates`
CREATE TABLE prompt_templates ( - scope_level: 'global', 'robeing', 'user', 'task'
id UUID PRIMARY KEY, - scope_id: robeing_id, user_id, task_type 등
scope_level VARCHAR(20) NOT NULL, -- 'global', 'robeing', 'user', 'task' - prompt_type: 'system', 'chat', 'extract', 'calendar_confirm', 'ir_analysis' 등
scope_id VARCHAR(255), -- robeing_id, user_id, task_type 등 - content: JSONB (템플릿 내용 + 변수 정의)
prompt_type VARCHAR(50) NOT NULL, -- 'system', 'chat', 'extract', 'calendar_confirm', 'ir_analysis' 등 - version, is_active, created_at, updated_at
version VARCHAR(20) DEFAULT '1.0',
content JSONB NOT NULL, -- 템플릿 내용 + 변수 정의 (XML 구조 유지)
is_active BOOLEAN DEFAULT true,
created_at TIMESTAMPTZ DEFAULT now(),
updated_at TIMESTAMPTZ DEFAULT now(),
UNIQUE(scope_level, scope_id, prompt_type, version)
);
```
---
## 프롬프트 분류 기준 ## 프롬프트 분류 기준
### 1. 변경 빈도별 ### 계층적 범위(Scope)
- **거의 안 바뀜**: Global/system_basic (기본 정체성) - Global: 모든 사용자 공통 기본 프롬프트
- **자주 변경**: User/preferred_name (사용자 피드백 반영) - Robeing: 특정 로빙 공통
- User: 사용자별 개인화
- Task: 작업 타입별
### 2. 계층적 범위(Scope) ### 병합 로직
- **Global**: 모든 사용자 공통 기본 프롬프트
- **Robeing**: 특정 로빙 공통
- **User**: 사용자별 개인화
- **Task**: 작업 타입별 (chat, extract, calendar_confirm 등)
### 3. 병합 로직
- Global → Robeing → User 순서로 조회 - Global → Robeing → User 순서로 조회
- 각 레벨별 개별 쿼리 후 애플리케이션에서 병합 - 각 레벨별 개별 쿼리 후 애플리케이션에서 병합
- Global scope는 scope_id=NULL로 조회
---
## 구현 Phase ## 구현 Phase
## Phase 1: DB 스키마 및 기본 인프라 ### Phase 1: DB 스키마 및 기본 인프라
- `rb8001/app/state/repositories/prompt_repository.py` (신규): prompt_templates 테이블 생성, PromptService 클래스 (조회, 병합, 캐싱)
**파일**: `rb8001/app/state/repositories/prompt_repository.py` (신규)
- `prompt_templates` 테이블 생성
- PromptService 클래스 (조회, 병합, 캐싱)
- 기본 프롬프트 마이그레이션 (하드코딩 → DB) - 기본 프롬프트 마이그레이션 (하드코딩 → DB)
## Phase 2: 핵심 프롬프트 DB화 ### Phase 2: 핵심 프롬프트 DB화
- `rb8001/app/services/llm/gemini_handler.py`, `rb8001/app/services/llm/llm_service.py`: 시스템 프롬프트 DB 조회로 변경
**파일**: `rb8001/app/services/llm/gemini_handler.py`, `rb8001/app/services/llm/llm_service.py`
- 시스템 프롬프트 DB 조회로 변경
- 작업 타입별 프롬프트 (chat, extract, calendar_confirm) DB화 - 작업 타입별 프롬프트 (chat, extract, calendar_confirm) DB화
- 폴백 로직: DB 조회 실패 시 기존 `_get_system_prompt()` 메서드 사용 - 폴백 로직: DB 조회 실패 시 기존 `_get_system_prompt()` 메서드 사용
## Phase 3: 개인화 및 동적 프롬프트 ### Phase 3: 개인화 및 동적 프롬프트
- `rb8001/app/services/llm/prompt_service.py` (신규): 사용자별 프롬프트 오버라이드, 감정 기반 동적 프롬프트 조합, 변수 치환 시스템
**파일**: `rb8001/app/services/llm/prompt_service.py` (신규) ### Phase 4: A/B 테스트 및 모니터링
- 사용자별 프롬프트 오버라이드 - 프롬프트 버전 관리, A/B 테스트 지원, 롤백 기능
- 감정 기반 동적 프롬프트 조합
- 변수 치환 시스템 ({current_time}, {emotion_labels})
## Phase 4: A/B 테스트 및 모니터링 ---
**파일**: `rb8001/app/services/llm/prompt_service.py`
- 프롬프트 버전 관리
- A/B 테스트 지원
- 롤백 기능
## 참고 문서 ## 참고 문서
- **[[book/300_architecture/313_Gemini_프롬프트_설계_원칙]]** - Gemini 프롬프트 설계 원칙 (XML 구조화, 퓨샷 예시, 구조화 등) - **필수 참고** - `book/300_architecture/313_Gemini_프롬프트_설계_원칙.md` - Gemini 프롬프트 설계 원칙 (필수 참고)
- [[ideas/250828_dynamic_system_prompt_memory]] - 동적 시스템 프롬프트 메모리 시스템 - `ideas/250828_dynamic_system_prompt_memory.md` - 동적 시스템 프롬프트 메모리 시스템
- [[troubleshooting/250806_happybell80_동적프롬프트구현]] - 동적 프롬프트 구현 기록 - `troubleshooting/250806_happybell80_동적프롬프트구현.md` - 동적 프롬프트 구현 기록
- [[book/300_architecture/311_FastAPI_구조_원칙]] - 계층 분리 원칙 - `book/300_architecture/311_백엔드_구조_원칙.md` - 계층 분리 원칙