From 032de108fdc10df8a87303b48b45873bbdc626e5 Mon Sep 17 00:00:00 2001 From: "Rodrigo Rodriguez (Pragmatismo)" Date: Mon, 9 Mar 2026 19:50:34 -0300 Subject: [PATCH] Relax hallucination detector: ignore Markdown separators, increase thresholds MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Ignore ---, ***, ___ (legitimate Markdown) - Increase consecutive threshold: 5 → 10 - Increase occurrence threshold: 8 → 15 - Increase token threshold: 10 → 15 --- src/llm/hallucination_detector.rs | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/llm/hallucination_detector.rs b/src/llm/hallucination_detector.rs index ddca30fa..43d6fa78 100644 --- a/src/llm/hallucination_detector.rs +++ b/src/llm/hallucination_detector.rs @@ -45,10 +45,10 @@ impl Default for HallucinationConfig { Self { min_text_length: 50, pattern_lengths: vec![3, 4, 5, 6, 8, 10, 15, 20], - consecutive_threshold: 5, - occurrence_threshold: 8, + consecutive_threshold: 10, // Increased from 5 to 10 + occurrence_threshold: 15, // Increased from 8 to 15 recent_text_window: 500, - identical_token_threshold: 10, + identical_token_threshold: 15, // Increased from 10 to 15 ignore_words: DEFAULT_IGNORE_WORDS.iter().map(|s| s.to_string()).collect(), } } @@ -159,6 +159,11 @@ impl HallucinationDetector { continue; } + // Ignore common Markdown separators + if pattern_str == "---" || pattern_str == "***" || pattern_str == "___" { + continue; + } + // Count how many times this pattern appears consecutively at the end let mut count = 0; let mut search_text = text;