Embeddings

This Langflow feature is currently in public preview. Development is ongoing, and the features and functionality are subject to change. Langflow, and the use of such, is subject to the DataStax Preview Terms.

Embeddings models convert text into numerical vectors. These embeddings capture the semantic meaning of the input text, and allow LLMs to understand context.

Refer to your specific component’s documentation for more information on parameters.

Use an embeddings model component in a flow

In this example of a document ingestion pipeline, the OpenAI embeddings model is connected to a vector database. The component converts the text chunks into vectors and stores them in the vector database. The vectorized data can be used to inform AI workloads like chatbots, similarity searches, and agents.

This embeddings component uses an OpenAI API key for authentication. Refer to your specific embeddings component’s documentation for more information on authentication.

url component

AI/ML

This component generates embeddings using the AI/ML API.

Parameters

Inputs
Name Type Description

model_name

String

The name of the AI/ML embedding model to use

aiml_api_key

SecretString

API key for authenticating with the AI/ML service

Outputs
Name Type Description

embeddings

Embeddings

An instance of AIMLEmbeddingsImpl for generating embeddings

Component code

aiml.py
404: Not Found

Amazon Bedrock Embeddings

Use this component to load embedding models and generate embeddings with Amazon Bedrock.

This component requires an AWS account and access to Amazon Bedrock.

Parameters

Inputs
Name Display Name Info

credentials_profile_name

AWS Credentials Profile

Name of the AWS credentials profile in ~/.aws/credentials or ~/.aws/config

model_id

Model ID

ID of the model to call, e.g., amazon.titan-embed-text-v1

endpoint_url

Endpoint URL

URL to set a specific service endpoint other than the default AWS endpoint

region_name

AWS Region

AWS region to use, e.g., us-west-2

Outputs
Name Type Description

embeddings

Embeddings

An instance for generating embeddings using Amazon Bedrock.

Component code

amazon_bedrock.py
404: Not Found

Astra DB vectorize

This component is deprecated as of Langflow version 1.1.2. Instead, use the Astra DB vector store component.

Connect this component to the Embeddings port of the Astra DB vector store component to generate embeddings.

This component requires that your Astra DB database has a collection that uses a vectorize embedding provider integration. For more information and instructions, see Auto-generate embeddings with vectorize.

Parameters

Inputs
Name Display Name Info

provider

Embedding Provider

The embedding provider to use

model_name

Model Name

The embedding model to use

authentication

Authentication

The name of the API key in Astra KMS that stores your vectorize embedding provider credentials. (Not required if using an Astra-hosted embedding provider).

provider_api_key

Provider API Key

As an alternative to authentication, directly provide your embedding provider credentials.

model_parameters

Model Parameters

Additional model parameters

Component code

astra_vectorize.py
404: Not Found

Azure OpenAI Embeddings

This component generates embeddings using Azure OpenAI models.

Use this component to create embeddings with Azure’s OpenAI service.

Make sure you have the necessary Azure credentials and have set up the OpenAI resource.

Parameters

Inputs
Name Display Name Info

Azure Endpoint

Azure Endpoint

Your Azure endpoint, including the resource

Deployment Name

Deployment Name

The name of the deployment

API Version

API Version

The API version to use

API Key

API Key

The API key to access the Azure OpenAI service

Outputs
Name Type Description

embeddings

Embeddings

An instance for generating embeddings using Azure OpenAI.

Component code

azure_openai.py
404: Not Found

Cloudflare Workers AI Embeddings

This component generates embeddings using Cloudflare Workers AI models.

Parameters

Inputs
Name Display Name Info

account_id

Cloudflare account ID

Find your account ID

api_token

Cloudflare API token

Create an API token

model_name

Model Name

List of supported models

strip_new_lines

Strip New Lines

Whether to strip new lines from the input text.

batch_size

Batch Size

Number of texts to embed in each batch.

api_base_url

Cloudflare API base URL

Base URL for the Cloudflare API.

headers

Headers

Additional request headers.

Outputs
Name Display Name Info

embeddings

Embeddings

An instance for generating embeddings using Cloudflare Workers.

Component code

cloudflare.py
404: Not Found

Cohere Embeddings

This component loads embedding models from Cohere.

Use this component to generate embeddings using Cohere’s AI models.

Ensure you have a valid Cohere API key.

Parameters

Inputs
Name Display Name Info

cohere_api_key

Cohere API Key

API key required to authenticate with the Cohere service.

model

Model Name

Language model used for embedding text documents and performing queries.

truncate

Truncate

Whether to truncate the input text to fit within the model’s constraints.

Outputs
Name Display Name Info

embeddings

Embeddings

An instance for generating embeddings using Cohere.

Component code

cohere.py
404: Not Found

Embedding similarity

This component computes selected forms of similarity between two embedding vectors.

Parameters

Inputs
Name Display Name Info

embedding_vectors

Embedding Vectors

A list containing exactly two data objects with embedding vectors to compare.

similarity_metric

Similarity Metric

Select the similarity metric to use. Options: "Cosine Similarity", "Euclidean Distance", "Manhattan Distance".

Outputs
Name Display Name Info

similarity_data

Similarity Data

Data object containing the computed similarity score and additional information.

Component code

similarity.py
from typing import Any

import numpy as np

from langflow.custom.custom_component.component import Component
from langflow.io import DataInput, DropdownInput, Output
from langflow.schema.data import Data


class EmbeddingSimilarityComponent(Component):
    display_name: str = "Embedding Similarity"
    description: str = "Compute selected form of similarity between two embedding vectors."
    icon = "equal"
    legacy: bool = True

    inputs = [
        DataInput(
            name="embedding_vectors",
            display_name="Embedding Vectors",
            info="A list containing exactly two data objects with embedding vectors to compare.",
            is_list=True,
            required=True,
        ),
        DropdownInput(
            name="similarity_metric",
            display_name="Similarity Metric",
            info="Select the similarity metric to use.",
            options=["Cosine Similarity", "Euclidean Distance", "Manhattan Distance"],
            value="Cosine Similarity",
        ),
    ]

    outputs = [
        Output(display_name="Similarity Data", name="similarity_data", method="compute_similarity"),
    ]

    def compute_similarity(self) -> Data:
        embedding_vectors: list[Data] = self.embedding_vectors

        # Assert that the list contains exactly two Data objects
        if len(embedding_vectors) != 2:  # noqa: PLR2004
            msg = "Exactly two embedding vectors are required."
            raise ValueError(msg)

        embedding_1 = np.array(embedding_vectors[0].data["embeddings"])
        embedding_2 = np.array(embedding_vectors[1].data["embeddings"])

        if embedding_1.shape != embedding_2.shape:
            similarity_score: dict[str, Any] = {"error": "Embeddings must have the same dimensions."}
        else:
            similarity_metric = self.similarity_metric

            if similarity_metric == "Cosine Similarity":
                score = np.dot(embedding_1, embedding_2) / (np.linalg.norm(embedding_1) * np.linalg.norm(embedding_2))
                similarity_score = {"cosine_similarity": score}

            elif similarity_metric == "Euclidean Distance":
                score = np.linalg.norm(embedding_1 - embedding_2)
                similarity_score = {"euclidean_distance": score}

            elif similarity_metric == "Manhattan Distance":
                score = np.sum(np.abs(embedding_1 - embedding_2))
                similarity_score = {"manhattan_distance": score}

        # Create a Data object to encapsulate the similarity score and additional information
        similarity_data = Data(
            data={
                "embedding_1": embedding_vectors[0].data["embeddings"],
                "embedding_2": embedding_vectors[1].data["embeddings"],
                "similarity_score": similarity_score,
            },
            text_key="similarity_score",
        )

        self.status = similarity_data
        return similarity_data

Google generative AI embeddings

This component connects to Google’s generative AI embedding service using the GoogleGenerativeAIEmbeddings class from the langchain-google-genai package.

Parameters

Inputs
Name Display Name Info

api_key

API Key

Secret API key for accessing Google’s generative AI service (required)

model_name

Model Name

Name of the embedding model to use (default: "models/text-embedding-004")

Outputs
Name Display Name Info

embeddings

Embeddings

Built GoogleGenerativeAIEmbeddings object.

Component code

google_generative_ai.py
404: Not Found

Hugging Face Embeddings

This component is deprecated as of Langflow version 1.0.18. Instead, use the Hugging Face API Embeddings component.

This component loads embedding models from HuggingFace.

Use this component to generate embeddings using locally downloaded Hugging Face models. Ensure you have sufficient computational resources to run the models.

Parameters

Inputs
Name Display Name Info

Cache Folder

Cache Folder

Folder path to cache HuggingFace models

Encode Kwargs

Encoding Arguments

Additional arguments for the encoding process

Model Kwargs

Model Arguments

Additional arguments for the model

Model Name

Model Name

Name of the HuggingFace model to use

Multi Process

Multi-Process

Whether to use multiple processes

Hugging Face embeddings inference

This component generates embeddings using Hugging Face inference API models and requires a Hugging Face API token to authenticate. Local inference models do not require an API key.

Use this component to create embeddings with Hugging Face’s hosted models, or to connect to your own locally hosted models. This component generates embeddings using Inference API models.

Use this component to create embeddings with Hugging Face’s hosted models. Ensure you have a valid Hugging Face API key.

Parameters

Inputs
Name Display name Description

API Key

API Key

The API key for accessing the Hugging Face Inference API.

API URL

API URL

The URL of the Hugging Face Inference API.

Model Name

Model Name

The name of the model to use for embeddings.

Cache Folder

Cache Folder

The folder path to cache Hugging Face models.

Encode Kwargs

Encoding Arguments

Additional arguments for the encoding process.

Model Kwargs

Model Arguments

Additional arguments for the model.

Multi Process

Multi-Process

Whether to use multiple processes.

Outputs
Name Type Description

embeddings

Embeddings

An instance for generating embeddings using HuggingFace.

Component code

huggingface_inference_api.py
404: Not Found

Connect the Hugging Face component to a local embeddings model

To run an embeddings inference model locally, see the Hugging Face documentation.

To connect the local Hugging Face model to the Hugging Face embeddings inference component and use it in a flow, follow these steps:

  1. Create a Vector store RAG flow. There are two embeddings models in this flow that you can replace with Hugging Face embeddings inference components.

  2. Replace both OpenAI embeddings model components with Hugging Face model components.

  3. Connect both Hugging Face components to the Embeddings ports of the Astra DB vector store components.

  4. In the Hugging Face components, set the Inference Endpoint field to the URL of your local inference model. The API Key field is not required for local inference.

  5. Run the flow. The local inference models generate embeddings for the input text.

IBM watsonx.ai Embeddings

This component generates embeddings using IBM watsonx.aimodels.

Parameters

Inputs
Name Display Name Info

url

watsonx API Endpoint

The base URL of the watsonx API.

project_id

watsonx project id

The project ID for watsonx.ai.

api_key

API Key

The API Key to use for the model.

model_name

Model Name

The name of the watsonx embeddings model to use. Options are dynamically fetched from the API.

truncate_input_tokens

Truncate Input Tokens

Maximum number of input tokens. The default is 200 tokens.

input_text

Include the original text in the output

Whether to include the original text in the output. The default is true.

Outputs
Name Display Name Info

embeddings

Embeddings

The configured watsonx.ai embeddings model. Type: Embeddings

Component code

watsonx.py
404: Not Found

LM Studio Embeddings

This component generates embeddings using LM Studio models.

Parameters

Inputs
Name Display Name Info

model

Model

The LM Studio model to use for generating embeddings

base_url

LM Studio Base URL

The base URL for the LM Studio API

api_key

LM Studio API Key

API key for authentication with LM Studio

temperature

Model Temperature

Temperature setting for the model

Outputs
Name Display Name Info

embeddings

Embeddings

The generated embeddings.

Component code

lmstudioembeddings.py
404: Not Found

MistralAI Embeddings

This component generates embeddings using MistralAI models.

Parameters

Inputs
Name Type Description

model

String

The MistralAI model to use (default: "mistral-embed")

mistral_api_key

SecretString

API key for authenticating with MistralAI

max_concurrent_requests

Integer

Maximum number of concurrent API requests (default: 64)

max_retries

Integer

Maximum number of retry attempts for failed requests (default: 5)

timeout

Integer

Request timeout in seconds (default: 120)

endpoint

String

Custom API endpoint URL (default: "https://api.mistral.ai/v1/")

Outputs
Name Type Description

embeddings

Embeddings

MistralAIEmbeddings instance for generating embeddings.

Component code

mistral.py
404: Not Found

NVIDIA

This component generates embeddings using NVIDIA models.

Parameters

Inputs
Name Type Description

model

String

The NVIDIA model to use for embeddings (e.g., nvidia/nv-embed-v1)

base_url

String

Base URL for the NVIDIA API (default: https://integrate.api.nvidia.com/v1)

nvidia_api_key

SecretString

API key for authenticating with NVIDIA’s service

temperature

Float

Model temperature for embedding generation (default: 0.1)

Outputs
Name Type Description

embeddings

Embeddings

NVIDIAEmbeddings instance for generating embeddings

Component code

nvidia.py
404: Not Found

Ollama Embeddings

This component generates embeddings using Ollama models.

Use this component to create embeddings with locally run Ollama models.

Parameters

Inputs
Name Display Name Info

Ollama Model

Model Name

Name of the Ollama model to use

Ollama Base URL

Base URL

Base URL of the Ollama API

Model Temperature

Temperature

Temperature parameter for the model

Outputs
Name Type Description

embeddings

Embeddings

An instance for generating embeddings using Ollama.

Component code

ollama.py
404: Not Found

OpenAI Embeddings

This component loads embedding models from OpenAI.

Use this component to generate embeddings using OpenAI’s models.

Ensure you have a valid OpenAI API key and sufficient quota.

Parameters

Inputs
Name Display Name Info

OpenAI API Key

API Key

The API key to use for accessing the OpenAI API

Default Headers

Default Headers

Default headers for the HTTP requests

Default Query

Default Query

Default query parameters for the HTTP requests

Allowed Special

Allowed Special Tokens

Special tokens allowed for processing

Disallowed Special

Disallowed Special Tokens

Special tokens disallowed for processing

Chunk Size

Chunk Size

Chunk size for processing

Client

HTTP Client

HTTP client for making requests

Deployment

Deployment

Deployment name for the model

Embedding Context Length

Context Length

Length of embedding context

Max Retries

Max Retries

Maximum number of retries for failed requests

Model

Model Name

Name of the model to use

Model Kwargs

Model Arguments

Additional keyword arguments for the model

OpenAI API Base

API Base URL

Base URL of the OpenAI API

OpenAI API Type

API Type

Type of the OpenAI API

OpenAI API Version

API Version

Version of the OpenAI API

OpenAI Organization

Organization

Organization associated with the API key

OpenAI Proxy

Proxy

Proxy server for the requests

Request Timeout

Request Timeout

Timeout for the HTTP requests

Show Progress Bar

Show Progress

Whether to show a progress bar for processing

Skip Empty

Skip Empty

Whether to skip empty inputs

TikToken Enable

Enable TikToken

Whether to enable TikToken

TikToken Model Name

TikToken Model

Name of the TikToken model

Outputs
Name Type Description

embeddings

Embeddings

An instance for generating embeddings using OpenAI.

Component code

openai.py
404: Not Found

Text embedder

This component generates embeddings for a given message using a specified embedding model.

Parameters

Inputs
Name Display Name Info

embedding_model

Embedding Model

The embedding model to use for generating embeddings.

message

Message

The message for which to generate embeddings.

Outputs
Name Display Name Info

embeddings

Embedding Data

Data object containing the original text and its embedding vector.

Component code

text_embedder.py
import logging
from typing import TYPE_CHECKING

from langflow.custom.custom_component.component import Component
from langflow.io import HandleInput, MessageInput, Output
from langflow.schema.data import Data

if TYPE_CHECKING:
    from langflow.field_typing import Embeddings
    from langflow.schema.message import Message


class TextEmbedderComponent(Component):
    display_name: str = "Text Embedder"
    description: str = "Generate embeddings for a given message using the specified embedding model."
    icon = "binary"
    legacy: bool = True
    inputs = [
        HandleInput(
            name="embedding_model",
            display_name="Embedding Model",
            info="The embedding model to use for generating embeddings.",
            input_types=["Embeddings"],
            required=True,
        ),
        MessageInput(
            name="message",
            display_name="Message",
            info="The message to generate embeddings for.",
            required=True,
        ),
    ]
    outputs = [
        Output(display_name="Embedding Data", name="embeddings", method="generate_embeddings"),
    ]

    def generate_embeddings(self) -> Data:
        try:
            embedding_model: Embeddings = self.embedding_model
            message: Message = self.message

            # Combine validation checks to reduce nesting
            if not embedding_model or not hasattr(embedding_model, "embed_documents"):
                msg = "Invalid or incompatible embedding model"
                raise ValueError(msg)

            text_content = message.text if message and message.text else ""
            if not text_content:
                msg = "No text content found in message"
                raise ValueError(msg)

            embeddings = embedding_model.embed_documents([text_content])
            if not embeddings or not isinstance(embeddings, list):
                msg = "Invalid embeddings generated"
                raise ValueError(msg)

            embedding_vector = embeddings[0]
            self.status = {"text": text_content, "embeddings": embedding_vector}
            return Data(data={"text": text_content, "embeddings": embedding_vector})
        except Exception as e:
            logging.exception("Error generating embeddings")
            error_data = Data(data={"text": "", "embeddings": [], "error": str(e)})
            self.status = {"error": str(e)}
            return error_data

VertexAI Embeddings

This component wraps around Google Vertex AI Embeddings API.

Use this component to generate embeddings using Google’s Vertex AI service.

Ensure you have the necessary Google Cloud credentials and permissions.

Parameters

Inputs
Name Display Name Info

credentials

Credentials

The default custom credentials to use

location

Location

The default location to use when making API calls

max_output_tokens

Max Output Tokens

Token limit for text output from one prompt

model_name

Model Name

The name of the Vertex AI large language model

project

Project

The default GCP project to use when making Vertex API calls

request_parallelism

Request Parallelism

The amount of parallelism allowed for requests

temperature

Temperature

Tunes the degree of randomness in text generations

top_k

Top K

How the model selects tokens for output

top_p

Top P

Probability threshold for token selection

tuned_model_name

Tuned Model Name

The name of a tuned model (overrides model_name if provided)

verbose

Verbose

Controls the level of detail in the output

Outputs
Name Type Description

embeddings

Embeddings

An instance for generating embeddings using VertexAI.

Component code

vertexai.py
404: Not Found

Was this helpful?

Give Feedback

How can we improve the documentation?

© 2025 DataStax | Privacy policy | Terms of use | Manage Privacy Choices

Apache, Apache Cassandra, Cassandra, Apache Tomcat, Tomcat, Apache Lucene, Apache Solr, Apache Hadoop, Hadoop, Apache Pulsar, Pulsar, Apache Spark, Spark, Apache TinkerPop, TinkerPop, Apache Kafka and Kafka are either registered trademarks or trademarks of the Apache Software Foundation or its subsidiaries in Canada, the United States and/or other countries. Kubernetes is the registered trademark of the Linux Foundation.

General Inquiries: +1 (650) 389-6000, info@datastax.com