具体来说是:LM Studio 在尝试把对话消息转换成模型能理解的格式时,内置的 Jinja 模板里调用了某个未定义或不是函数的变量,导致渲染失败。
错误
2026-06-16 00:32:14 [ERROR]
[gemma-4-12b-it@q5_k_m] Error rendering prompt with jinja template: "Cannot call something that is not a function: got UndefinedValue".
This is usually an issue with the model's prompt template. If you are using a popular model, you can try to search the model under lmstudio-community, which will have fixed prompt templates. If you cannot find one, you are welcome to post this issue to our discord or issue tracker on GitHub. Alternatively, if you know how to write jinja templates, you can override the prompt template in My Models > model settings > Prompt Template.. Error Data: n/a, Additional Data: n/a
2026-06-16 00:32:18 [INFO]
[gemma-4-12b-it@q5_k_m] Running chat completion on conversation with 3 messages.
2026-06-16 00:32:18 [INFO]
[gemma-4-12b-it@q5_k_m] Streaming response…
2026-06-16 00:32:18 [ERROR]
[gemma-4-12b-it@q5_k_m] Error rendering prompt with jinja template: "Cannot call something that is not a function: got UndefinedValue".
This is usually an issue with the model's prompt template. If you are using a popular model, you can try to search the model under lmstudio-community, which will have fixed prompt templates. If you cannot find one, you are welcome to post this issue to our discord or issue tracker on GitHub. Alternatively, if you know how to write jinja templates, you can override the prompt template in My Models > model settings > Prompt Template.. Error Data: n/a, Additional Data: n/a
2026-06-16 00:32:19 [INFO]
[gemma-4-12b-it@q5_k_m] Running chat completion on conversation with 3 messages.
2026-06-16 00:32:19 [INFO]
[gemma-4-12b-it@q5_k_m] Streaming response…
2026-06-16 00:32:19 [ERROR]
[gemma-4-12b-it@q5_k_m] Error rendering prompt with jinja template: "Cannot call something that is not a function: got UndefinedValue".
This is usually an issue with the model's prompt template. If you are using a popular model, you can try to search the model under lmstudio-community, which will have fixed prompt templates. If you cannot find one, you are welcome to post this issue to our discord or issue tracker on GitHub. Alternatively, if you know how to write jinja templates, you can override the prompt template in My Models > model settings > Prompt Template.. Error Data: n/a, Additional Data: n/a
2026-06-16 00:32:19 [INFO]
[gemma-4-12b-it@q5_k_m] Running chat completion on conversation with 3 messages.
2026-06-16 00:32:19 [INFO]
[gemma-4-12b-it@q5_k_m] Streaming response…
2026-06-16 00:32:19 [ERROR]
[gemma-4-12b-it@q5_k_m] Error rendering prompt with jinja template: "Cannot call something that is not a function: got UndefinedValue".
This is usually an issue with the model's prompt template. If you are using a popular model, you can try to search the model under lmstudio-community, which will have fixed prompt templates. If you cannot find one, you are welcome to post this issue to our discord or issue tracker on GitHub. Alternatively, if you know how to write jinja templates, you can override the prompt template in My Models > model settings > Prompt Template.. Error Data: n/a, Additional Data: n/a
2026-06-16 00:32:20 [INFO]
[gemma-4-12b-it@q5_k_m] Running chat completion on conversation with 3 messages.
2026-06-16 00:32:20 [INFO]
[gemma-4-12b-it@q5_k_m] Streaming response…
2026-06-16 00:32:20 [ERROR]
[gemma-4-12b-it@q5_k_m] Error rendering prompt with jinja template: "Cannot call something that is not a function: got UndefinedValue".
This is usually an issue with the model's prompt template. If you are using a popular model, you can try to search the model under lmstudio-community, which will have fixed prompt templates. If you cannot find one, you are welcome to post this issue to our discord or issue tracker on GitHub. Alternatively, if you know how to write jinja templates, you can override the prompt template in My Models > model settings > Prompt Template.. Error Data: n/a, Additional Data: n/a
2026-06-16 00:32:22 [INFO]
[gemma-4-12b-it@q5_k_m] Running chat completion on conversation with 3 messages.
2026-06-16 00:32:22 [INFO]
[gemma-4-12b-it@q5_k_m] Streaming response…
2026-06-16 00:32:22 [ERROR]
[gemma-4-12b-it@q5_k_m] Error rendering prompt with jinja template: "Cannot call something that is not a function: got UndefinedValue".
This is usually an issue with the model's prompt template. If you are using a popular model, you can try to search the model under lmstudio-community, which will have fixed prompt templates. If you cannot find one, you are welcome to post this issue to our discord or issue tracker on GitHub. Alternatively, if you know how to write jinja templates, you can override the prompt template in My Models > model settings > Prompt Template.. Error Data: n/a, Additional Data: n/a
2026-06-16 00:32:25 [INFO]
[gemma-4-12b-it@q5_k_m] Running chat completion on conversation with 3 messages.
2026-06-16 00:32:25 [INFO]
[gemma-4-12b-it@q5_k_m] Streaming response…
2026-06-16 00:32:25 [ERROR]
[gemma-4-12b-it@q5_k_m] Error rendering prompt with jinja template: "Cannot call something that is not a function: got UndefinedValue".
This is usually an issue with the model's prompt template. If you are using a popular model, you can try to search the model under lmstudio-community, which will have fixed prompt templates. If you cannot find one, you are welcome to post this issue to our discord or issue tracker on GitHub. Alternatively, if you know how to write jinja templates, you can override the prompt template in My Models > model settings > Prompt Template.. Error Data: n/a, Additional Data: n/a
解决方案
问题根因
模型:gemma-4-12b-it@q5_k_m(Gemma 系列)
这个错误 "Cannot call something that is not a function: got UndefinedValue" 通常意味着:
模板与模型不匹配:LM Studio 自动识别或加载的 prompt template 可能不是为 Gemma 4 设计的,里面用到了 messages 或 add_generation_prompt 等变量/函数,但在当前上下文中这些值未定义。
Gemma 的 Chat Template 特殊:Gemma 系列(尤其是较新版本)的 Hugging Face tokenizer_config.json 中的 chat template 可能包含一些自定义 Jinja 宏或过滤器,LM Studio 的渲染引擎没有正确解析。
解决办法(按推荐顺序)
方法 1:换用 lmstudio-community 的修复版(最简单)
日志里其实已经提示了:
"If you are using a popular model, you can try to search the model under lmstudio-community, which will have fixed prompt templates."
在 LM Studio 的模型搜索里,找 lmstudio-community/gemma-4-12b-it(或类似名称),下载社区修复版。社区版通常会修正 Jinja 模板兼容性问题。
方法 2:手动覆盖 Prompt Template
如果你已经有模型文件,不想重新下载:

在 LM Studio 左侧点击 My Models
找到 gemma-4-12b-it,点击右侧的 ⚙️ Model Settings
找到 Prompt Template 区域
选择 Override(覆盖)
输入一个兼容的模板。对于 Gemma 模型,可以尝试以下简化模板:
jinja2{%
<<start_of_turn>{{ message.role }}
{{ message.content }}<<end_of_turn>
{% endfor %}
<<start_of_turn>model
或者更通用的 ChatML 格式:
jinja2{%
<|<|im_start|>{{ message.role }}
{{ message.content }}<|<|im_end|>
{% endfor %}
<|<|im_start|>assistant
⚠️ 注意:具体用哪种格式取决于你的模型量化版本实际训练时使用的格式。Gemma 原生通常用 <start_of_turn> 格式。
方法 3:检查 tokenizer_config.json
如果你是从 Hugging Face 下载的原始模型:
找到模型文件夹中的 tokenizer_config.json
打开它,找到 "chat_template" 字段
如果里面包含类似 {{ add_generation_prompt() }} 或 {{ bos_token }} 之类的调用,而 LM Studio 报错,说明某些函数/变量不被支持
可以临时把 tokenizer_config.json 里的 chat_template 改成简单的字符串拼接格式,或者直接在 LM Studio 里覆盖(方法 2)





