Skip to content

LLM Generate Embeddings

The LLM Generate Embeddings task converts input text into an embedding, which is a vector of numbers that represents the text. The embedding can be stored in a vector database for later retrieval. This task utilizes a previously integrated language model (LLM) to generate the embeddings.

The LLM Generate Embeddings task takes the input text and processes it through the selected language model (LLM) to produce embeddings. The task evaluates the specified parameters, such as the LLM provider and model, and generates an embedding for the provided text. The output is a JSON array of numbers, which can be used in subsequent tasks or stored for future use.

Prerequisites

Task parameters

Configure these parameters for the LLM Generate Embeddings task.

Parameter Description Required/ Optional
inputParameters.llmProvider The integration name of the LLM provider to use with the task.

Note: If you haven’t configured your AI/LLM provider on your Orkes Conductor cluster, go to the Integrations tab and configure your required provider.
Required.
inputParameters.model The embedding model to use from the selected LLM provider. For example, text-embedding-3-large for OpenAI. Required.
inputParameters.text The text to be converted and stored as a vector. It can also be passed as variables. Required.
inputParameters.dimensions The number of dimensions in the generated embedding. The value must be supported by the chosen model and match your vector database index. If not set, the model's default size is used. Optional.
inputParameters.inputGuardrail Available since: v5.5.0 and later Scrubs or validates text before it's sent to the model.
ParameterDescription
inputGuardrail.typeThe guardrail type: JAVASCRIPT, HTTP, or WORKFLOW.
inputGuardrail.targetThe JS expression, URL, or workflow name to run, depending on type.
inputGuardrail.versionThe workflow version to use. Applies only when type is WORKFLOW. Defaults to the latest version.
inputGuardrail.headersExtra request headers to send, such as an API key. Applies only when type is HTTP.
inputGuardrail.failureModeFAIL (default) fails the task if the guardrail fails. WARN logs the failure and continues with the original text.
Refer to LLM Task Guardrails for a full guide.
Optional.

The following are generic configuration parameters that can be applied to the task and are not specific to the LLM Generate Embeddings task.

Caching parameters

You can cache the task outputs using the following parameters. Refer to Caching Task Outputs for a full guide.

Parameter Description Required/ Optional
cacheConfig.ttlInSecond The time to live in seconds, which is the duration for the output to be cached. Required if using cacheConfig.
cacheConfig.key The cache key is a unique identifier for the cached output and must be constructed exclusively from the task’s input parameters.
It can be a string concatenation that contains the task’s input keys, such as ${uri}-${method} or re_${uri}_${method}.
Required if using cacheConfig.
Other generic parameters

Here are other parameters for configuring the task behavior.

Parameter Description Required/ Optional
optional Whether the task is optional.

If set to true, any task failure is ignored, and the workflow continues with the task status updated to COMPLETED_WITH_ERRORS. However, the task must reach a terminal state. If the task remains incomplete, the workflow waits until it reaches a terminal state before proceeding.
Optional.

Task configuration

This is the task configuration for an LLM Generate Embeddings task.

{
  "name": "llm_generate_embeddings",
  "taskReferenceName": "llm_generate_embeddings_ref",
  "inputParameters": {
    "llmProvider": "openAI",
    "model": "text-embedding-3-large",
    "text": "${workflow.input.text}",
    "dimensions": 3072
  },
  "type": "LLM_GENERATE_EMBEDDINGS"
}

Task output

The LLM Generate Embeddings task will return the following parameters.

Parameter Description
result The embedding for the input text, as a JSON array of numbers.

Examples

Here are some examples for using the LLM Generate Embeddings task.

Using an LLM Generate Embeddings task in a workflow

See an example of building a question answering workflow using stored embeddings.