Qwen2.5-Omni multimodal audio understanding model – key features of audio content parsing and natural language description generation
Input column name | Note |
|---|---|
contents | An array containing audio data, with element type as string (file path or URL). |
user_prompts | The prompt for audio understanding, defaults to None. If not provided, the prompt specified in the parameters is used by default. |
The processed array, where each element is the text result of the audio understanding. For audio files that fail to process, an empty string is returned.
If a parameter does not have a default value, it is required
Parameter name | Type | Default value | Description |
|---|---|---|---|
model_path | str | /opt/las/models | The absolute path for storing local model files, which 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-Omni-7B | Supported multimodal model versions. Currently supports the Qwen2.5-Omni series models. Optional values: ["Qwen/Qwen2.5-Omni-7B"] Default value: "Qwen/Qwen2.5-Omni-7B" |
prompt | str | Please provide a detailed description of this audio. | The prompt that helps the user understand the audio content; the model generates an audio description based on the prompt. Default value: "Please provide a detailed description of this audio." |
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 the GPU memory capacity. Default value: 4 |
dtype | str | bfloat16 | Model inference precision options: - bfloat16: balances precision and speed - float16: faster inference speed - float32: highest precision but consumes 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 when CUDA-compatible and dtype is 16-bit floating point). Default value: True |
max_caption_length | int | 256 | The maximum number of tokens for model-generated descriptions. Longer generations may include more details but increase computation time. Default value: 256 |
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 audio content understanding and generate descriptions as specified.
from __future__ import annotations import os import daft from daft import col from daft.las.functions.multimodal.qwen_omni_audio_understanding import QwenOmniAudioUnderstanding from daft.las.functions.udf import las_udf if __name__ == "__main__": if os.getenv("DAFT_RUNNER", "native") == "ray": import logging import 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 = { "audio_path": [ f"https://{tos_dir_url}/public/shared_audio_dataset/.mp3" ], "prompt": [""], } model_path = os.getenv("MODEL_PATH", "/opt/las/models") model_name = "Qwen/Qwen2.5-Omni-7B" dtype = "bfloat16" use_flash_attention_2 = True default_prompt = None max_caption_length = 256 batch_size = 1 rank = 0 num_gpus = int(os.getenv("NUM_GPUS", 1)) num_gpus = 1 ds = daft.from_pydict(samples) ds = ds.with_column( "caption", las_udf( QwenOmniAudioUnderstanding, construct_args={ "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, "batch_size": batch_size, "rank": rank, }, num_gpus=num_gpus, batch_size=1, concurrency=1, )(col("audio_path"), col("prompt")), ) print(ds.to_pandas()["caption"][0]) ds.show() # ╭────────────────────────────────┬───────────────────────────────────────────────┬─────────────────────────────────────────────────────────────╮ # │ audio_path ┆ prompt ┆ caption │ # │ --- ┆ --- ┆ --- │ # │ Utf8 ┆ Utf8 ┆ Utf8 │ # ╞════════════════════════════════╪═══════════════════════════════════════════════╪═════════════════════════════════════════════════════════════╡ # │ tos://las-cn-beijing-public-o… ┆ Please convert this audio directly into text without any explanation. … ┆ I have saved the person and retrieved what I needed. I, Old Sun, do not seek any fame or fortune, only wish to return to the Mountain of Flowers and Fruit… │ # ╰────────────────────────────────┴───────────────────────────────────────────────┴─────────────────────────────────────────────────────────────╯