Deep reasoning capability based on the DeepSeek-R1 model
Use the DeepSeek-R1 model with deep reasoning capability to analyze and understand text, and return structured output. Before answering a question, the model performs question analysis and decomposition, and generates a response based on this process.
reasoning_content) to enhance the comprehensiveness and depth of the answer.texts column.thinking_type parameter (enabled / disabled / auto), allowing flexible trade-offs between answer quality and performance.texts (text): string or list type, used as the user's question or prompt.struct type containing:
llm_result: The final answer generated by the model.reasoning_content: The model's chain of thought or reasoning process.LAS_LLM_FINISH_REASON_CHECK=true is set, the struct additionally includes a finish_reason field to determine the reason for output termination (such as stop, length).LAS_LLM_BOTS_REFERENCES=true is set, the struct additionally includes a references field (JSON string) to carry external knowledge information referenced by the model.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, 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( ArkLLMThinkingVision, construct_args={ "model": "deepseek-r1", "system_text": "", "inference_type": "online", }, )(texts=col("query")), )
In Daft 0.6.5 and earlier versions, only video or image input is supported, not both at the same time. The input type is specified via multimodal_type, which supports "video" and "image", "text". It also supports providing text information by specifying prompt. The following is an example:
df = df.with_column( "llm_result", las_udf( ArkLLMThinkingVision, construct_args={ "model": "deepseek-r1", "multimodal_type": "text", "inference_type": "online", }, )(col("query")), )
Input column name | Note |
|---|---|
texts | (Required) Pass in the user's text prompt. Supports passing a single text (string) or multiple texts (list). |
By default, the returned field type is struct, which contains the following fields:
llm_result: The final answer content output by the model.reasoning_content: The content of the model's chain of thought output (reasoning process).When the relevant environment variables are set, the returned struct will additionally include the following fields:
finish_reason (when LAS_LLM_FINISH_REASON_CHECK=true): The reason for the model output ending. Common values include stop (normal termination), length (reached maximum length), and content_filter (triggered content filtering policy).references (when LAS_LLM_BOTS_REFERENCES=true): Reference information in JSON string format, used to carry external knowledge referenced by the model.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: deepseek-r1. | |
version | str or None | Model version. Enter the version information corresponding to the model. For example: 250528. | |
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 ModelArk platform for inference. - batch: Uses the batch inference module provided by ModelArk platform for inference. |
system_text | str or None | 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 involving both 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 involving both text and video, input the system video URL to guide the model's behavior. | |
image_format | str | jpeg | Image encoding format. Default is jpeg. Supported formats: JPEG, PNG, WEBP, GIF, BMP, TIFF, and many other common formats. |
image_url_detail | str or None | Image quality. Supports manually setting the image quality. Value range: high, low, 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, for a more comprehensive understanding. - low: Low detail mode, suitable for simple image classification/recognition, overall content understanding/description, and similar scenarios, to enable 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 be no more than 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 the speed 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 exactly. 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 for each candidate token 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. The model considers tokens whose probability mass falls within top_p. When the value is 0, the model only considers the token with the highest log probability. A value of 0.1 means only the top 10% of tokens by 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 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, and 100 causes only that token to be 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 response. To have the model return the tools to be invoked, you must configure this structure. | |
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: Enables thinking mode; the model always thinks before answering. - disabled: Disables thinking mode; the model answers questions directly without thinking. - auto: Automatic thinking mode; the model determines whether to think 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 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 the ArkLLMThinkingVision.Deepseek-R1 operator for in-depth text reasoning.
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__": # Environment variable LAS_API_KEY must be configured: LAS_API_KEY can be obtained by creating it on the LAS service page queries = {"query": [""]} df = daft.from_pydict(queries) df = df.with_column( "llm_result", las_udf( ArkLLMThinkingVision, construct_args={ "model": "deepseek-r1", "system_text": "", "inference_type": "online", }, )(texts=col("query")), ) 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) # +------------------------------------+--------------------------------------------------+--------------------------------------------------------------------+ # | query | llm_result | reasoning_content | # | Utf8 | Utf8 | Utf8 | # +====================================+==================================================+====================================================================+ # | Help me plan a 10-day trip to Xinjiang in May | The following is a 10-day itinerary for Xinjiang in May, focusing mainly on Northern Xinjiang... | | Okay, the user asked me to help plan a 10-day trip to Xinjiang in May. First... | # +------------------------------------+--------------------------------------------------+--------------------------------------------------------------------+