koboldcpp/tools/mtmd
Pepper Gray ca86fb222e
llama : add missing headers (#28566)
* fix compile-error: add missing header

Bug: #28557
Signed-off-by: Pepper Gray <hello@peppergray.xyz>

* fix compile-error: add missing header

Bug: #28559
Signed-off-by: Pepper Gray <hello@peppergray.xyz>

* fix compile-error: add missing header

Bug: #28560
Signed-off-by: Pepper Gray <hello@peppergray.xyz>

* fix compile-error: add missing header

Bug: #28561
Signed-off-by: Pepper Gray <hello@peppergray.xyz>

* fix compile-error: add missing header

Bug: #28562
Signed-off-by: Pepper Gray <hello@peppergray.xyz>

* fix compile-error: add missing header

Bug: #28564
Signed-off-by: Pepper Gray <hello@peppergray.xyz>

---------

Signed-off-by: Pepper Gray <hello@peppergray.xyz>
2026-09-08 12:59:53 +02:00
..
debug mtmd: add --mmproj-device argument (#23255) 2026-08-20 18:45:37 +02:00
legacy-models
models ggml : update ggml_prec specification (#26675) 2026-09-08 09:06:24 +03:00
tests sampler : remove "full-context windows" from history-based samplers (#26524) 2026-08-04 21:28:55 +03:00
clip-graph.h mtmd: use ggml_rope_set_offset (#27521) 2026-08-22 16:33:47 +02:00
clip-impl.h mtmd: support DeepSeek-V4-Flash-Vision-Exp (#28133) 2026-09-02 16:43:43 +02:00
clip-model.h mtmd: support DeepSeek-V4-Flash-Vision-Exp (#28133) 2026-09-02 16:43:43 +02:00
clip.cpp ggml : update ggml_prec specification (#26675) 2026-09-08 09:06:24 +03:00
clip.h mtmd: add --mmproj-device argument (#23255) 2026-08-20 18:45:37 +02:00
CMakeLists.txt mtmd: support DeepSeek-V4-Flash-Vision-Exp (#28133) 2026-09-02 16:43:43 +02:00
deprecation-warning.cpp llama : add missing headers (#28566) 2026-09-08 12:59:53 +02:00
mtmd-audio.cpp mtmd: propagate const to preproc class (#28310) 2026-09-03 12:57:10 +02:00
mtmd-audio.h mtmd: propagate const to preproc class (#28310) 2026-09-03 12:57:10 +02:00
mtmd-cli.cpp mtmd: add mtmd_tokenize_from_parts() (#28250) 2026-09-02 21:20:10 +02:00
mtmd-helper-common.h mtmd, common: various fixes (#27071) 2026-08-14 23:34:56 +02:00
mtmd-helper-gen.cpp mtmd: support pocket-tts (#26871) 2026-08-11 14:18:30 +02:00
mtmd-helper.cpp mtmd : add const in various places (#28307) 2026-09-03 12:12:49 +02:00
mtmd-helper.h mtmd : add const in various places (#28307) 2026-09-03 12:12:49 +02:00
mtmd-image.cpp mtmd: propagate const to preproc class (#28310) 2026-09-03 12:57:10 +02:00
mtmd-image.h mtmd: propagate const to preproc class (#28310) 2026-09-03 12:57:10 +02:00
mtmd-internal.h mtmd: add mtmd_tokenize_from_parts() (#28250) 2026-09-02 21:20:10 +02:00
mtmd.cpp model, mtmd: fix gemma4 vision handling (#28335) 2026-09-04 12:23:27 +02:00
mtmd.h mtmd : add const in various places (#28307) 2026-09-03 12:12:49 +02:00
README-dev.md mtmd: add mtmd_tokenize_from_parts() (#28250) 2026-09-02 21:20:10 +02:00
README.md
requirements.txt requirements: use stable torch packages on s390x (#26864) 2026-08-11 21:58:53 +08:00
test-1.jpeg
test-2.mp3
test-3.mp4 mtmd : add video input support (#24269) 2026-06-08 14:40:12 +03:00
tests.sh mtmd: add batching for mtmd-cli, add video tests (#24778) 2026-06-18 21:55:04 +02:00

Multimodal Support in llama.cpp

This directory provides multimodal capabilities for llama.cpp. Initially intended as a showcase for running LLaVA models, its scope has expanded significantly over time to include various other vision-capable models. As a result, LLaVA is no longer the only multimodal architecture supported.

Important

Multimodal support can be viewed as a sub-project within llama.cpp. It is under very heavy development, and breaking changes are expected.

The naming and structure related to multimodal support have evolved, which might cause some confusion. Here's a brief timeline to clarify:

  • #3436: Initial support for LLaVA 1.5 was added, introducing llava.cpp and clip.cpp. The llava-cli binary was created for model interaction.
  • #4954: Support for MobileVLM was added, becoming the second vision model supported. This built upon the existing llava.cpp, clip.cpp, and llava-cli infrastructure.
  • Expansion & Fragmentation: Many new models were subsequently added (e.g., #7599, #10361, #12344, and others). However, llava-cli lacked support for the increasingly complex chat templates required by these models. This led to the creation of model-specific binaries like qwen2vl-cli, minicpmv-cli, and gemma3-cli. While functional, this proliferation of command-line tools became confusing for users.
  • #12849: libmtmd was introduced as a replacement for llava.cpp. Its goals include providing a single, unified command-line interface, improving the user/developer experience (UX/DX), and supporting both audio and image inputs.
  • #13012: mtmd-cli was added, consolidating the various model-specific CLIs into a single tool powered by libmtmd.

Pre-quantized models

See the list of pre-quantized model here

How it works and what is mmproj?

Multimodal support in llama.cpp works by encoding images into embeddings using a separate model component, and then feeding these embeddings into the language model.

This approach keeps the multimodal components distinct from the core libllama library. Separating these allows for faster, independent development cycles. While many modern vision models are based on Vision Transformers (ViTs), their specific pre-processing and projection steps can vary significantly. Integrating this diverse complexity directly into libllama is currently challenging.

Consequently, running a multimodal model typically requires two GGUF files:

  1. The standard language model file.
  2. A corresponding multimodal projector (mmproj) file, which handles the image encoding and projection.

What is libmtmd?

As outlined in the history, libmtmd is the modern library designed to replace the original llava.cpp implementation for handling multimodal inputs.

Built upon clip.cpp (similar to llava.cpp), libmtmd offers several advantages:

  • Unified Interface: Aims to consolidate interaction for various multimodal models.
  • Improved UX/DX: Features a more intuitive API, inspired by the Processor class in the Hugging Face transformers library.
  • Flexibility: Designed to support multiple input types (text, audio, images) while respecting the wide variety of chat templates used by different models.

How to obtain mmproj

Multimodal projector (mmproj) files are specific to each model architecture.

For the following models, you can use convert_hf_to_gguf.py with --mmproj flag to get the mmproj file:

  • Gemma 3 ; See the guide here - Note: 1B variant does not have vision support
  • SmolVLM (from HuggingFaceTB)
  • SmolVLM2 (from HuggingFaceTB)
  • Pixtral 12B - only works with transformers-compatible checkpoint
  • Qwen 2 VL and Qwen 2.5 VL (from Qwen)
  • Mistral Small 3.1 24B
  • InternVL 2.5 and InternVL 3 from OpenGVLab (note: we don't support conversion of InternVL3-*-hf model, only non-HF version is supported ; InternLM2Model text model is not supported)
  • MiniCPM-V 4.6 ; See the guide here - requires the standard transformers v5.7.0+ checkpoint

For older models, please refer to the relevant guide for instructions on how to obtain or create them:

NOTE: conversion scripts are located under tools/mtmd/legacy-models