diff --git a/crates/vetta-infer-gw/src/chat.rs b/crates/vetta-infer-gw/src/chat.rs index 9c91762..0a852f5 100644 --- a/crates/vetta-infer-gw/src/chat.rs +++ b/crates/vetta-infer-gw/src/chat.rs @@ -28,8 +28,14 @@ pub fn chat_turn( on_text: &mut dyn FnMut(&str), ) -> Result { let prompt = render_prompt(history, effort)?; + if std::env::var("VETTA_DBG_PROMPT").is_ok() { + eprintln!("[chat] prompt={prompt:?}"); + } let enc = tok.encode(prompt, false).map_err(|e| e.to_string())?; let ids: Vec = enc.get_ids().iter().map(|&x| x as i32).collect(); + if std::env::var("VETTA_DBG_PROMPT").is_ok() { + eprintln!("[chat] prompt_ids={ids:?}"); + } let g = ParsedGen { max_new, sampling: SamplingOpts::default(), // greedy, deterministic @@ -40,6 +46,11 @@ pub fn chat_turn( ids, }; let stop = AtomicBool::new(false); + // In the plain-content path (effort none) the assistant content channel closes + // at <|end_message|> (200010); the model then emits EOS. Stop at end_message so + // the reply is exactly the content even if the trailing EOS is delayed by a + // near-tie (the reference closes the channel here too). + let stop_at_end_message = effort.trim() == "none"; let mut generated: Vec = Vec::new(); let mut printed = 0usize; let mut full = String::new(); @@ -57,6 +68,9 @@ pub fn chat_turn( } full = txt; } + if stop_at_end_message && id == 200010 { + stop.store(true, std::sync::atomic::Ordering::Relaxed); + } }; serve_gen(eng, &g, &stop, &mut emit); } diff --git a/crates/vetta-infer-gw/src/serve.rs b/crates/vetta-infer-gw/src/serve.rs index 6a445b3..005e805 100644 --- a/crates/vetta-infer-gw/src/serve.rs +++ b/crates/vetta-infer-gw/src/serve.rs @@ -229,6 +229,12 @@ pub fn serve_gen( return; } let rep = sample_logits_exact(&mut lg, &opts, &history, None, &mut rng, &mut scratch); + if std::env::var("VETTA_DBG_LOGITS").is_ok() { + let mut idx: Vec = (0..eng.vocab).collect(); + idx.sort_by(|&a, &b| lg[b].partial_cmp(&lg[a]).unwrap()); + let top: Vec<(usize, f32)> = idx[..5].iter().map(|&i| (i, lg[i])).collect(); + eprintln!("[dbg] step={step} pos={pos} top5={top:?}"); + } if rep.nonfinite_logits == eng.vocab { finish = "nonfinite"; break;