Provides deep reasoning capabilities for large models in multimodal scenarios
Uses models with deep reasoning capabilities to analyze and understand images, videos, or text, and returns structured text output. The operator automatically constructs a message structure that complies with multimodal model specifications. Users only need to provide image, video, or text data according to the specification to complete inference.
(Mixing string and list types in the same field is not allowed)
This operator (ArkLLMThinkingVision) is used differently in Daft 0.6.5 (and earlier versions) compared to version 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, which correspond 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( ArkLLMThinkingVision, construct_args={ "model": "doubao-seed-1.6", "system_text": "", "inference_type": "online", }, )(videos=col("videos"), texts=""), )
In Daft 0.6.5 and earlier versions, only video or image can be provided as input, and simultaneous input of both video and image is not supported. The input type is specified via multimodal_type, which supports "video", "image", and "text". It also supports providing text information by specifying the prompt. The following is an example:
df = df.with_column( "llm_result", las_udf( ArkLLMThinkingVision, construct_args={ "model": "doubao-seed-1.6", "multimodal_type": "video", "system_text": "", "prompt": "", "inference_type": "online", }, )(col("videos")), )
Input column name | Description |
|---|---|
images | Provide the image data to be processed. Supports input of a single image (string) or multiple images (list). The data source is controlled by the source_type parameter: In url mode, http/https/tos/s3 and other protocol addresses are supported, where tos/s3 will be automatically converted to a pre-signed URL; in base64 mode, the image's Base64 encoding is used; in binary mode, binary data will be automatically converted to Base64 encoding. |
videos | Provide the video data to be processed. Supports input of a single video (string) or multiple videos (list). The data source is controlled by the source_type parameter: In url mode, http/https/tos/s3 and other protocol addresses are supported, where tos/s3 will be automatically converted to a pre-signed URL; in base64 mode, the video's Base64 encoding is used; in binary mode, binary data will be automatically converted to Base64 encoding. |
texts | Provide user text prompts. Supports input of a single text (string) or multiple texts (list). |
By default, the returned field type is struct, which includes the following fields:
When the environment variable LAS_LLM_FINISH_REASON_CHECK=true, the returned struct will additionally include the following field:
When the environment variable LAS_LLM_BOTS_REFERENCES=true, the returned struct will additionally include the following field:
Both environment variables can be enabled at the same time, in which case the output struct will include all of the above fields.
If a parameter does not have a default value, it is required.
Parameter name | Type | Default value | Description |
|---|---|---|---|
model | str | Model name. Supported models include: Doubao model and DeepSeek model. For example: doubao-seed-1.6. | |
version | str or None | Model version. Enter the version information corresponding to the model. For example: 250115. | |
inference_type | str | batch | Inference type. Supports online inference and batch inference. The default value is batch, which uses batch inference. - online: Uses the online inference module provided by the ModelArk platform for inference. - batch: Uses the batch inference module provided by the ModelArk platform for inference. |
system_text | str or None | System prompt content. The system prompt content is used as input to the model with the system role to uniformly constrain model behavior. | |
system_image_url | str or None | System image URL. In scenarios with mixed text and images, input the system image URL to guide the model's behavior. | |
system_video_url | str or None | System video URL. In scenarios with mixed text and videos, input the system video URL to guide the model's behavior. | |
image_format | str | jpeg | Image encoding format. The default is jpeg. Supported formats: JPEG, PNG, WEBP, GIF, BMP, TIFF, and other common formats. |
image_url_detail | str or None | Image quality. Supports manual setting of image quality. The available values are high, low, and auto. - high: High-detail mode, suitable for scenarios requiring understanding of image details, such as multiple local information/feature extraction, complex/rich detail image understanding, and more comprehensive understanding. - low: Low-detail mode, suitable for simple image classification/recognition, overall content understanding/description, and similar scenarios, with faster understanding. - auto: Default mode. The mode selected varies slightly depending on the model. For details, refer to the official documentation. | |
video_format | str | mp4 | Video encoding format. Configure the video format; the default is mp4. Supported video formats: MP4, AVI, MOV. Each video file must not exceed 50MB. |
video_fps | float or None | Video frame rate. Value range: [0.2, 5]. Default value: 1. Extracts a specified number of images from the video per second. The higher the value, the more precisely the model understands changes in the video frames; the lower the value, the less sensitive the model is to changes in the video frames, but fewer tokens are used and processing is faster. | |
source_type | str | url | Data source type. Specifies the format of the media data source; the default is url. Optional values: - binary: raw binary data - base64: Base64-encoded data - url: network resource address (supports http/https/tos/s3), where tos/s3 will be automatically converted to a pre-signed URL |
max_tokens | int or None | Maximum length of model response (in tokens). The total input and output length is limited by the model context. | |
max_completion_tokens | int or None | Maximum number of tokens generated by the model, including reasoning_content and content, but excluding the input messages. When exceeded, the model stops outputting reasoning_content and answers, and returns the finish_reason field with the value "length". | |
stop | list or None | Stop word list. When the model encounters a string specified in the stop field, it will stop generating further output. The string itself will not be output. Supports up to 4 strings. For example: ["你好", "天气"]. | |
frequency_penalty | float | 0 | Frequency penalty coefficient. Frequency penalty coefficient. If the value is positive, new tokens are penalized based on their frequency in the text, reducing the likelihood of the model repeating tokens character by character. Value range: [-2.0, 2.0], default is 0. |
presence_penalty | float | 0 | Presence penalty coefficient. Presence penalty coefficient. If the value is positive, new tokens are penalized based on whether they have appeared in the text so far, increasing the likelihood that the model discusses new topics. Value range: [-2.0, 2.0]. Default value: 0. |
temperature | float | 1 | Sampling temperature. Sampling temperature controls the degree to which the probability distribution of candidate words is smoothed when generating text. - When the value is 0, the model considers only the token with the highest log probability. - Higher values (such as 0.8) make the output more random, while lower values (such as 0.2) make the output more focused and deterministic. It is generally recommended to adjust only one of temperature or top_p, rather than modifying both. The value range is [0, 2], with a default value of 1. |
top_p | float | 0.7 | Nucleus sampling probability threshold. Nucleus sampling probability threshold. The model considers token results whose probability mass falls within top_p. When the value is 0, the model only considers the token with the highest log probability. 0.1 means only the top 10% of tokens with the highest probability mass are considered. The higher the value, the greater the randomness of the generated output; the lower the value, the more deterministic the output. The default value is 0.7. |
logit_bias | dict or None | Adjusts the probability of specified tokens appearing in the model's output, making the generated content better align with specific preferences. The logit_bias field accepts a map value, where each key is a token ID from the vocabulary (obtained using the tokenization interface), and each value is the bias value for that token, with a range of [-100, 100]. -1 decreases the likelihood of selection, 1 increases the likelihood; -100 completely prohibits selection of that token, 100 results in only that token being selectable. The actual effect of this parameter may vary depending on the model. | |
tools | list or None | Tool invocation configuration. List of tools to be invoked, which can be included in the model's returned information. To have the model return tools to be invoked, this structure must be configured. | |
thinking_type | str or None | Thinking mode Controls whether the model enables deep thinking mode. If not configured, deep thinking mode is used by default and can be manually disabled. Optional values: - enabled: Thinking mode is enabled, and the model will always think before answering. - disabled: Thinking mode is disabled, and the model answers questions directly without thinking. - auto: Automatic thinking mode, where the model determines whether thinking is needed based on the question; simple questions are answered directly. | |
llm_config | dict or None | Custom LLM configuration. In addition to the parameters above, other parameters are passed through to the model. The parameters above will override the values in llm_config. | |
request_timeout | int | 1200 | Timeout duration. Timeout duration for a single request (in seconds). |
max_concurrency | int | 100 | Concurrency. Maximum concurrency per process. |
The following code demonstrates how to use daft to access the ModelArk multimodal deep reasoning model (Doubao series) for batch inference. Caution: The results of each large model inference may vary.
from __future__ import annotations import os import daft from daft import col from daft.las.functions.ark_llm.ark_llm_thinking_vision import ArkLLMThinkingVision 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 created 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", ] } df = daft.from_pydict(samples) df = df.with_column( "llm_result", las_udf( ArkLLMThinkingVision, construct_args={ "model": "doubao-seed-1.6-flash", "system_text": "", "inference_type": "online", }, )(videos=col("videos")), ) df = df.with_column("reasoning_content", col("llm_result")["reasoning_content"]) df = df.with_column("llm_result", col("llm_result")["llm_result"]) df.show() # Output (the results of each large model inference may vary) # ╭────────────────────────────────┬────────────────────────┬───────────────────────────────────────────────────────────╮ # │ videos ┆ llm_result ┆ reasoning_content │ # │ --- ┆ --- ┆ --- │ # │ String ┆ String ┆ String │ # ╞════════════════════════════════╪════════════════════════╪═══════════════════════════════════════════════════════════╡ # │ https://las-public-data-qa.to… ┆ ### Detailed description of the video content: ┆ │ # │ ┆ ┆ The user now needs me to analyze the content of this video and provide a detailed description. First, I... │ # │ ┆ ┆ │ # │ ┆ #### **Scenario and environment...** ┆ │ # ╰────────────────────────────────┴────────────────────────┴───────────────────────────────────────────────────────────╯