llm-jp-4-vl-9b-mlx-4bit / constants.py
aipib's picture
Upload folder using huggingface_hub
56f9b45 verified
Raw
History Blame Contribute Delete
2.81 kB
# --------------------------------------------------------
# LLM-jp-VL
# Copyright (c) 2026 LLM-jp
# Licensed under The Apache License 2.0 [see LICENSE for details]
#
# Originally based on InternVL
# Copyright (c) 2024 OpenGVLab
# Licensed under The MIT License [see LICENSE for details]
# --------------------------------------------------------
IMG_CONTEXT_TOKEN = "<|image_pad|>"
HARMONY_START = "<|start|>"
HARMONY_END = "<|end|>"
HARMONY_MESSAGE = "<|message|>"
HARMONY_CHANNEL = "<|channel|>"
HARMONY_RETURN = "<|return|>"
IMAGE_START = "<|image_start|>"
IMAGE_END = "<|image_end|>"
# System message following the official llm-jp/llm-jp-4-8b-thinking (Harmony)
# format. Keep build_system_message() in sync with LLMJP4_HARMONY_CHAT_TEMPLATE
# in prepare_llmjpvl.py (tests/test_chat_template.py checks they agree).
MODEL_IDENTITY = "You are LLM-jp-VL, a Multimodal LLM trained by LLM-jp."
KNOWLEDGE_CUTOFF = "2025-12"
DEFAULT_REASONING_EFFORT = "medium"
# Reasoning effort is conditioned on the CoT length of the (rendered) last turn,
# so the model learns to associate a higher effort with a larger thinking
# budget. Without conditioning, think/non-think samples share one effort and
# give a conflicting signal (the model then just skips analysis). Harmony has
# three levels: no CoT -> low; short CoT -> medium; long CoT (>= threshold,
# absolute so it holds across datasets with longer reasoning) -> high.
EFFORT_WITHOUT_THINK = "low"
THINK_EFFORT_TOKEN_THRESHOLD = 100 # think tokens >= threshold -> high, else medium
def effort_for_think_tokens(num_think_tokens: int) -> str:
"""Map a turn's CoT length to a Harmony reasoning-effort level."""
if num_think_tokens <= 0:
return EFFORT_WITHOUT_THINK
return "high" if num_think_tokens >= THINK_EFFORT_TOKEN_THRESHOLD else "medium"
# Reasoning effort is conditioned on whether the training sample carries CoT, so
# the model learns to associate the effort level with (not) emitting an analysis
# channel. Without this, think/non-think samples share one effort and give a
# conflicting signal (the model then just skips analysis).
EFFORT_WITH_THINK = "high"
EFFORT_WITHOUT_THINK = "low"
VALID_CHANNELS_LINE = (
"# Valid channels: analysis, commentary, final."
" Channel must be included for every message."
)
def build_system_message(
model_identity: str = MODEL_IDENTITY,
knowledge_cutoff: str = KNOWLEDGE_CUTOFF,
reasoning_effort: str = DEFAULT_REASONING_EFFORT,
) -> str:
# Unlike the official template, no "Current date:" line — a live date
# would make training samples and evaluation prompts non-reproducible.
return (
f"{model_identity}\n"
f"Knowledge cutoff: {knowledge_cutoff}\n\n"
f"Reasoning: {reasoning_effort}\n\n"
f"{VALID_CHANNELS_LINE}"
)