Qwen2.5-VL multimodal video understanding model – temporal semantic parsing and natural language description generation
URL, Base64 encoding, and binary streamprompt parameterInput column name | Note |
|---|---|
videos | An array containing video data; element types are string or binary. |
user_prompts | The prompt for video understanding; defaults to None. If not provided, the prompt parameter will be used by default. |
The processed array, where each element is the visual understanding result for each video.
If a parameter does not have a default value, it is required
Parameter name | Type | Default value | Description |
|---|---|---|---|
video_src_type | str | video_url | The input video format type. Supported types: - tos / http address (video_url) - base64 encoding (video_base64) - binary stream (video_binary) Optional values: ["video_url", "video_base64", "video_binary"] Default value: "video_url" |
model_path | str | /opt/las/models | The absolute path for storing local model files; defaults to the preset path inside the container. When using a custom model, this path must be modified. Default value: "/opt/las/models" |
model_name | str | Qwen/Qwen2.5-VL-7B-Instruct | Supported visual language model versions. Currently, only the Qwen2.5-VL series models are supported. Optional values: ["Qwen/Qwen2.5-VL-7B-Instruct"] Default value: "Qwen/Qwen2.5-VL-7B-Instruct" |
prompt | str | Please provide a detailed description of this video. | The prompt for users to understand video content; the model will generate a description of the video based on the prompt. Default value: "Please provide a detailed description of this video." |
batch_size | int | 4 | The number of samples processed per inference. A larger batch_size can improve throughput but increases VRAM consumption; it is recommended to adjust according to GPU VRAM. Default value: 4 |
dtype | str | bfloat16 | Model inference precision selection: - bfloat16: balances precision and speed - float16: faster inference speed - float32: highest precision but uses the most GPU memory Available values: ["bfloat16", "float16", "float32"] Default value: "bfloat16" |
use_flash_attention_2 | bool | True | Whether to use Flash Attention 2 to optimize attention computation (effective only when CUDA-compatible and dtype is 16-bit floating point) Default value: True |
max_caption_length | int | 256 | Maximum number of tokens for model-generated descriptions. Longer generations may contain more details but increase computation time. Default value: 256 |
min_pixels | int or None | None | Minimum video pixels. If not set, the original video pixels are used by default. The larger the video pixels, the higher the GPU memory usage. Default value: None |
max_pixels | int or None | None | Maximum video pixels. If not set, the original video pixels are used by default. The larger the video pixels, the higher the GPU memory usage. Default value: None |
fps | float or None | None | Video frame rate. If not set, the original video frame rate is used by default. The higher the video frame rate, the higher the GPU memory usage. Default value: None |
do_sample | bool | False | Whether to enable sampling generation. When True, the model samples the next token probabilistically, resulting in more diverse outputs; when False, greedy or beam search is used, resulting in more deterministic outputs. Default value: False |
temperature | float | 1.0 | Sampling temperature, controls the randomness of generated content. The higher the value, the more diverse the generation; the lower the value, the more conservative the generation. Default value: 1.0 |
top_k | int | 50 | During sampling, the next token is selected only from the top k tokens with the highest probability. A smaller k value increases relevance, while a larger k value increases diversity. Default value: 50 |
top_p | float | 1.0 | Cumulative probability threshold for nucleus sampling. Sampling is performed only from the set of tokens whose cumulative probability exceeds top_p, controlling the diversity of generated content. The smaller the value, the more conservative the generation; the larger the value, the more diverse the generation. Default value: 1.0 |
rank | int or None | None | Specifies the GPU device number to use (effective in multi-GPU environments). For example: 0 indicates the first GPU, 1 indicates the second GPU. Default value: None |
The following code demonstrates how to use daft to run the operator for video content understanding and generate descriptions according to instructions.
from __future__ import annotations import logging import os import ray import daft from daft import col from daft.las.functions.multimodal.qwen_vl_video_understanding import QwenVLVideoUnderstanding from daft.las.functions.udf import las_udf if __name__ == "__main__": os.environ["DAFT_RUNNER"] = "ray" def configure_logging(): logging.basicConfig( level=logging.INFO, format="%(asctime)s - %(name)s - %(levelname)s - %(message)s", datefmt="%Y-%m-%d %H:%M:%S.%s".format(), ) logging.getLogger("tracing.span").setLevel(logging.WARNING) logging.getLogger("daft_io.stats").setLevel(logging.WARNING) logging.getLogger("DaftStatisticsManager").setLevel(logging.WARNING) logging.getLogger("DaftFlotillaScheduler").setLevel(logging.WARNING) logging.getLogger("DaftFlotillaDispatcher").setLevel(logging.WARNING) ray.init(dashboard_host="0.0.0.0", runtime_env={"worker_process_setup_hook": configure_logging}) daft.set_runner_ray() daft.set_execution_config(actor_udf_ready_timeout=600) daft.set_execution_config(min_cpu_per_task=0) tos_dir_url = os.getenv("TOS_DIR_URL", "las-cn-beijing-public-online.tos-cn-beijing.volces.com") samples = { "video_path": [ f"https://{tos_dir_url}/public/shared_video_dataset/eating_56.mp4" ], "prompt": [""] } video_src_type = "video_url" model_path = os.getenv("MODEL_PATH", "/opt/las/models") model_name = os.getenv("MODEL_NAME", "Qwen/Qwen2.5-VL-7B-Instruct") dtype = "bfloat16" use_flash_attention_2 = True default_prompt = None max_caption_length = 256 min_pixels = 320 * 160 max_pixels = 320 * 160 fps = 1 batch_size = 2 rank = 0 ds = daft.from_pydict(samples) ds = ds.with_column( "caption", las_udf( QwenVLVideoUnderstanding, construct_args={ "video_src_type": video_src_type, "model_path": model_path, "model_name": model_name, "dtype": dtype, "use_flash_attention_2": use_flash_attention_2, "prompt": default_prompt, "max_caption_length": max_caption_length, "min_pixels": min_pixels, "max_pixels": max_pixels, "batch_size": batch_size, "rank": rank, }, num_gpus=1, batch_size=2, concurrency=1, )(col("video_path"), col("prompt")), ) ds.show() # ╭────────────────────────────────┬─────────────────────────┬─────────────────────────────────────────────────────────────╮ # │ video_path ┆ prompt ┆ caption │ # │ --- ┆ --- ┆ --- │ # │ Utf8 ┆ Utf8 ┆ Utf8 │ # ╞════════════════════════════════╪═════════════════════════╪═════════════════════════════════════════════════════════════╡ # │ tos://las-cn-beijing-public-o… ┆ Please provide a detailed description of the video. … ┆ This is an animation clip. A cartoon character appears in the scene, and it looks like a… │ # ╰────────────────────────────────┴─────────────────────────┴─────────────────────────────────────────────────────────────╯