Auto-load a matching mmproj so vision models just work - #254
Auto-load a matching mmproj so vision models just work#254GiuseppeCapaldo93 wants to merge 2 commits into
Conversation
When a model is launched, look for a multimodal projector (mmproj) whose filename correlates with the model (quantization/precision tokens ignored, e.g. Nemotron-...-Q4_K_M matches mmproj-Nemotron-...-BF16) in models/mmproj/ or models/, and pass it as -mm automatically. Respects an explicit -mm/--mmproj/--no-mmproj and can be disabled via LLAMA_GUI_AUTO_MMPROJ=0. Requires a substantial name overlap to avoid false matches (e.g. LFM2 won't grab an unrelated projector). Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
e4463e6 to
88bed79
Compare
|
P2 — Make automatic mmproj matching conservative The feature direction looks good, but the current substring/length fallback can attach an incompatible same-family projector. For example:
Because A narrow fix would be:
This keeps the existing directory scan, explicit |
|
Thanks for the detailed review — addressed in the latest push (fdfdcbc).
The directory scan, explicit |
|
Almost there, Thanks — I found one remaining P2 edge case in
can launch the selected model while auto-attaching the old model’s projector. Similarly, a later The narrow fix would be to reuse the existing helper: model_flag, model_path = _last_launch_flag_entry(
flat_launch_args, _MODEL_VALUE_FLAGS
)
if model_flag not in _LOCAL_MODEL_VALUE_FLAGS or not model_path:
return [] |
Launching a vision model previously required manually passing the multimodal projector. When a matching mmproj file is present, add "-mm <path>" for the vision-capable tools (llama-server / llama-cli / llama-mtmd-cli), unless the user already set an mmproj flag or --no-mmproj. Matching is conservative: model and mmproj filenames must reduce to the same normalized key (extension, shard suffix, a leading "mmproj" marker, and quantization/precision tokens are stripped), so a quantized model matches its BF16/F16 projector while a close-but-different family version does not. The q-quant token is normalized whole, including legacy Qn_n forms such as Q4_0 and Q5_1, so no trailing digit is left behind. The effective (last) model source drives matching, via the existing _last_launch_flag_entry precedence helper: Custom Launch Args may repeat -m/--model and sit before the UI-selected model, and a later remote -hf/-mu source suppresses auto-detection so no local projector is wrongly attached. Projector discovery scans the dedicated models/mmproj/ tree recursively (so a projector the downloader stored under models/mmproj/<repo-slug>/<file>.gguf is rediscovered after a reload) and the plain models/ directory shallowly (for manually placed files), recognizing the same names the downloader accepts (mmproj / clip* / projector) via is_mmproj_filename. Adds tests for quant normalization, exact-key matching (positive and negative), last/effective model source, remote-source suppression, recursive discovery of a downloaded projector, and clip/projector name recognition. The directory scan, explicit -mm / --no-mmproj handling, tool scope, environment toggle, and launch integration are unchanged. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
fdfdcbc to
f550445
Compare
|
Thanks — all three points are addressed (f550445).
Full backend suite passes (493 tests). (For reference, the same review was also posted on #253 — these fixes live here on the mmproj branch.) |
|
This one will take a little extra time on my end, I'm putting it on hold for a bit. |
Oops, didn't realize that happened. |
|
Sadly this conflicts with changes that were in progress regarding model discoverability in subfolders. I'll have to close for now. |
Motivation
Multimodal (vision) GGUF models need a companion multimodal projector
(
mmproj) passed via-mm. Today the projector has to be located and wired upby hand; if it is forgotten the model loads without vision and there is no
obvious hint why.
Change
When a model is launched, look for an
mmprojwhose filename correlates withthe model file and pass it as
-mmautomatically:models/mmproj/tree recursively (so a projector thedownloader stored under
models/mmproj/<repo-slug>/is rediscovered after areload) and
models/shallowly, recognizingmmproj/clip*/projectornames.
shard suffixes, so e.g.
Nemotron-…-Q4_K_M.ggufmatchesmmproj-Nemotron-…-BF16.gguf.(e.g.
-V-2.6vs-V-2) or an unrelated model will not grab a strayprojector.
-mor a later remote-hf/--model-urlis honored rather than the first-m.-mm/--mmproj/--mmproj-url/--no-mmproj, andonly applies to
llama-server/llama-cli/llama-mtmd-cli.LLAMA_GUI_AUTO_MMPROJ=0.Testing
AutoMmprojTestscovering key normalization, companion matching,false-positive avoidance, and the override/disable paths.