Large model multimodal understanding processor
Uses VolcanoVeArk's large model to analyze and understand images, videos, or text, and returns a text output.
http/https/tos/s3 protocols, Base64 encoding, and raw binary data. TOS/S3 addresses are automatically pre-signed.string (single) or list (multiple) formats as input.images (images): string or list type.videos (videos): string or list type.texts (text): string or list type, used as user prompts.string type.LAS_LLM_FINISH_REASON_CHECK=true is set, returns a struct type containing:
llm_result: The text result generated by the model.finish_reason: The reason for the model output termination. Possible values include stop (normal end), length (maximum length reached), and content_filter (content filtering).This operator (ArkLLMVisionUnderstanding) is used differently in Daft 0.6.5 (and earlier versions) compared to Daft 0.6.14 (and later versions).
In Daft 0.6.14 and later versions, you can specify the images, texts, and videos fields as input, corresponding to the model's image, text, and video inputs, and simultaneous input is supported. The following is an example:
df = df.with_column( "llm_result", las_udf( ArkLLMVisionUnderstanding, construct_args={ "model": "Doubao-1.5-vision-pro", "system_text": "", }, )(videos=col("video_urls"), texts=col("prompts")), )
In Daft 0.6.5 and earlier versions, only video or image can be input, and simultaneous input of video and image is not supported. The input type is specified via multimodal_type, which supports "video", "image", and "text". It also supports passing text information by specifying the prompt. The following is an example:
df = df.with_column( "llm_result", las_udf( ArkLLMVisionUnderstanding, construct_args={ "model": "Doubao-1.5-vision-pro", "multimodal_type": "video", "prompt": "", "inference_type": "online", }, )(col("videos")), )
Input field name | Note |
|---|---|
images | Provide the image data to be processed. Supports passing a single image (string) or multiple images (list). The data source is controlled by the |
videos | Provide the video data to be processed. Supports passing a single video (string) or multiple videos (list). The data source and processing method are the same as the |
texts | Provide user text prompts. Supports passing a single text (string) or multiple texts (list). |
By default, the returned field type is string, and the content is the model output result.
When the environment variable LAS_LLM_FINISH_REASON_CHECK=true is set, the returned field type is struct, containing the following fields:
llm_result: Model output resultfinish_reason: Reason for model output termination. Common values include stop (normal termination), length (reached maximum length), and content_filter (triggered content filtering policy).If a parameter does not have a default value, it is required.
Parameter name | Type | Default value | Description |
|---|---|---|---|
model | str | (Required) Model name. For example, | |
version | str | Model version. For example, | |
inference_type | str | batch | Inference type. Supports online inference and batch inference. Optional values: |
system_text | str | System prompt content. Used as input to the model with the system role to uniformly constrain model behavior. | |
system_image_url | str | System image URL. Used to guide model behavior. | |
system_video_url | str | System video URL. Used to guide model behavior. | |
image_format | str | jpeg | Image encoding format. Supports common formats such as |
image_url_detail | str | Image quality. Value range: | |
video_format | str | mp4 | Video encoding format. Supports |
video_fps | float | 1.0 | Video frame rate. Value range: |
source_type | str | url | Media data source format. Optional values: |
max_tokens | int | Maximum length of model response (in tokens). | |
max_completion_tokens | int | Maximum number of tokens generated by the model. | |
stop | list[str] | Stop word list. The model will stop generating when it encounters the specified string. | |
frequency_penalty | float | 0 | Frequency penalty coefficient. Value range: |
presence_penalty | float | 0 | Presence penalty coefficient. Value range: |
temperature | float | 1.0 | Sampling temperature. Value range: |
top_p | float | 0.7 | Nucleus sampling probability threshold. |
logit_bias | dict | Adjusts the probability of specified tokens appearing in the output. | |
tools | list | List of tools to be called. | |
llm_config | dict | Other custom parameters passed to the model. | |
request_timeout | int | 1200 | Request timeout (seconds). |
max_concurrency | int | 100 | Maximum number of concurrent requests per process. |
The following code demonstrates how to use the ArkLLMVisionUnderstanding operator to understand videos.
from __future__ import annotations import os import daft from daft import col from daft.las.functions.ark_llm.ark_llm_vision_understanding import ArkLLMVisionUnderstanding from daft.las.functions.udf import las_udf 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(min_cpu_per_task=0) if __name__ == "__main__": # The environment variable LAS_API_KEY must be configured: LAS_API_KEY is obtained by creating it on the LAS service page tos_dir_url = os.getenv("TOS_DIR_URL", "las-cn-beijing-public-online.tos-cn-beijing.volces.com") samples = { "videos": [ f"https://{tos_dir_url}/public/shared_video_dataset/eating_56.mp4", ], "prompts": [""], } df = daft.from_pydict(samples) df = df.with_column( "llm_result", las_udf( ArkLLMVisionUnderstanding, construct_args={ "model": "Doubao-1.5-vision-pro", "system_text": "", "inference_type": "online", }, )(videos=col("videos"), texts=col("prompts")), ) df.show() # Output (the results of large model inference may differ each time) # ╭────────────────────────────────┬────────────────┬─────────────────────────────────────────────────────────────╮ # │ videos ┆ prompts ┆ llm_result │ # │ --- ┆ --- ┆ --- │ # │ String ┆ String ┆ String │ # ╞════════════════════════════════╪════════════════╪═════════════════════════════════════════════════════════════╡ # │ https://las-public-data-qa.to… ┆ What is in the video? ┆ The video shows a cartoon-style scene, with the main element being a two-story red egg-shaped building. │ # ╰────────────────────────────────┴────────────────┴─────────────────────────────────────────────────────────────╯