Skip to content

fix(generate): start a chat reply on its own line after the prompt echo - #2862

Merged
inureyes merged 1 commit into
mainfrom
fix/generate-prompt-echo-newline
Nov 5, 2026
Merged

inureyes merged 1 commit into
mainfrom
fix/generate-prompt-echo-newline

Conversation

@inureyes

@inureyes inureyes commented Nov 5, 2026 •

Copy link
Copy Markdown
Member

mlxcel generate echoes the user prompt and then streams the reply with no separator, so with a chat template the reply runs on from the prompt:

Generating...
Write a haiku about running a language model on a laptop.Cores ablaze bright

A chat-templated reply is a new assistant turn, so the echo now ends with a newline and the reply starts on the next line. Raw completion (--no-chat-template, or a checkpoint without a template) is unchanged: the continuation still follows the prompt text directly.

This lines up with llama.cpp (checked at 69ee2ec): llama-cli echoes > prompt on its own line before the reply, llama-completion in conversation mode echoes the rendered template so the reply follows the assistant header, and only -no-cnv raw completion prints prompt and continuation as one passage.

Validation on an M1 Ultra: two new unit tests in generate_tests.rs; Meta-Llama-3.1-8B-Instruct-4bit and gemma-4-e4b-it-4bit (with --image) now print the reply on the line after the prompt; --no-chat-template -p "The capital of France is" still prints The capital of France is Paris.. cargo fmt --check and clippy on the binary target are clean. Not run locally: the model-gated integration tests that parse generate stdout (tests/lang_bias.rs, tests/surgery_cli.rs, tests/common/mod.rs::extract_generated_body); they read the text after Generating...\n, which now starts with the prompt line and a newline, so the extracted body gains one newline and their comparisons are between runs of the same build.

The mlxcel.ai landing page captures were re-recorded with this change.

`mlxcel generate` echoes the user prompt and then streams the reply with no separator, so a chat-templated reply runs on from the prompt ("...on a laptop.Cores ablaze bright"). With a chat template the reply is a new assistant turn, so the echo now ends with a newline. Without one (`--no-chat-template`, or a checkpoint that has no template) the reply continues the prompt text and the echo is unchanged.

This matches llama.cpp: `llama-cli` echoes the prompt as `> prompt` on its own line before the reply, `llama-completion` in conversation mode echoes the rendered template so the reply follows the assistant header, and only raw `-no-cnv` completion prints prompt and continuation as one passage.

The text, pipeline, and XLA paths decide from whether the rendered prompt differs from the user prompt; the diffusion, LLaDA-2, and Florence-2 paths from `--no-chat-template`; Nemotron Parse always starts its output on a new line.

Validated with two unit tests and real runs on an M1 Ultra: Meta-Llama-3.1-8B-Instruct-4bit and gemma-4-e4b-it-4bit put the reply on the line after the prompt, and `--no-chat-template -p "The capital of France is"` still prints "The capital of France is Paris.".
@inureyes inureyes added status:review Under review type:bug Bug fixes, error corrections, or issue resolutions priority:medium Medium priority labels Nov 5, 2026
@inureyes
inureyes merged commit a9abf5a into main Nov 5, 2026
31 checks passed
@inureyes
inureyes deleted the fix/generate-prompt-echo-newline branch November 5, 2026 23:26
@inureyes inureyes added status:done Completed and removed status:review Under review labels Nov 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

priority:medium Medium priority status:done Completed type:bug Bug fixes, error corrections, or issue resolutions

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant