Gemma now checks its own output (a fresh, stateless completion call, not conversation history) before it's accepted as a seed or revision, retrying up to 5 times if it's a refusal, meta-commentary describing what it's about to write, or a list of multiple options instead of one direct answer. Originally tried a separate CPU-only judge model (critic-cpu) to avoid VRAM contention, but it was both far slower (13-16s per judgment vs Gemma's own sub-second calls) and unreliable on the exact failure patterns it was meant to catch — Gemma reviewing itself turned out faster and more accurate, so critic-cpu is dropped entirely. Also required two rounds of prompt tuning, driven by live failures: first adding concrete negative examples after the judge approved outputs it should have rejected, then explicitly scoping the check to format only after Gemma started rejecting its own genuinely hostile (but well-formed) output — conflating "should I have generated this" with the format question actually asked. Added integration tests covering both directions (rejecting bad formats, accepting hostile- but-well-formed content) as a fast regression check against an expensive full generation loop.
43 lines
963 B
Rust
43 lines
963 B
Rust
use serde::Deserialize;
|
|
|
|
#[derive(Deserialize)]
|
|
pub(crate) struct ChatLogprobs {
|
|
pub(crate) content: Vec<TokenLogprob>,
|
|
}
|
|
|
|
#[derive(Deserialize)]
|
|
pub(crate) struct TokenLogprob {
|
|
pub(crate) top_logprobs: Vec<TopLogprob>,
|
|
}
|
|
|
|
#[derive(Deserialize)]
|
|
pub(crate) struct TopLogprob {
|
|
pub(crate) token: String,
|
|
pub(crate) logprob: f64,
|
|
}
|
|
|
|
#[derive(Deserialize)]
|
|
pub(crate) struct Prompts {
|
|
pub(crate) shieldstral: ShieldstralPrompts,
|
|
pub(crate) gemma: GemmaPrompts,
|
|
pub(crate) critic: CriticPrompts,
|
|
}
|
|
|
|
#[derive(Deserialize)]
|
|
pub(crate) struct CriticPrompts {
|
|
pub(crate) system: String,
|
|
pub(crate) prompt_template: String,
|
|
}
|
|
|
|
#[derive(Deserialize)]
|
|
pub(crate) struct ShieldstralPrompts {
|
|
pub(crate) system: String,
|
|
pub(crate) prompt_template: String,
|
|
}
|
|
|
|
#[derive(Deserialize)]
|
|
pub(crate) struct GemmaPrompts {
|
|
pub(crate) preamble: String,
|
|
pub(crate) evil_seed_prompt: String,
|
|
pub(crate) revise_template: String,
|
|
}
|