Text vectorization processor
Input column name | Description |
|---|---|
text_contents | Pass in the text data to be processed. |
Returns the vectorized array processed by the model. Type: list[float]
If a parameter does not have a default value, it is required.
Parameter name | Type | Default value | Description |
|---|---|---|---|
model | str | doubao-embedding-large | Model name, for example: |
version | str or None | Model version. Enter the version information corresponding to the model. Example: text-250515 | |
api_key | str or None | ||
encoding_format | str or None | Encoding format for embedding. Supported formats: float, base64 | |
request_timeout | int | 1200 | Timeout. The timeout for a single request (seconds). |
max_concurrency | int | 100 | Concurrency. Maximum concurrency per process. |
The following code demonstrates how to use daft to access the ModelArk text vectorization model 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.doubao_embedding_text import DoubaoEmbeddingText 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 is obtained by creating it on the LAS service page samples = {"text": ["Hello World!", None]} df = daft.from_pydict(samples) # Compute the vectorized data of the text df = df.with_column( "embeddings", las_udf( DoubaoEmbeddingText, construct_args={ "model": "doubao-embedding", }, )(col("text")), ) df.show() # Output (the results of each large model inference may vary) # ╭────────┬────────────────────╮ # │ text ┆ embeddings │ # │ --- ┆ --- │ # │ Utf8 ┆ List[Float32] │ # ╞════════╪═══════════════════╡ # │ Hello World! ┆ [-3.90625, -1.4921875, -2.031… │ # ├╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┤ # │ None ┆ None │ # ╰────────┴────────────────────╯