You need to enable JavaScript to run this app.
Lake AI Service

Lake AI Service

Copy page
Download PDF
Video understanding
Video content understanding (Qwen VL series models, supports large-scale models)
Copy page
Download PDF
Video content understanding (Qwen VL series models, supports large-scale models)

Operator introduction

Description

The Qwen2.5-VL multimodal video understanding model supports temporal semantic parsing and natural language description generation, making it suitable for a wide range of video analysis scenarios.

Main features

  • Multimodal temporal modeling: Supports three video input formats (URL, Base64 encoding, binary stream), flexibly adapting to different data sources.
  • Spatiotemporal joint modeling: Automatically captures the spatiotemporal features and semantic associations of videos, enabling more accurate video content understanding.
  • Conversational prompt support: Customize the generation direction via the prompt parameter to meet diverse business requirements.
  • Efficient inference: Integrates the VLLM inference engine, supporting bfloat16, float16, and float32 precision, fully utilizing GPU performance.
  • It is recommended to use GPUs with 48GB or more GPU memory.

Applicable scenarios

  • Video content understanding and summarization
  • Intelligent monitoring and event analysis
  • Multimodal dialogue and interaction
  • Other AI applications requiring video semantic parsing

Caution

  • Only GPU environments are supported. It is recommended to set parameters appropriately based on GPU memory and business requirements.
  • For best results, standardize video size and frame rate before inference.

Daft usage

Operator parameters

Input

Input column name

Description

videos

An array containing video data. Each element is a string or binary.

user_prompts

The prompt corresponding to video understanding. The default is None. If not provided, the prompt parameter will be used by default.

Output

An array of processed results, with each element representing the visual understanding result for each video.

Parameters

If a parameter does not have a default value, it is required.

Parameter name

Type

Default value

Description

video_src_type

str

video_url

Input video format. Supported: - "video_url": TOS or HTTP address - "video_base64": base64 encoding - "video_binary": binary stream Optional values: ["video_url", "video_base64", "video_binary"] Default value: "video_url"

model_path

str

/opt/las/models

The absolute path where the local model files are stored. The default path is within the container. When using a custom model, this path needs to 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-AWQ", "Qwen/Qwen2.5-VL-7B-Instruct", "Qwen/Qwen2.5-VL-32B-Instruct-AWQ", "Qwen/Qwen2.5-VL-32B-Instruct", "Qwen/Qwen2.5-VL-72B-Instruct"] Default value: "Qwen/Qwen2.5-VL-7B-Instruct"

prompt

str

Please provide a detailed description of this video.

A prompt for users to understand the video content. The model will generate a description of the video based on the prompt. If left empty, it is recommended to provide a specific prompt for each data entry. 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 GPU memory consumption. It is recommended to adjust according to GPU memory. Default value: 4

dtype

str

bfloat16

Model inference precision selection. - "bfloat16": Balances precision and speed - "float16": Faster inference speed - "float32": Highest precision but maximum GPU memory consumption Optional values: ["bfloat16", "float16", "float32"] Default value: "bfloat16"

max_model_len

int

128000

Maximum supported model input length (number of tokens), which affects the length of video descriptions that can be processed. Cannot exceed 128000. Default value: 128000

max_num_seqs

int

128

Maximum number of sequences per batch, which affects concurrent inference capability. Default value: 128

tensor_parallel_size

int

1

The number of GPUs for tensor parallelism to improve inference speed. Default value: 1

enable_prefix_caching

bool

True

Whether to enable prefix caching to accelerate multi-turn inference. Default value: True

gpu_memory_utilization

float

0.9

Upper limit of single GPU memory utilization, range 0~1. Default value: 0.9

enforce_eager

bool

False

Whether to force inference in eager mode, available for debugging or special scenarios. Default value: False

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. It is recommended to set a specific frame rate value. Default value: None

temperature

float

1.0

Sampling temperature, controls the diversity of generated content. The higher the value, the more random the generation. Default value: 1.0

top_p

float

0.2

Nucleus sampling probability threshold, controls the diversity of generated content. The smaller the value, the more conservative the generation. Default value: 0.2

repetition_penalty

float

1.05

Repetition penalty coefficient to prevent generating repetitive content. The larger the value, the less repetitive the content. Default value: 1.05

max_tokens

int

8192

Maximum number of tokens generated per request, which affects the description length. Default value: 8192

stop_token_ids

list

[]

Generation stops when these token IDs are encountered. Used to customize generation stopping criteria. Default value: []

seed

int

42

Random seed to ensure reproducible inference results. Default value: 42

Examples

The following code demonstrates how to use daft to run the operator for video content understanding and generate descriptions as instructed.

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_vllm import QwenVLVideoUnderstandingVLLM
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"
    default_prompt = None
    max_caption_length = 256
    min_pixels = 320 * 160
    max_pixels = 320 * 160
    fps = 1
    batch_size = 2
    seed = 42
    max_model_len = 12800
    max_num_seqs = 128
    tensor_parallel_size = 1
    enable_prefix_caching = True
    gpu_memory_utilization = 0.95
    enforce_eager = True

    ds = daft.from_pydict(samples)
    ds = ds.with_column(
        "caption",
        las_udf(
            QwenVLVideoUnderstandingVLLM,
            construct_args={
                "video_src_type": video_src_type,
                "model_path": model_path,
                "model_name": model_name,
                "dtype": dtype,
                "prompt": default_prompt,
                "max_caption_length": max_caption_length,
                "min_pixels": min_pixels,
                "max_pixels": max_pixels,
                "fps": fps,
                "batch_size": batch_size,
                "seed": seed,
                "max_model_len": max_model_len,
                "max_num_seqs": max_num_seqs,
                "tensor_parallel_size": tensor_parallel_size,
                "enable_prefix_caching": enable_prefix_caching,
                "gpu_memory_utilization": gpu_memory_utilization,
                "enforce_eager": enforce_eager,
            },
            num_gpus=tensor_parallel_size,
            batch_size=batch_size,
            concurrency=1,
        )(col("video_path"), col("prompt")),
    )

    ds.show()

    # ╭────────────────────────────────┬─────────────────────────┬─────────────────────────────────────────────────────────────╮
    # │ video_path                     ┆ prompt                  ┆ caption                                                     │
    # │ ---                            ┆ ---                     ┆ ---                                                         │
    # │ Utf8                           ┆ Utf8                    ┆ Utf8                                                        │
    # ╞════════════════════════════════╪═════════════════════════╪═════════════════════════════════════════════════════════════╡
    # │ https://las-cn-beijing-public… ┆ Please provide a detailed description of the video. …    ┆ This is an animated clip featuring a cartoon character, which is designed as a…           │
    # ╰────────────────────────────────┴─────────────────────────┴─────────────────────────────────────────────────────────────╯
Last updated: 2026.05.12 19:06:35