Dedicated processor for large model text generation (Doubao/DeepSeek)
Input column name | Description |
|---|---|
raw_text | Contains the text data to be processed. Type: str |
(By default) When the environment variable LAS_LLM_FINISH_REASON_CHECK=false, the returned field type is str.
When the environment variable LAS_LLM_FINISH_REASON_CHECK=true, the returned field type is struct and includes the following 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. Example doubao-1.5-lite-32k | |
version | str or None | Model version. Enter the corresponding version information for the model. Example 250115 | |
inference_type | str | batch | Inference type. Supports online inference and batch inference. The default value is batch, which uses batch inference.
|
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 | The maximum number of tokens generated by the model, including reasoning_content and content, but excluding the input 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 | The model stops generating when it encounters a string specified in the stop field. The string itself will not be output. Up to 4 strings are supported. 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. The 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. The higher the value, the greater the randomness; the lower the value, the greater the determinism. It is generally recommended to adjust only temperature or top_p, not both. 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 fit 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 the 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 | List of tools to be called, which can be included in the model's returned information. To have the model return the tools to be called, configure this structure. | |
llm_config | dict or None | Custom LLM configuration. Except for 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. Timeout for a single request (in seconds). |
max_concurrency | int | 100 | Concurrency. Maximum number of concurrent requests per process. |
system_content | str or None | System prompt content. System prompt content, used as input to the model with the system role. | |
prompt | str or None | User prompt. User prompt used to guide the model's behavior. When this field is configured, it will be concatenated with the input text and provided to the model as the user role. At the same time, this field can also be set to {query}, in which case the input text will replace this field. |
The following code demonstrates how to use daft to access the VolcanoVeArk text generation model for batch inference. Note that the result 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_text_generate import ArkLLMTextGenerate 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 queries = { "query": [ "", "", ] } ds = daft.from_pydict(queries) ds = ds.with_column( "llm_result", las_udf( ArkLLMTextGenerate, construct_args={ "model": "doubao-lite-32k", "inference_type": "online", }, )(col("query")), ) ds.show() # Output (the result of each large model inference may differ) # ╭────────────────────┬───────────────────────────────────────╮ # │ query ┆ llm_result │ # │ --- ┆ --- │ # │ Utf8 ┆ Utf8 │ # ╞════════════════════╪═══════════════════════════════════════╡ # │ Where is the capital of China ┆ The capital of China is Beijing. │ # │ ┆ │ # │ ┆ Beijing is China's political center, cultural center, and international... │ # ├╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┤ # │ What cruciferous plants are there? ┆ There are many types of cruciferous plants, common ones include: │ # │ ┆ 1. **Vegetable category** │ # │ ┆ … │ # ╰────────────────────┴───────────────────────────────────────╯