Seed-X multilingual text translation model – cross-language text translation key features
Input column name | Note |
|---|---|
contents | An array containing the texts to be translated. Each element must be a string. |
The processed array, with each element being the translation result of each text. For texts that fail to process, an empty string is returned.
If a parameter does not have a default value, it is required.
Parameter name | Type | Default value | Description |
|---|---|---|---|
model_path | str | /opt/las/models | The absolute path where the local model files are stored. The default is the preset path inside the container. When using a custom model, this path must be modified. Default value: "/opt/las/models" |
model_name | str | Seed-X-PPO-7B | Supported multilingual model names. Currently supports the Seed-X-Instruct-7B and Seed-X-PPO-7B series models. Optional values: ["Seed-X-Instruct-7B", "Seed-X-PPO-7B"] Default value: "Seed-X-PPO-7B" |
dtype | str | bfloat16 | Model inference precision option. Default value: "bfloat16" |
max_model_len | int | 32768 | Maximum sequence length supported by the model. Default value: 32768 |
max_num_seqs | int | 128 | The maximum number of sequences the model can process simultaneously. Default value: 128 |
tensor_parallel_size | int | 1 | The number of devices used for tensor parallel computation, for multi-GPU parallel inference. Default value: 1 |
enable_prefix_caching | bool | True | Whether to enable the prefix caching mechanism, which can improve inference efficiency for repeated prefixes. Default value: True |
gpu_memory_utilization | float | 0.9 | GPU memory usage ratio, range 0–1. Default value: 0.9 |
use_cot | bool | False | Whether to use Chain-of-Thought mode for translation. Default value: False |
source_language | str | Chinese | Name of the source language. For supported languages, refer to the model documentation. Default value: "Chinese" |
target_language | str | English | Name of the target language. For supported languages, refer to the model documentation. Default value: "English" |
max_tokens | int | 1024 | The maximum number of tokens the model can generate for translation results. Default value: 1024 |
batch_size | int | 4 | The number of text samples processed per inference. Default value: 4 |
seed | int | 42 | Random seed for result reproducibility. Default value: 42 |
The following code demonstrates how to use daft to run the operator and translate multilingual text based on the Doubao model.
from __future__ import annotations import logging import os import ray import daft from daft import col from daft.las.functions.text.multilingual_text_translate import MultilingualTextTranslate from daft.las.functions.udf import las_udf if __name__ == "__main__": os.environ["DAFT_RUNNER"] = "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(actor_udf_ready_timeout=600) daft.set_execution_config(min_cpu_per_task=0) samples = { "text": [ "", ] } model_path = os.getenv("MODEL_PATH", "/opt/las/models") model_name = "Seed-X-PPO-7B" max_model_len = 32768 max_num_seqs = 128 tensor_parallel_size = 1 dtype = "bfloat16" enable_prefix_caching = True gpu_memory_utilization = 0.9 use_cot = False source_language = "Chinese" target_language = "English" max_tokens = 1024 batch_size = 4 seed = 42 ds = daft.from_pydict(samples) ds = ds.with_column( "translate_text", las_udf( MultilingualTextTranslate, construct_args={ "model_path": model_path, "model_name": model_name, "dtype": dtype, "max_model_len": max_model_len, "max_num_seqs": max_num_seqs, "tensor_parallel_size": tensor_parallel_size, "enable_prefix_caching": enable_prefix_caching, "gpu_memory_utilization": gpu_memory_utilization, "use_cot": use_cot, "source_language": source_language, "target_language": target_language, "max_tokens": max_tokens, "batch_size": batch_size, "seed": seed, }, num_gpus=1, batch_size=1, concurrency=1, )(col("text")), ) ds.show() # ╭─────────────────────────────────────────────────────────────┬────────────────────────────────╮ # │ text ┆ translate_text │ # │ --- ┆ --- │ # │ Utf8 ┆ Utf8 │ # ╞═════════════════════════════════════════════════════════════╪════════════════════════════════╡ # │ This is a high-quality academic paper on the development of artificial intelligence technology, with detailed and informative content… ┆ This is a high-quality academ… │ # ╰─────────────────────────────────────────────────────────────┴────────────────────────────────╯