diff --git a/CHANGELOG.md b/CHANGELOG.md index 2a9ee102e..076c565b4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -98,6 +98,26 @@ `LlamaStructuredOutput.parse` still decode it); trim replies you compare exactly. `ChatSession` and its tool loop store assistant turns in `history` without that whitespace, so the next prompt is unchanged. +- **Behavior change:** an image or audio part of a chat request to a GGUF + model takes the place it has in its message, as llama.cpp's `llama-server` + renders it ([#964](https://github.com/leehack/llamadart/issues/964)). For + Qwen3.5 and Qwen2.5-Omni it was attached before the whole prompt, and for + GLM-OCR it was wrapped in the image start and end tokens twice, so prompts + for media turns of these models change. A chat template no longer writes + its own text for a media part: Qwen's `Picture N: ` under `add_vision_id`, + the Kimi-K2 wrapper, Reka's run of image tokens and Cohere's + `<|IMG_PATCH|>` are gone, as on `llama-server`. A placeholder string that + a chat message quotes (``, ``, `[IMG]`, `<__media__>`) is text + instead of a part. Where the runtime would still read such a string as a + part, it reaches the model with a zero-width space (U+200B) after its + first character, which the model may repeat in its answer: a quoted + `<__media__>` in `create` on native; every placeholder the bridge + rewrites in `create` on Web; and every placeholder `generate` reads in the + prompt `chatTemplate` returns for messages with media and in `create` on + a custom backend without `BackendChatPromptGeneration`, which + `package:llamadart/backend.dart` now exports. A prompt written for + `generate` keeps its placeholders, and `chatTemplate` output for messages + without media is unchanged. ## 0.11.1 diff --git a/doc/litert_lm_templates.md b/doc/litert_lm_templates.md index 66e4d7a75..a5961628a 100644 --- a/doc/litert_lm_templates.md +++ b/doc/litert_lm_templates.md @@ -209,9 +209,9 @@ Templates are committed as jinja under `tool/litert_lm_templates/` and embedded into `lib/src/backends/litert_lm/litert_lm_chat_templates.dart` by a generator. Start from the canonical template llama.cpp uses. Keep any runtime content-shape adapter in this source and cover it with prompt-parity tests. -An adapter that reads content part lists either renders image and audio parts -or rejects both: the Dart renderer gives a template that reads part lists -media as typed parts unless it rejects both kinds. Pin the result in +The Dart renderer gives an adapter the media marker in the message text and +never an image or audio part. It still reports an adapter that reads content +part lists but rejects both kinds as reading strings only. Pin the result in `test/unit/core/template/template_caps_cache_fixtures_test.dart`. 1. Copy the canonical jinja into `tool/litert_lm_templates/.jinja` diff --git a/doc/webgpu_bridge.md b/doc/webgpu_bridge.md index 70960841f..f49378657 100644 --- a/doc/webgpu_bridge.md +++ b/doc/webgpu_bridge.md @@ -342,6 +342,17 @@ gates against real assets and models; its header lists the setup. exported from `package:llamadart`. - Large model URL loads can use a worker-thread fetch-backed path to reduce contiguous `ArrayBuffer` pressure, but only after an explicit opt-in. +- With media parts the bridge reads its marker `<__media__>` and the + placeholders it rewrites to it (``, `[IMG]`, `<|image|>`, ``, + `<|img|>`, `<|vision_start|><|image_pad|><|vision_end|>` and its + `video_pad` form, `