{"record":{"id":"6eccd042d0283a92","repo":"hiyouga/LlamaFactory","slug":"minicpm-v-model-does-not-support-input-images-and","errorCode":null,"errorMessage":"MiniCPM-V model does not support input images and videos at the same time.","messagePattern":"MiniCPM-V model does not support input images and videos at the same time\\.","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"src/llamafactory/data/mm_plugin.py","lineNumber":1648,"sourceCode":"        return mm_inputs\n\n    @override\n    def process_messages(\n        self,\n        messages: list[dict[str, str]],\n        images: list[\"ImageInput\"],\n        videos: list[\"VideoInput\"],\n        audios: list[\"AudioInput\"],\n        processor: Optional[\"MMProcessor\"],\n    ) -> list[dict[str, str]]:\n        self._validate_input(processor, images, videos, audios)\n        self._validate_messages(messages, images, videos, audios)\n        num_image_tokens, num_video_tokens, num_audio_tokens = 0, 0, 0\n        messages = deepcopy(messages)\n        image_processor: BaseImageProcessor = getattr(processor, \"image_processor\")\n        mm_inputs, audio_inputs = {}, {}\n        if len(images) != 0 and len(videos) != 0:\n            raise ValueError(\"MiniCPM-V model does not support input images and videos at the same time.\")\n\n        if len(videos) != 0:\n            max_slice_nums = 2\n            use_image_id = False\n            mm_inputs = self._get_mm_inputs([], videos, [], processor)\n        else:\n            max_slice_nums = image_processor.max_slice_nums\n            use_image_id = image_processor.use_image_id\n\n        for i, message in enumerate(messages):\n            content = message[\"content\"]\n            while IMAGE_PLACEHOLDER in content:\n                content = content.replace(IMAGE_PLACEHOLDER, \"{{image}}\", 1)\n                num_image_tokens += 1\n\n            while VIDEO_PLACEHOLDER in content:\n                video_seqlen = len(mm_inputs[\"image_sizes\"][num_video_tokens]) if self.expand_mm_tokens else 1\n                content = content.replace(VIDEO_PLACEHOLDER, \"{{image}}\" * video_seqlen, 1)","sourceCodeStart":1630,"sourceCodeEnd":1666,"githubUrl":"https://github.com/hiyouga/LlamaFactory/blob/f28afaf6355af515454dfb16c97d728307c93897/src/llamafactory/data/mm_plugin.py#L1630-L1666","documentation":"The MiniCPM-V plugin's process_messages refuses samples that contain both images and videos: the MiniCPM-V architecture and its chat template cannot interleave the two modalities in one conversation.","triggerScenarios":"Using template 'minicpm_v' with a dataset row whose messages contain both <img>/(image) and <video> placeholders, or whose images and videos columns are both non-empty.","commonSituations":"Mixed-media datasets reused across models; a row that always carries an images column (e.g. empty string still counts) alongside videos.","solutions":["Split the sample: keep either the images or the videos, and remove the other modality's placeholders.","Filter mixed rows from the dataset before training with MiniCPM-V.","Use a model/plugin that supports mixed media (e.g. qwen2_vl/qwen3_vl) if mixed samples are required."],"exampleFix":"// before\n{\"content\": \"<image> and <video>\", \"images\": [\"a.jpg\"], \"videos\": [\"b.mp4\"]}\n// after\n{\"content\": \"<video>\", \"videos\": [\"b.mp4\"]}  // image removed for MiniCPM-V","handlingStrategy":"validation","validationCode":"assert not (images and videos), 'MiniCPM-V cannot mix images and videos in one sample'","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Maintain separate dataset configs for image-only and video-only samples when using MiniCPM-V."],"tags":["multimodal","minicpm-v","mixed-media","unsupported-feature"],"backgroundTag":null,"analyzedSha":"f28afaf6355af515454dfb16c97d728307c93897","analyzedAt":"2026-08-14T21:57:28.298Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}