diff --git a/crates/kebab-config/src/lib.rs b/crates/kebab-config/src/lib.rs index fdbe071..1cd5f81 100644 --- a/crates/kebab-config/src/lib.rs +++ b/crates/kebab-config/src/lib.rs @@ -205,9 +205,10 @@ pub struct RagCfg { /// with `forced_stop = true`. /// /// Default `15` — tuned down from the original 30 in the v0.18 - /// pre-cut dogfood (`tasks/HOTFIXES.md` 2026-05-25 fb-41 post-PR-7 - /// entry). With 30 chunks the synthesize prompt was large enough - /// for gemma3:4b to lose the citation rule + drift into unrelated + /// pre-cut dogfood (`tasks/HOTFIXES.md` 2026-05-25 fb-41 entry, + /// "post-PR-7 dogfood retest + PR-8 partial mitigation" sub-section). + /// With 30 chunks the synthesize prompt was large enough for + /// gemma3:4b to lose the citation rule + drift into unrelated /// chunks; 15 keeps the prompt tight while still allowing 3-iter /// cross-doc reasoning over ~5 chunks per iter. #[serde(default = "default_multi_hop_max_pool_chunks")] diff --git a/tasks/HOTFIXES.md b/tasks/HOTFIXES.md index c757c57..7254de6 100644 --- a/tasks/HOTFIXES.md +++ b/tasks/HOTFIXES.md @@ -53,18 +53,43 @@ Multi-hop 의 safety floor 가 single-pass 와 정확히 일치 — multi-hop 같은 도그푸딩에서 발견된 다른 항목들 — PR-7 본 fix 의 scope 밖, v0.18.1 또는 후속 PR 대상: -- **synthesize citation marker 일관성 부족** (S1/S2/S3, P1) — 30-chunk pool 의 large prompt 에서 gemma3:4b 가 `[#N]` citation rule 잃음 → 답변 본문 정상이나 `grounded=false (LlmSelfJudge)` 로 노출. **권장 mitigation**: `MULTI_HOP_SYNTHESIZE_SYSTEM_PROMPT` 의 citation rule 강화 또는 `multi_hop_max_pool_chunks` default 30 → 15. -- **latency 20-25× cost** — single-pass 30s vs multi-hop 590-685s (synthesize 단계가 cost dominant). spec 의 "2-5× LLM cost" 보다 큼. pool size 축소가 mitigation. +- **synthesize citation marker 일관성 부족** (S1/S2/S3, P1) — 30-chunk pool 의 large prompt 에서 gemma3:4b 가 `[#N]` citation rule 잃음 → 답변 본문 정상이나 `grounded=false (LlmSelfJudge)` 로 노출. **권장 mitigation**: `MULTI_HOP_SYNTHESIZE_SYSTEM_PROMPT` 의 citation rule 강화 또는 `multi_hop_max_pool_chunks` default 30 → 15. → **closure (부분)**: 아래 *post-PR-7 dogfood retest + PR-8* 절. pool 30 → 15 ship. +- **latency 20-25× cost** — single-pass 30s vs multi-hop 590-685s (synthesize 단계가 cost dominant). spec 의 "2-5× LLM cost" 보다 큼. pool size 축소가 mitigation. → **closure**: PR-8 의 pool 15 로 614s → 158s (4× 개선) 확인. - **release binary path confusion** — `/home/altair823/kebab/target/release/kebab` (v0.17.1 stale) vs `/build/out/cargo-target/release/kebab` (v0.17.2 latest). CARGO_TARGET_DIR env 의 영향. docs 한 줄 권장. +### post-PR-7 dogfood retest + PR-8 partial mitigation + +PR-7 머지 후 같은 dogfood S7 (`What is the chemical formula of caffeine?`) 시나리오 재검증: + +| metric | single-pass | multi-hop pre-fix | multi-hop PR-7 | multi-hop PR-8 | +|---|---|---|---|---| +| grounded | false (LlmSelfJudge) | true ✗ | true ✗ | true ✗ | +| latency | ~30s | 141s | 143s | **158s** (4× 개선) | +| top_score / gate | 0.5 / 0.30 | 0.5 / 0.30 | 0.5 / 0.30 (probe pass) | 0.5 / 0.30 (probe pass) | +| pool size | n/a | 30 | 30 | **15** | +| answer | "근거가 부족하다" ✓ | hallucination | hallucination | hallucination (LLM 새 rule 무시) | + +**PR-7 의 probe gate not enough**: hybrid mode 의 RRF top_score = 0.5 (gate 0.30 위) — caffeine vector 유사도가 *어떤* chunk 와 매칭 (Adam optimizer 의 `g_t = ∂L/∂θ` 시각적 short structured token) → probe gate 통과 → synthesize 진입 → hallucination. + +**PR-8 의 변경** (`crates/kebab-config/src/lib.rs` + `crates/kebab-rag/src/pipeline.rs`): +- `multi_hop_max_pool_chunks` default **30 → 15**. synthesize prompt size 축소 → latency 4× 개선. +- `MULTI_HOP_SYNTHESIZE_SYSTEM_PROMPT` 에 **답하기 전 self-check** rule 추가 — 원본 question 의 핵심 entity 가 [근거] 본문에 literal 없으면 즉시 "근거가 부족하다". + +**PR-8 의 한계**: gemma3:4b 가 prompt rule 무시. strong rule + small pool 도 hallucination 차단 못함. **LLM-self-judge 기반 safety 의 ceiling** 명확. + +### PR-9 — NLI-based post-synthesis verification (예정) + +학계 / industry 표준 (Self-RAG, CRAG, Auto-GDA, MedTrust-RAG) 결론: deterministic post-synthesis verification 이 정답. **mDeBERTa-v3-base-xnli-multilingual ONNX model (280 MB)** 가 `(premise = packed_chunks, hypothesis = answer)` entailment 검사 → score < 0.5 면 refuse. PR-8 위에 layered defense. design note: `/build/cache/dogfood-v018/results/PR-9-DESIGN.md`. 단계적 PR (9a / 9b / 9c) — 추정 ~10시간. v0.18.0 cut blocker. + ### 사용자 영향 -PR-7 머지 후 (v0.18.0 cut 직전): -- multi-hop 의 safety 가 single-pass 와 동일. KB 밖 query 가 hallucination 답변 못 받음. -- Multi-hop 의 정상 use case (compound / cross-doc reasoning) 는 영향 없음 — probe 가 통과하면 기존 flow 그대로. -- Wire 변경 없음 (`Answer.hops` 의 노출 동일, refusal_reason 값 동일). +PR-7 + PR-8 머지 후 (v0.18.0 cut 직전): +- multi-hop 의 safety floor 는 single-pass 와 동일 (PR-7 probe gate). probe gate 가 reject 하는 query 는 hallucination 못 받음. +- 그러나 hybrid RRF 가 *weak match* 라도 gate 통과 시 (vector embedding 의 false positive) hallucination 가능 — PR-9 NLI 가 진짜 close. +- Multi-hop 정상 use case (compound / cross-doc reasoning) 영향 없음. +- Wire 변경 없음 (PR-8 의 pool default 만 변경, additive config 영향). -Cross-link: `/build/cache/dogfood-v018/results/SUMMARY.md` (전체 dogfood 보고서), spec `docs/superpowers/specs/2026-05-25-p9-fb-41-multi-hop-rag-design.md`. +Cross-link: `/build/cache/dogfood-v018/results/SUMMARY.md` (전체 dogfood 보고서), `/build/cache/dogfood-v018/results/PR-9-DESIGN.md` (NLI design note), spec `docs/superpowers/specs/2026-05-25-p9-fb-41-multi-hop-rag-design.md`. ## 2026-05-25 — v0.17.0 post-dogfood: `[models.llm] request_timeout_secs` 노브 + 권장 모델 가이드