Chat models read role-marked text rather than the speech bubbles displayed in a chat. In LM Studio, a prompt template turns those messages into the model's input format, and a model-specific override changes that formatting for the next load.

LM Studio normally reads the template from the model's metadata. An override can help when a custom model has missing or incompatible metadata, or when a particular application needs different formatting; a model with valid metadata usually needs no change.

The override belongs to one model and takes effect when that model loads. An assistant prefill can appear in the formatted input without appearing in the reply bubble, so a successful chat alone does not prove which template was used.

The starting point is a downloaded, unloaded GGUF model and a working lms command in your terminal.
Related: Unload a model
Related: Verify the lms CLI

Steps to set a prompt template in LM Studio:

  1. Open Library from the left sidebar.
  2. Click the target model's gear button in My Models.
  3. Select the Load tab in the model settings.

    In LM Studio 0.4.28 with llama.cpp Engine Protocol, Inference → Prompt Template displays a moved-location notice; the editable control is Load → Advanced → Chat Template. The older Jinja and Manual selector described in the prompt-template documentation is not the editor shown here.

  4. Expand Advanced below Context and Offload.
  5. Expand Chat Template in the advanced load settings.

    The template must match the model's expected role markers and special tokens. This change adds an assistant prefill to the existing Qwen2.5 template; it does not repair faulty Qwen metadata. A template from another model family can break responses. The trash icon beside Chat Template removes this override and restores the model's default template.

  6. Replace the final assistant-generation line in the Qwen2.5 Jinja template with the prefill line below.

    The existing line is:

    {{- '<|im_start|>assistant\n' }}

    The replacement adds only the literal Answer: after the assistant-role newline:

    {{- '<|im_start|>assistant\nAnswer: ' }}

    The surrounding add_generation_prompt condition and the rest of the template stay intact. The field saves the model-specific override as it is edited.

  7. Click Load Model at the top of the model settings.

    A template change affects a new load. An instance loaded before the edit continues using its earlier template.

  8. Confirm Load Model in the load dialog.
  9. Dismiss the model settings panel by clicking outside it.
  10. Open Chat from the left sidebar.
  11. Create a New chat.
  12. Open Pick a model at the bottom of the new chat.
  13. Select the model under LOADED MODELS.
  14. Start the input log stream in your terminal.

    Input logs contain message text. A synthetic question avoids recording a private conversation.

    $ lms log stream --source model --filter input --json

    The model source records the formatted input sent to the model. –filter input omits model output, and –json exposes the formatted string in data.input. The stream remains open while the chat runs.
    Related: View LM Studio logs

  15. Enter Name one primary color using one word. in the message box.
  16. Send the message with the upward-arrow button.
  17. Confirm that the model returns a reply.

    The reply can omit the prefill because Answer: was already supplied as model input.

  18. Check that the data.input value ends with the assistant prefill.
    assistant\nAnswer: 

    In the JSON string, \n represents the newline after the assistant role, and a space follows the colon. This ending proves that the loaded model used the custom prefill on the new request; a reply alone cannot establish that. An unchanged ending or a template-parsing error means the intended formatting was not applied.

Share this guide