From d8425ea3b3164c3fb27cfefc644695d684859d19 Mon Sep 17 00:00:00 2001 From: Asep Haryana Date: Sun, 26 Jul 2026 15:38:05 +0700 Subject: [PATCH] feat: switch to MiniCPM5-1B-Claude-Opus-Fable5-V2-Thinking-Q8_0 GGUF - Updated model path + model ID for new 1B thinking model - Updated prompt builder to use MiniCPM5 native /think trigger - Updated clean_text to strip MiniCPM5 special tokens - Bumped n_ctx from 2048 to 8192 --- src/application/chat/use_cases.rs | 13 +++++++++---- src/config/mod.rs | 6 +++--- src/presentation/handler/health.rs | 2 +- 3 files changed, 13 insertions(+), 8 deletions(-) diff --git a/src/application/chat/use_cases.rs b/src/application/chat/use_cases.rs index c9fa711..4604966 100644 --- a/src/application/chat/use_cases.rs +++ b/src/application/chat/use_cases.rs @@ -89,8 +89,8 @@ pub fn build_prompt(messages: &[ChatMessage], tools: &Option>) -> S } } - // Generation prompt: non-thinking mode - prompt.push_str("<|im_start|>assistant\n\n\n\n\n"); + // Generation prompt: thinking mode (MiniCPM5 native) + prompt.push_str("<|im_start|>assistant\n/think\n\n"); prompt } @@ -182,8 +182,13 @@ pub fn build_sampler(params: &SamplerParams) -> LlamaSampler { pub fn clean_text(text: &str) -> String { text.replace("<|im_end|>", "") .replace("<|im_start|>", "") - .replace("", "") - .replace("", "") + .replace("<|thought_begin|>", "") + .replace("<|thought_end|>", "") + .replace("<|tool_call|>", "") + .replace("<|execute_start|>", "") + .replace("<|execute_end|>", "") + .replace("/think", "") + .replace("/no_think", "") .trim() .to_string() } diff --git a/src/config/mod.rs b/src/config/mod.rs index 576eab1..97c17b3 100644 --- a/src/config/mod.rs +++ b/src/config/mod.rs @@ -4,8 +4,8 @@ use std::sync::LazyLock; -const DEFAULT_MODEL_PATH: &str = "/models/MiniCPM-V-4.6-Q4_K_M.gguf"; -pub const MODEL_ID: &str = "minicpm-v-4.6"; +const DEFAULT_MODEL_PATH: &str = "/models/MiniCPM5-1B-Claude-Opus-Fable5-V2-Thinking-Q8_0.gguf"; +pub const MODEL_ID: &str = "minicpm5-1b-fable5-v2-thinking"; /// Application configuration loaded at startup from environment variables. #[derive(Debug, Clone)] @@ -44,7 +44,7 @@ impl AppConfig { .and_then(|v| v.parse().ok()) .unwrap_or(8080), log_level: std::env::var("RUST_LOG").unwrap_or_else(|_| "info".to_string()), - n_ctx: 2048, + n_ctx: 8192, n_batch: 512, n_threads: 4, } diff --git a/src/presentation/handler/health.rs b/src/presentation/handler/health.rs index 663627b..b1f7e9b 100644 --- a/src/presentation/handler/health.rs +++ b/src/presentation/handler/health.rs @@ -8,6 +8,6 @@ use crate::domain::entity::HealthResponse; pub async fn health_check() -> Json { Json(HealthResponse { status: "ok".into(), - model: format!("{MODEL_ID}-q4_k_m"), + model: format!("{MODEL_ID}-q8_0"), }) }