Run this model with HF Jobs

Run moonshotai/Kimi-K2-Instruct on Hugging Face's managed compute, monitor its progress, and retrieve the results when it's done.

Paste one of these prompts into your coding agent:

Fine-tune on my dataset

Use HF Jobs and TRL to fine-tune https://huggingface.co/moonshotai/Kimi-K2-Instruct. Ask me which dataset to train on, then push the fine-tuned model to a new model repo. Run `hf jobs --help` first to learn the CLI.

Run batch inference

Use HF Jobs to run batch inference with https://huggingface.co/moonshotai/Kimi-K2-Instruct on the inputs in a mounted HF Bucket. Ask me which Bucket to use, then write the outputs back to it and keep each input ID. Run `hf jobs --help` first to learn the CLI.

Evaluate on a benchmark

Use HF Jobs to evaluate https://huggingface.co/moonshotai/Kimi-K2-Instruct. Ask me which benchmark to run, then save the scores and the per-example results to a new dataset repo. Run `hf jobs --help` first to learn the CLI.

Quantize for lower memory use

Use HF Jobs to create a 4-bit version of https://huggingface.co/moonshotai/Kimi-K2-Instruct. Push it to a new model repo, then reload it from there and report its memory footprint. Run `hf jobs --help` first to learn the CLI.

Should the chat template include <think> in the generation prompt for tool calling?

#61
by dansalib - opened

Hi! I've been experimenting with Kimi-K2-Instruct for tool calling use cases and noticed some intermittent issues I wanted to ask about.

What I'm seeing:

When using the model with tools enabled, I occasionally get incomplete responses where the model seems to stop mid-thought. Looking at the raw token output, I noticed it sometimes generates <|im_end|> before completing the tool call.

After some debugging, I noticed the current chat template's generation prompt is:

  {%- if add_generation_prompt -%}
    <|im_assistant|>assistant<|im_middle|>
  {%- endif -%}

My question:

Since Kimi-K2 is a thinking model that outputs ... blocks, should the generation prompt include the opening tag to ensure the model starts in thinking mode?

Something like:

  {%- if add_generation_prompt -%}
    <|im_assistant|>assistant<|im_middle|><think>
  {%- endif -%}

I noticed that when I manually add to the generation prompt, the model's tool calling behavior becomes more consistent. But I'm not sure if this is the intended usage or if I'm missing something in my setup.

Context

  • Using the model via vLLM with --enable-auto-tool-choice
    --tool-call-parser kimi_k2
  • Temperature: 1.0, top_p: 1.0 (default settings)
  • The issue happens roughly 1 in 20 requests

Would love to hear if this is expected behavior or if there's a recommended way to handle this. Thanks!

Sign up or log in to comment