Skip to main content
For the complete documentation index for agents and LLMs, see llms.txt.

TwelveLabsTextEmbedder

Embed query strings using TwelveLabs Marengo. Marengo embeds text, images, audio, and video into a single shared vector space, so query embeddings from this component are directly comparable with document embeddings from TwelveLabsDocumentEmbedder.

Embedding Models in Query Pipelines and Indexes

The embedding model you use to embed documents in your indexing pipeline must be the same as the embedding model you use to embed the query in your query pipeline.

This means the embedders for your indexing and query pipelines must match. For example, if you use CohereDocumentEmbedder to embed your documents, you should use CohereTextEmbedder with the same model to embed your queries.

Key Features

  • Embeds a single text string into a float vector using the Marengo model.
  • Supports cross-modal retrieval when paired with Marengo document embeddings.
  • Supports optional prefix and suffix strings before embedding.
  • Provides synchronous and asynchronous execution.

Configuration

Add Workspace-Level Integration

  1. Click your profile icon and choose Settings.
  2. Go to Workspace>Integrations.
  3. Find the provider you want to connect and click Connect next to them.
  4. Enter the API key and any other required details.
  5. Click Connect. You can use this integration in pipelines and indexes in the current workspace.

Add Organization-Level Integration

  1. Click your profile icon and choose Settings.
  2. Go to Organization>Integrations.
  3. Find the provider you want to connect and click Connect next to them.
  4. Enter the API key and any other required details.
  5. Click Connect. You can use this integration in pipelines and indexes in all workspaces in the current organization.
  1. Drag the TwelveLabsTextEmbedder component onto the canvas from the Component Library.
  2. Click on the component to open the configuration panel.
  3. On the General tab:
    1. Connect Haystack Platform to TwelveLabs by creating a secret called TWELVELABS_API_KEY. For more information about secrets, see Create Secrets.
    2. Set the model to the Marengo model you want to use. The default is marengo3.0.
  4. Go to the Advanced tab to configure prefix and suffix.

Connections

TwelveLabsTextEmbedder receives a query string, typically from the Input component. It outputs a float vector through its embedding output, which you connect to an embedding retriever.

Source Code

To check this component's source code, open text_embedder.py in the Haystack Core Integrations repository.

Usage Examples

Basic Configuration

  TwelveLabsTextEmbedder:
type: haystack_integrations.components.embedders.twelvelabs.text_embedder.TwelveLabsTextEmbedder
init_parameters:
api_key:
type: env_var
env_vars:
- TWELVELABS_API_KEY
strict: false
model: marengo3.0

Using the Component in a Pipeline

# haystack-pipeline
components:
TwelveLabsTextEmbedder:
type: haystack_integrations.components.embedders.twelvelabs.text_embedder.TwelveLabsTextEmbedder
init_parameters:
api_key:
type: env_var
env_vars:
- TWELVELABS_API_KEY
strict: false
model: marengo3.0

retriever:
type: haystack.components.retrievers.in_memory.embedding_retriever.InMemoryEmbeddingRetriever
init_parameters:
document_store:
type: haystack.document_stores.in_memory.document_store.InMemoryDocumentStore
init_parameters: {}
top_k: 10

connections:
- sender: TwelveLabsTextEmbedder.embedding
receiver: retriever.query_embedding

max_runs_per_component: 100

metadata: {}

inputs:
query:
- TwelveLabsTextEmbedder.text

Parameters

Inputs

ParameterTypeDescription
textstrThe string to embed.

Outputs

ParameterTypeDescription
embeddingList[float]The embedding vector for the input string.
metaDict[str, Any]Metadata about the request, including the model used.

Init Parameters

These are the parameters you can configure in Pipeline Builder:

ParameterTypeDefaultDescription
api_keySecretSecret.from_env_var("TWELVELABS_API_KEY")The TwelveLabs API key.
modelstrmarengo3.0The Marengo model name.
prefixstr""A string to add to the beginning of the text before embedding.
suffixstr""A string to add to the end of the text before embedding.

Run Method Parameters

These are the parameters you can configure for the component's run() method. This means you can pass these parameters at query time through the API, in Playground, or when running a job. For details, see Modify Pipeline Parameters at Query Time.

ParameterTypeDefaultDescription
textstrThe string to embed.