use super::super::ServeArgs;
use super::violation::Violation;
use crate::tokenizer::HeapTrimPolicy;
pub(super) fn check(args: &ServeArgs, v: &mut Vec<Violation>) {
let min_tokens = args.chat_surface.tokenizer_trim_min_tokens;
if min_tokens > args.max_seq_len {
v.push(Violation::new(
format!(
"--tokenizer-trim-min-tokens {min_tokens} is above --max-seq-len {}.",
args.max_seq_len
),
"a prompt longer than --max-seq-len is refused, so no encode could reach the \
threshold and the flag would do nothing.",
"use a threshold at or below --max-seq-len, or 0 to never trim.",
));
}
if let Err(why) = HeapTrimPolicy::process_heap(min_tokens) {
v.push(Violation::new(
format!("--tokenizer-trim-min-tokens {min_tokens} on this build."),
why,
"drop --tokenizer-trim-min-tokens (or set it to 0).",
));
}
}