Provides deep reasoning capabilities of large models in multimodal scenarios
Uses models with deep reasoning capabilities to analyze and interpret images, videos, or text, and returns structured text output. The operator automatically constructs a message structure compliant with multimodal model specifications. Users only need to provide image, video, or text data as specified to complete inference.
(String and list types cannot be mixed within the same field)
This operator (ArkLLMThinkingVision) 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 when providing input, which correspond to the model's image, text, and video inputs. You can provide all of them at the same time. Here 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 video and image is not supported. The input type is specified using multimodal_type, which accepts "video", "image", and "text". It also supports providing text information by specifying the prompt. Here 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")), )
The model is invoked via the "dialog interface", where inference is initiated for each request, and the system waits for the model to output results. Using Daft, a batch of requests can be processed in parallel to improve inference efficiency.
Input column name | Description |
|---|---|
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 source_type parameter: URL mode supports http/https/tos/s3 and other protocol addresses, where tos/s3 will be automatically converted to a pre-signed URL; base64 mode uses the Base64 encoding of the image; binary mode will automatically convert binary data to Base64 encoding. |
videos | Provide the video data to be processed. Supports passing a single video (string) or multiple videos (list). The data source is controlled by the source_type parameter: URL mode supports http/https/tos/s3 and other protocol addresses, where tos/s3 will be automatically converted to a pre-signed URL; base64 mode uses the Base64 encoding of the video; binary mode will automatically convert binary data to Base64 encoding. |
texts | Provide user text prompts. Supports passing a single text (string) or multiple texts (list). |
By default, the returned field type is struct and includes the following fields:
When the environment variable LAS_LLM_FINISH_REASON_CHECK=true, the struct will additionally include the following field:
When the environment variable LAS_LLM_BOTS_REFERENCES=true, the struct will additionally include the following field:
Both environment variables can be enabled simultaneously, in which case the 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 are: 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, 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, enter 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 images, enter 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 provides a more comprehensive understanding. - low: Low-detail mode, suitable for simple image classification/recognition, overall content understanding/description, and similar scenarios, provides faster understanding. - auto: Default mode. Different models may select different modes. For details, please 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]. The default value is 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 the speed is faster. | |
source_type | str | url | Data source type Specifies the source format of media data. The default is url. Optional values: - binary: Original 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 model response length (in tokens). The total input and output length is limited by the model's context window. | |
max_completion_tokens | int or None | The maximum number of tokens generated by the model, including reasoning_content and content, but excluding the provided messages. When this limit is exceeded, the model stops outputting reasoning_content and answers, and returns the finish_reason field as 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 included in the 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 verbatim. Value range is [-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 is [-2.0, 2.0]. Default value is 0. |
temperature | float | 1 | Sampling temperature. Sampling temperature controls the degree to which the probability distribution for each candidate word is smoothed when generating text. - When set to 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 temperature or top_p, not both. Value range is [0, 2], default value is 1. |
top_p | float | 0.7 | Nucleus sampling probability threshold. Nucleus sampling probability threshold. The model considers token results within the top_p probability mass. When set to 0, the model considers only the token with the highest log probability. 0.1 means only the top 10% of tokens by probability mass are considered. Higher values increase randomness, lower values increase determinism. 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 match 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 of selection; -100 completely prohibits selection of that token, and 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. The 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 will answer questions directly without thinking. - auto: Automatic thinking mode. The model autonomously 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 will be passed through to the model. The parameters above will override the values in llm_config. | |
request_timeout | int | 1200 | Timeout. The timeout duration for a single request (in seconds). |
max_concurrency | int | 100 | Concurrency. The maximum number of concurrent requests per process. |
The following code demonstrates how to use Daft to access the Volcano ModelArk multimodal deep thinking model (Doubao series) for batch inference. Please note: 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 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", ] } df = daft.from_pydict(samples) df = df.with_column( "llm_result", las_udf( ArkLLMThinkingVision, construct_args={ "model": "doubao-1.5-thinking-vision-pro", "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 result of each large model inference may vary) # ╭────────────────────────────────┬────────────────────────────────────────────┬────────────────────────────────────────────╮ # │ videos ┆ llm_result ┆ reasoning_content │ # │ --- ┆ --- ┆ --- │ # │ Utf8 ┆ Utf8 ┆ Utf8 │ # ╞════════════════════════════════╪════════════════════════════════════════════╪════════════════════════════════════════════╡ # │ https://las-public-data-qa.to… ┆ The video presents an animated segment: initially, it shows a ┆ The user now needs to describe the content in the video. First, observe the visuals: │ # │ ┆ A **multi-layer cartoon wind… ┆ The beginning features a multi-layer egg… │ # ╰────────────────────────────────┴────────────────────────────────────────────┴────────────────────────────────────────────╯
This interface is used to assemble data into the request format required by the model as a JSONL file and upload it to Volcano Engine Object Storage (TOS). Batch inference tasks are executed using the Doubao model.
Input column name | Description |
|---|---|
model | The name of the large model provided by ModelArk to be used, such as doubao-seed-1.6, doubao-seed-1.8, and so on. |
version | The version number of the model to be used. For example, the version number of doubao-seed-1.8 is 251228 |
input_dir | The path to the original input data, used for result backfill by the callback script. After the task is completed, the data in this path will be left-joined with the inference results. Must be a tos:// or s3:// path. |
output_dir | Output directory for inference results. Must be an object storage path starting with tos:// or s3://. All intermediate files of inference results will be stored here. |
primary_column_name | Name of the primary key column in the DataFrame. The values in this column will be used as the primary key for inference records, enabling subsequent result tracing and association. The values in this column should remain unique within the DataFrame. |
image_column_name | Name of the image column in the DataFrame. The values in this column will be used as the image field in inference records for the model to process multimodal inputs. |
video_column_name | Name of the column in the DataFrame containing video data (URL or binary data). |
text_column_name | Name of the column in the DataFrame containing the text prompt. |
message_column_name | Name of the column in the DataFrame containing the complete messages list. If this parameter is provided, image/video/text_column_name will be ignored, and this column will be used directly to construct the request. |
Returns a list of JSONL file paths written to TOS. This JSONL file contains the input data for batch inference. After the JSONL file is generated, it will be submitted to the Doubao model for batch inference. At the same time, a corresponding inference task and its progress will be available in the task management section of the AI Data Lake Service.
If a parameter does not have a default value, it is required.
Parameter name | Type | Default value | Description |
|---|---|---|---|
output_dir | str | The total output directory for the inference task must be an object storage path starting with tos:// or s3://. All inference results and intermediate files will be stored here. | |
primary_column_name | str | Name of the primary key column in the DataFrame. The values in this column will be used as the custom_id for inference records, enabling subsequent result tracing and association. The values in this column should remain unique within the DataFrame. | |
model | str | Name of the large model provided by ModelArk, such as doubao-seed-1.6, doubao-seed-1.8, and so on. | |
version | str | Model version number. For example, the version number of doubao-seed-1.8 is 251228 | |
input_dir | str | None | None |
batch_inference_dataset_dir | str | None | None |
input_format | str | parquet | Format of the raw data in input_dir, used for callback script reading. Supports parquet, csv, and json. It is recommended to use the parquet format. Because complex column types in csv/json may cause parsing errors. |
llm_column_name | str | llm_result | Name of the column in the final output that stores the model inference content. |
finish_reason_column_name | str | None | finish_reason |
image_column_name | str | None | None |
video_column_name | str | None | None |
text_column_name | str | None | None |
message_column_name | str | None | None |
max_tokens | int | None | None |
max_completion_tokens | int | None | None |
stop | list[str] | None | None |
frequency_penalty | float | None | None |
presence_penalty | float | None | None |
temperature | float | None | None |
top_p | float | None | None |
logit_bias | dict | None | None |
tools | list[dict] | None | None |
llm_config | dict | None | None |
num_batches | int | None | None |
completion_window | str | Task completion window for ModelArk batch inference service, for example, "1d" means 1 day. | |
repartition | int | None | None |
kwargs | dict | Any other parameters to be transparently passed to the internal ArkLLMVisionUnderstanding UDF, such as system_text and so on. |
The following code demonstrates how to use the submit_ark_batch_inference_job interface to perform batch inference on a Daft DataFrame. Please note: The results of each large model inference may vary.
from __future__ import annotations import logging import daft from daft.io import IOConfig from daft.las.io.tos import TOSConfig logging.basicConfig(level=logging.INFO) # --- 1. Preparation: When executing the task, set the following environment variables on the LAS platform as needed --- # LAS_API_KEY # ACCESS_KEY # SECRET_KEY # TOS_ENDPOINT # --- 2. Define input and output paths --- # Caution: The path must be a TOS or S3 path # Configure the object storage bucket name as needed bucket_name = "bucket_name" # Configure the path for the raw data. This path stores the raw data that needs to be inferred using the Doubao model (only parquet/csv/json storage formats are supported; parquet format is recommended). If the file does not exist, you can also create it using the method described below: input_data_path = f"s3://{bucket_name}/doubao_test_job_path/original_data.parquet" # Configure the output directory for inference results. This directory stores the files with merged inference results. That is, append the inference results to the input_data_path file and save them to a new file. output_dir = f"tos://{bucket_name}/doubao_test_job_path/to/inference_output/" # Configure the output directory for the batch inference dataset. If batch_inference_dataset_dir is not specified, the default is {output_dir}/batch_inference_dataset. This path stores the jsonl files containing inference results returned by the Doubao model. batch_inference_dataset_dir = f"tos://{bucket_name}/doubao_test_job_path/to/batch_inference_dataset" io_config = IOConfig(s3=TOSConfig.from_env().to_s3_config()) # --- 3. Construct Daft DataFrame --- # ---- If the input_data_path does not exist, a simple creation method is provided below. Otherwise, skip the following steps and read the file directly. # Suppose we have a DataFrame containing IDs and text prompts data = { "request_id": [f"req_{i}" for i in range(10)], "prompt": [f"写一个关于数字 {i} 的短故事" for i in range(10)], } df = daft.from_pydict(data) df.write_parquet(input_data_path.replace("tos://", "s3://"), io_config=io_config) # Read the input_data_path file df = daft.read_parquet(input_data_path, io_config=io_config) # --- 4. Call the interface to submit the batch inference task --- generated_files = df.submit_ark_batch_inference_job( output_dir=output_dir, primary_column_name="request_id", model="doubao-seed-1-8", version="251228", # Define the input data columns text_column_name="prompt", # Define the information required for the callback input_dir=input_data_path, input_format="parquet", # Define the LLM inference parameters max_tokens=256, temperature=0.7, # (Optional) Performance parameters: split 10 data entries into 2 files for inference # num_batches=2, # (Optional) Repartition after callback: merge the final results into a single file repartition=1, completion_window="2d", ) print(f"成功生成并提交了 {len(generated_files)} 个输入文件:") for file_path in generated_files: print(f"- {file_path}")