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

TwelveLabsDocumentEmbedder

Compute Marengo embeddings for document text content using TwelveLabs. Use this component in indexing pipelines to prepare documents for cross-modal retrieval with TwelveLabsTextEmbedder.

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 each document's content and stores the vector in Document.embedding.
  • Supports cross-modal retrieval because Marengo embeds text, images, audio, and video into one shared space.
  • Supports embedding selected metadata fields alongside document content.
  • Processes documents in configurable batches with an optional progress bar.
  • 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 TwelveLabsDocumentEmbedder 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, suffix, batch_size, meta_fields_to_embed, and embedding_separator.

Connections

TwelveLabsDocumentEmbedder receives a list of documents, typically from a converter or splitter. It outputs the same documents with embeddings added to their embedding field, ready to be sent to a DocumentWriter.

Source Code

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

Usage Examples

Basic Configuration

  TwelveLabsDocumentEmbedder:
type: haystack_integrations.components.embedders.twelvelabs.document_embedder.TwelveLabsDocumentEmbedder
init_parameters:
api_key:
type: env_var
env_vars:
- TWELVELABS_API_KEY
strict: false
model: marengo3.0
batch_size: 32

Using the Component in a Pipeline

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

document_writer:
type: haystack.components.writers.document_writer.DocumentWriter
init_parameters:
document_store:
type: haystack.document_stores.in_memory.document_store.InMemoryDocumentStore
init_parameters: {}

connections:
- sender: TwelveLabsDocumentEmbedder.documents
receiver: document_writer.documents

max_runs_per_component: 100

metadata: {}

Parameters

Inputs

ParameterTypeDescription
documentsList[Document]The documents to embed. Their content field is embedded.

Outputs

ParameterTypeDescription
documentsList[Document]Copies of the input documents with embedding populated.
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 each text before embedding.
suffixstr""A string to add to the end of each text before embedding.
batch_sizeint32Number of documents per batch. Within a batch, run_async embeds concurrently.
progress_barboolTrueWhether to show a progress bar while embedding.
meta_fields_to_embedOptional[List[str]]NoneList of metadata fields to embed along with the document text.
embedding_separatorstr\nSeparator used to concatenate metadata fields to the document text.

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
documentsList[Document]The documents to embed.