chore(rag): PR #167 회차 1 리뷰 반영
- `parse_decompose_response_drops_partial_empty_keeps_valid` 신규
회귀 핀 — `["", "valid q", " "]` → `["valid q"]` (trim+filter
chain 동작 pin).
- `multi_hop_decompose` 의 `stop: Vec::new()` 옆 doc comment 추가 —
의도 명시 (instruction-following 모델 기대 + prose 추가 시
MultiHopDecomposeFailed refusal 가 policy). 회차 1 question 의
답변.
- plan 의 PR-3 implementation order 에 회차 1 carry-over 추가:
1) ask + ask_multi_hop 의 §4-§9 mirror → 공통 helper 추출,
2) decompose template 의 substitution corner case → format!
named arg 으로 교체.
회차 1 의 다른 suggestion (mirror refactor, substitution corner
case, history block helper) 는 PR-3 합리적 timing 으로 plan 에
명시 — 회차 2 reply 에 정리.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -908,6 +908,16 @@ impl RagPipeline {
|
||||
let req = GenerateRequest {
|
||||
system: MULTI_HOP_DECOMPOSE_SYSTEM_PROMPT.to_string(),
|
||||
user,
|
||||
// Empty stop is intentional. Instruction-following models
|
||||
// (gemma3:4b+ / gemma4:e4b / Claude / GPT-4) honor the
|
||||
// "JSON array only" prompt rule, so prose past the
|
||||
// closing `]` is rare. If a downstream LM does append
|
||||
// prose, `parse_decompose_response` returns `None` and
|
||||
// the caller surfaces `MultiHopDecomposeFailed` — that
|
||||
// is the policy. Adding a trailing-`]` stop sequence
|
||||
// risks truncating the array (LM emits the close bracket
|
||||
// and we cut the response one token too early), which
|
||||
// is a worse failure mode than the explicit refusal.
|
||||
stop: Vec::new(),
|
||||
// JSON array of up to 5 sub-questions is short. 512 is a
|
||||
// comfortable cap that fits in any context window without
|
||||
@@ -1495,6 +1505,16 @@ mod tests {
|
||||
assert_eq!(out, vec!["rust async", "tokio runtime"]);
|
||||
}
|
||||
|
||||
/// Partial-empty case — drop the empties, keep the rest. Pins
|
||||
/// the trim-then-filter chain in `parse_decompose_response` so a
|
||||
/// future refactor that reorders the steps (e.g. take-then-trim)
|
||||
/// can't accidentally swallow valid sub-queries.
|
||||
#[test]
|
||||
fn parse_decompose_response_drops_partial_empty_keeps_valid() {
|
||||
let out = parse_decompose_response(r#"["", "valid q", " "]"#).unwrap();
|
||||
assert_eq!(out, vec!["valid q"]);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn est_tokens_approx_quarters() {
|
||||
assert_eq!(est_tokens(""), 0);
|
||||
|
||||
Reference in New Issue
Block a user