From 22cb65c84c2d4484dc46a9aed631cea4a311ba80 Mon Sep 17 00:00:00 2001 From: tslil Date: Mon, 3 Aug 2026 16:38:11 +0100 Subject: wallpaper.py: go back to gemma4 e4b --- wallpaper.py | 28 ++++++++++++++++++++++------ 1 file changed, 22 insertions(+), 6 deletions(-) diff --git a/wallpaper.py b/wallpaper.py index bdd3b37..22295ab 100755 --- a/wallpaper.py +++ b/wallpaper.py @@ -143,24 +143,40 @@ def step_context( def clean_llm_output(text: str) -> str: + # llama-completion end marker. text = re.sub( r"\s*\[\s*end of text\s*\]\s*$", "", text, flags=re.IGNORECASE, ) + + # Gemma 4 reasoning channel. text = re.sub( - r".*?", + r"<\|channel>thought\s*.*?\s*", "", text, flags=re.DOTALL | re.IGNORECASE, ) + + # DeepSeek/Qwen-style reasoning tags. text = re.sub( - r".*$", + r".*?", "", text, flags=re.DOTALL | re.IGNORECASE, ) + + # Detect truncated reasoning rather than sending it to sd-cli. + if re.match( + r"^\s*(?:<\|channel>thought\b|)", + text, + flags=re.IGNORECASE, + ): + raise RuntimeError( + "The model generated reasoning but did not reach a final answer. Check that your llama.cpp build supports '--reasoning off', or increase --llm-max-tokens." + ) + return text.strip() @@ -459,13 +475,13 @@ def parse_args() -> argparse.Namespace: llm.add_argument( "--llm-model-path", type=Path, - default=Path("~/store/weights/Qwen3-8B-Q4_K_M.gguf"), + default=Path("~/store/weights/gemma-4-E4B-it-Q4_K_M.gguf"), help="Model path for generating image prompts.", ) llm.add_argument( "--llm-max-tokens", type=positive_int, - default=384, + default=1024, help="Maximum number of prompt tokens to generate.", ) llm.add_argument( @@ -502,7 +518,7 @@ def parse_args() -> argparse.Namespace: "The weather should be reflected in your prompt where it does not contradict the biome; the biome's climate wins any conflict. " "The season should set the overall mood of the prompt. " "Do not include the time, date, or location in your prompt. " - "Output ONLY the image prompt — no explanation or preamble." + "Output ONLY the image prompt - no explanation or preamble, no thinking." ), help="System prompt for the LLM.", ) @@ -576,7 +592,7 @@ def parse_args() -> argparse.Namespace: ) sd_cli.add_argument( "--sd-cli-explicit-instructions", - default="No railings, no glass, no people, no objects.", + default="No railings, no glass, no people, no objects, no houses.", help="Instructions appended to every diffusion prompt.", ) -- cgit v1.2.3