Feat/web chat multimodal#181
Merged
Merged
Conversation
Tested on the 0.6.1-beta.1 build: rebuilding the projector per request did
NOT change the failure. Dark / low-contrast / portrait images still degrade
identically ("collage / vertical repetition", person not seen), while clear
landscape photos still work. The failure is therefore deterministic by image
type and lives upstream in the Gemma 4 projector/encoder (cf. llama.cpp
multimodal issues), not in shared mtmd state on our side.
Reverting restores the load-once projector and removes the ~150-300 ms
per-request re-init cost that bought us nothing. The WebP→PNG conversion and
the stream-error surfacing from the same beta stay — those are real fixes.
Root-caused the "hard images misread" behaviour: Gemma 4 (GEMMA4UV) is a
dynamic-resolution vision model that caps an image at max 280 tokens
(clip.cpp: set_limit_image_tokens(40, 280)). That low cap downscales images
hard; on dark / low-contrast / small-subject photos the encoder loses the
subject and the model confabulates ("collage / repeated text"). The author's
own comment notes the model "performs quite poor with small images".
The mtmd C API already exposes image_min_tokens / image_max_tokens and passes
them to clip, but our vendored binding didn't surface them. This:
* adds image_min_tokens / image_max_tokens to MtmdContextParams (+ both From
impls), defaulting to -1 (= keep model metadata default),
* wires EULLM_IMAGE_MAX_TOKENS / EULLM_IMAGE_MIN_TOKENS env overrides in
init_mtmd_optional so the budget can be raised without recompiling.
Lets us empirically test whether more resolution fixes the hard images.
Caveat: very high values can OOM/crash some projectors (cf. llama.cpp#21550);
raise in moderate steps (512, then 1024).
Second 0.6.1 pre-release. Over beta.1: * expose EULLM_IMAGE_MAX_TOKENS / EULLM_IMAGE_MIN_TOKENS to raise Gemma 4's 280-token image cap (the suspected cause of hard-image misreads), * revert the per-request MtmdContext experiment (no effect on the failure). WebP→PNG conversion, stream-error surfacing and web audio carried over.
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.
No description provided.