Skip to content

Local UI to run and train LLMs and diffusion models. Supports GGUF, MLX, Qwen3.8, DeepSeek-V4.1, MiniMax-H3, Gemma 4, FLUX and more.

Studio: leave rows with a null caption out of vision training (#14726)

Vineeth Sai Varikuntlac18042bb3cf9
diff --git a/studio/backend/tests/test_vlm_null_caption_rows.py b/studio/backend/tests/test_vlm_null_caption_rows.py
new file mode 100644
index 00000000000..90c4e1e1e27
--- /dev/null
+++ b/studio/backend/tests/test_vlm_null_caption_rows.py
@@ -0,0 +1,21 @@
+# SPDX-License-Identifier: AGPL-3.0-only
+# Copyright 2026-present the Unsloth AI Inc. team. All rights reserved. See /studio/LICENSE.AGPL-3.0
+
+from datasets import Dataset
+from PIL import Image
+
+from utils.datasets import format_conversion
+
+
+def test_rows_with_a_null_caption_are_left_out_of_vision_training():
+ ds = Dataset.from_dict(
+ {
+ "image": [Image.new("RGB", (4, 4)) for _ in range(3)],
+ "text": ["a cat", None, "a dog"],
+ }
+ )
+
+ out = format_conversion.convert_to_vlm_format(ds, instruction = "Describe.")
+
+ answers = [sample["messages"][1]["content"][0]["text"] for sample in out]
+ assert answers == ["a cat", "a dog"]
diff --git a/studio/backend/utils/datasets/format_conversion.py b/studio/backend/utils/datasets/format_conversion.py
index 510fb548469..0d22d5d219e 100644
--- a/studio/backend/utils/datasets/format_conversion.py
+++ b/studio/backend/utils/datasets/format_conversion.py
@@ -520,6 +520,13 @@ def convert_to_vlm_format(
dataset = dataset.select(with_image)
total = len(with_image)
+ # A null caption would render as the word "None" in the assistant turn, so leave those rows out like rows without an image.
+ with_text = [i for i, text in enumerate(dataset[text_column]) if text is not None]
+ if len(with_text) < total:
+ logger.info(f"Skipping {total - len(with_text)}/{total} rows without text")
+ dataset = dataset.select(with_text)
+ total = len(with_text)
+
_image_lookup = None
_IMAGE_EXTS = (".png", ".jpg", ".jpeg", ".webp", ".gif", ".bmp", ".tiff")
if (