Skip to content
View as Markdown

tinker_cookbook.renderers.get_renderer

Generated from tinker-cookbook at commit 8486b8d. Source links point at that snapshot.

tinker_cookbook.renderers.get_renderer(name, tokenizer, image_processor, model_name)

Factory function to create renderers by name.

Parameters:

  • name (str) – Renderer name. Supported values: - "role_colon": Simple role:content format - "llama3": Llama 3 chat format - "qwen3": Qwen3 with thinking enabled - "qwen3_vl": Qwen3 vision-language with thinking - "qwen3_vl_instruct": Qwen3 vision-language instruct (no thinking) - "qwen3_disable_thinking": Qwen3 with thinking disabled - "qwen3_instruct": Qwen3 instruct 2507 (no thinking) - "qwen3_5": Qwen3.5 VL with thinking - "qwen3_5_disable_thinking": Qwen3.5 VL with thinking disabled - "qwen3_5_preserve_thinking": Qwen3.5 VL with thinking, keeping earlier reasoning in history so multi-turn episodes have the sequence extension property - "qwen3_8_xhigh_reasoning": Qwen3.8 with thinking (reasoning effort xhigh, the HF default) - "qwen3_8_medium_reasoning": Qwen3.8 with thinking, reasoning effort medium - "qwen3_8_low_reasoning": Qwen3.8 with thinking, reasoning effort low - "qwen3_8_disable_thinking": Qwen3.8 with thinking disabled - "deepseekv3": DeepSeek V3 (defaults to non-thinking mode) - "deepseekv3_disable_thinking": DeepSeek V3 non-thinking (alias) - "deepseekv3_thinking": DeepSeek V3 thinking mode - "deepseekv4_1": DeepSeek V4.1 thinking mode, high reasoning effort (HF default) - "deepseekv4_1_low_reasoning": DeepSeek V4.1 thinking mode, low reasoning effort - "deepseekv4_1_max_reasoning": DeepSeek V4.1 thinking mode, max reasoning effort - "deepseekv4_1_disable_thinking": DeepSeek V4.1 chat mode (no reasoning) - "deepseekv4_1_preserve_thinking": DeepSeek V4.1 thinking mode, keeping earlier reasoning in history so multi-turn episodes have the sequence extension property - "glm5_3_max_reasoning": GLM-5.3 / GLM-5.3-Flash with max reasoning effort (HF default) - "glm5_3_low_reasoning": GLM-5.3 / GLM-5.3-Flash with low reasoning effort (thinking cannot be disabled) - "glm5_3_high_reasoning": GLM-5.3 / GLM-5.3-Flash with high reasoning effort - "kimi_k2": Kimi K2 Thinking format - "kimi_k25": Kimi K2.5 with thinking enabled - "kimi_k25_disable_thinking": Kimi K2.5 with thinking disabled - "kimi_k26": Kimi K2.6 with thinking enabled (HF default — same token output as kimi_k25) - "kimi_k26_disable_thinking": Kimi K2.6 with thinking disabled - "kimi_k26_preserve_thinking": Kimi K2.6 with thinking enabled and historical <think>...</think> blocks preserved (HF preserve_thinking=true); use for long-horizon agents / multi-turn RL - "kimi_k31_pro_max_reasoning": Kimi K3.1-Pro with max reasoning effort - "kimi_k31_pro_high_reasoning": Kimi K3.1-Pro with high reasoning effort - "kimi_k31_pro_low_reasoning": Kimi K3.1-Pro with low reasoning effort - "kimi_k31_pro_disable_thinking": Kimi K3.1-Pro with thinking disabled - "kimi_k31_pro_no_reasoning_effort": Kimi K3.1-Pro with thinking and no effort message - "nemotron3": Nemotron-3 with full reasoning - "nemotron3_low_thinking": Nemotron-3 with low-effort reasoning (Super only) - "nemotron3_disable_thinking": Nemotron-3 with reasoning off - "nemotron3_preserve_thinking": Nemotron-3 (Nano/Super) with full reasoning and historical <think>...</think> blocks preserved (HF truncate_history_thinking=false); use for multi-turn RL / long-horizon agents - "nemotron3_ultra": Nemotron-3 Ultra / 3.5 Lightning / 3.5 Super with full reasoning - "nemotron3_ultra_disable_thinking": Nemotron-3 Ultra / 3.5 Lightning / 3.5 Super with reasoning off - "nemotron3_ultra_medium_thinking": Nemotron-3 Ultra / 3.5 Super with medium-effort reasoning - "nemotron3_ultra_preserve_thinking": Nemotron-3 Ultra / 3.5 Lightning / 3.5 Super with full reasoning and historical <think>...</think> blocks preserved (HF truncate_history_thinking=false) - "gpt_oss_no_sysprompt": GPT-OSS without system prompt - "gpt_oss_low_reasoning": GPT-OSS with low reasoning - "gpt_oss_medium_reasoning": GPT-OSS with medium reasoning - "gpt_oss_high_reasoning": GPT-OSS with high reasoning - Custom renderers registered via register_renderer()
  • tokenizer (Tokenizer) – The tokenizer to use.
  • image_processor (ImageProcessor | None) – Required for VL renderers.
  • model_name (str | None) – Model name for pickle metadata. If None, falls back to tokenizer.name_or_path. Provide this explicitly when the tokenizer was loaded with a remapped name (e.g., Llama 3 models).

Returns: Renderer – A Renderer instance configured for the specified format.

Raises:

  • RendererError: If the renderer name is unknown or if a VL renderer
  • is requested without an image_processor.
from tinker_cookbook import renderers
from tinker_cookbook.tokenizer_utils import get_tokenizer
tokenizer = get_tokenizer("Qwen/Qwen3-8B")
renderer = renderers.get_renderer("qwen3", tokenizer)
prompt = renderer.build_generation_prompt([
{"role": "user", "content": "Hello!"}
])