Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
74 changes: 74 additions & 0 deletions docs/evaluation/fewshot-tuning-20260916.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
# 동적 Few-shot 선택값 튜닝 (2026-09-16)

## 결론

권장값은 다음과 같습니다.

```yaml
analysis:
few-shot:
search:
top-k: 5
min-similarity: 0.40
minimum-selected-count: 2
```

동적 선택 feature flag의 기본값은 계속 비활성입니다. 이 설정은 품질 평가와 단계적 운영 적용에
사용할 권장 검색값이며, 운영 활성화를 의미하지 않습니다.

## 평가 조건

- holdout: `evaluation_cases_검수(2).csv` 20건
- 후보 데이터셋: `fewshot-pm-reviewed-20260914-v2` 5건
- 분석·Judge 모델: `gpt-4o-mini`
- 분석 temperature: 0.2, Judge temperature: 0.0
- 분석 모드: single-pass
- 각 실험의 분석·Judge 성공: 20/20
- STATIC 품질과 TOPK5 품질은 기존 비교 평가 결과를 사용
- 튜닝 3개 설정은 각각 새 분석·Judge 실행

LLM 출력은 비결정적이므로 단일 실행 결과입니다. 운영 활성화 전에는 권장 설정을 같은 holdout과
신규 holdout에서 반복 평가해야 합니다.

## similarity 분포

TOPK5 실행에서 선택된 100개 점수의 범위는 0.2763~0.6075, 평균은 0.4140,
중앙값은 0.4115였습니다.

| 임계값 | 평균 통과 후보 수 | 0건 | 2건 미만 |
| ---: | ---: | ---: | ---: |
| 0.30 | 4.90 | 0 | 0 |
| 0.35 | 4.45 | 0 | 0 |
| 0.40 | 2.80 | 1 | 3 |
| 0.45 | 1.45 | 3 | 12 |
| 0.50 | 0.35 | 13 | 20 |

0.35는 비용 절감이 작고, 0.45부터는 fallback 의존도가 지나치게 높아 0.40을 실험값으로
선택했습니다.

## 결과

| 설정 | 품질 평균 | STATIC 대비 개선/동일/악화 | 평균 선택 수 | 총 분석 토큰 | 평균 지연 | P95 지연 |
| --- | ---: | ---: | ---: | ---: | ---: | ---: |
| STATIC | 3.70 | 기준 | 4.00 | 171,379 | 5,511ms | 8,344ms |
| TOPK5, 임계값 없음 | 4.15 | 12/4/4 | 5.00 | 320,984 | 5,880ms | 10,350ms |
| TOPK3, 임계값 없음 | 3.70 | 6/9/5 | 3.00 | 251,195 | 5,266ms | 6,663ms |
| TOPK5, 0.40, 최소 1 | 3.95 | 7/10/3 | 3.05 | 251,825 | 5,149ms | 6,955ms |
| **TOPK5, 0.40, 최소 2** | **4.10** | **10/8/2** | **3.45** | **265,266** | **5,469ms** | **7,471ms** |

권장값은 임계값 없는 TOPK5보다 총 분석 토큰을 55,718개(17.4%) 줄이면서 품질 평균은
0.05만 낮았습니다. STATIC 대비 품질은 0.40 높고, 악화 사례는 2건입니다.

`minimum-selected-count=2`에서는 17건이 EMBEDDING, 3건이 LOCAL_FALLBACK이었습니다.
Cohere 논리 호출은 모든 동적 설정에서 21회로 동일했습니다. 임계값은 프롬프트에 넣을 후보를
줄이지만 query/document embedding 호출 자체를 줄이지는 않습니다.

## 결정

- `top-k=3` 단독 적용은 품질 하락으로 제외합니다.
- `min-similarity=0.40`으로 낮은 유사도 후보를 제거합니다.
- 통과 후보가 2개 미만이면 로컬 fallback하여 지나치게 작은 예시 집합을 피합니다.
- 동적 선택 feature flag는 비활성으로 유지합니다.
- 신규 후보 추가 또는 embedding 모델 변경 시 분포와 임계값을 다시 평가합니다.

로컬 원본은 `build/evaluation/fewshot-tuning-20260916/`에 있으며 Git 추적 대상이 아닙니다.
4 changes: 2 additions & 2 deletions src/main/resources/application-analysis-eval.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,8 @@ analysis:
search:
candidate-limit: ${ANALYSIS_FEW_SHOT_CANDIDATE_LIMIT:30}
top-k: ${ANALYSIS_FEW_SHOT_TOP_K:5}
min-similarity: ${ANALYSIS_FEW_SHOT_MIN_SIMILARITY:${ANALYSIS_FEW_SHOT_MIN_RERANK_SCORE:-1.0}}
minimum-selected-count: ${ANALYSIS_FEW_SHOT_MINIMUM_SELECTED_COUNT:1}
min-similarity: ${ANALYSIS_FEW_SHOT_MIN_SIMILARITY:${ANALYSIS_FEW_SHOT_MIN_RERANK_SCORE:0.40}}
minimum-selected-count: ${ANALYSIS_FEW_SHOT_MINIMUM_SELECTED_COUNT:2}
diversity-enabled: ${ANALYSIS_FEW_SHOT_DIVERSITY_ENABLED:true}

cohere:
Expand Down
4 changes: 2 additions & 2 deletions src/main/resources/application-dev.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -179,8 +179,8 @@ analysis:
search:
candidate-limit: ${ANALYSIS_FEW_SHOT_CANDIDATE_LIMIT:30}
top-k: ${ANALYSIS_FEW_SHOT_TOP_K:5}
min-similarity: ${ANALYSIS_FEW_SHOT_MIN_SIMILARITY:${ANALYSIS_FEW_SHOT_MIN_RERANK_SCORE:-1.0}}
minimum-selected-count: ${ANALYSIS_FEW_SHOT_MINIMUM_SELECTED_COUNT:1}
min-similarity: ${ANALYSIS_FEW_SHOT_MIN_SIMILARITY:${ANALYSIS_FEW_SHOT_MIN_RERANK_SCORE:0.40}}
minimum-selected-count: ${ANALYSIS_FEW_SHOT_MINIMUM_SELECTED_COUNT:2}
diversity-enabled: ${ANALYSIS_FEW_SHOT_DIVERSITY_ENABLED:true}

cohere:
Expand Down
4 changes: 4 additions & 0 deletions src/main/resources/application-fewshot-pm-eval.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ analysis:
dataset-version: fewshot-pm-reviewed-20260914-v2
reviewed-evaluation-resource: analysis/fewshot/reviewed-fewshot-cases-pm-20260914-v2.json
reviewed-evaluation-csv-path: ""
search:
top-k: 5
min-similarity: 0.40
minimum-selected-count: 2
source:
fixed-enabled: false
curated-enabled: false
Expand Down
4 changes: 2 additions & 2 deletions src/main/resources/application-prod.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -181,8 +181,8 @@ analysis:
search:
candidate-limit: ${ANALYSIS_FEW_SHOT_CANDIDATE_LIMIT:30}
top-k: ${ANALYSIS_FEW_SHOT_TOP_K:5}
min-similarity: ${ANALYSIS_FEW_SHOT_MIN_SIMILARITY:${ANALYSIS_FEW_SHOT_MIN_RERANK_SCORE:-1.0}}
minimum-selected-count: ${ANALYSIS_FEW_SHOT_MINIMUM_SELECTED_COUNT:1}
min-similarity: ${ANALYSIS_FEW_SHOT_MIN_SIMILARITY:${ANALYSIS_FEW_SHOT_MIN_RERANK_SCORE:0.40}}
minimum-selected-count: ${ANALYSIS_FEW_SHOT_MINIMUM_SELECTED_COUNT:2}
diversity-enabled: ${ANALYSIS_FEW_SHOT_DIVERSITY_ENABLED:true}

cohere:
Expand Down
Loading