Repository navigation
Conversation
The Gemma 4 model card recommends image content before the text and audio content after it. Both prompt builders put images and audio before the text; audio now follows it, for gemma4-it (E2B, E4B and their flash and dflash variants) and gemma4-it:12b, from the server and the CLI. The media payload reaches the engine with the first prefill chunk only, which was widened to reach the last image. With audio after the text, a long text would push the audio into a later chunk without its payload. The first chunk now reaches the last image or audio clip (plan.media_end), as for Qwen3.5-Omni, and media_end_by_kind, which only Gemma 4 read, is gone.
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The Gemma 4 model card ("Best Practices", "Modality order") recommends putting image content before the text and audio content after it. FastFlowLM puts both images and audio before the text. Images stay where they are; audio now follows the text, in both the server and the CLI prompt builders of
gemma4-it(E2B, E4B and their flash and dflash variants) andgemma4-it:12b.Before:
After:
The media payload reaches the engine with the first prefill chunk only, and that chunk was widened to reach the last image. With audio after the text, a long text would push the audio into a later chunk without its payload. The first chunk now reaches the last image or audio clip (
plan.media_end), as for Qwen3.5-Omni, and the per-kindmedia_end_by_kindthat only Gemma 4 used is removed.How to reproduce
The order isn't visible through the API, so this shows the prefill chunking and the transcript. Make a short speech clip and send it after a long text (about 7,800 tokens):
mainPrefill chunk 1/2 with 4096 tokens,Prefill chunk 2/2 with 3708 tokensPrefill chunk 1/1 with 7804 tokensThe single chunk is the payload fix: the audio now comes after the text, so the first chunk is widened to reach it. The transcript difference is one example on this clip, not a measurement.
I found this while comparing the prompts flm renders with Google's template, using a small debug branch that logs every prompt to a file (
log-prompt,FLM_LOG_PROMPT=<file>).