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.
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
contentand stores the vector inDocument.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
- Click your profile icon and choose Settings.
- Go to Workspace>Integrations.
- Find the provider you want to connect and click Connect next to them.
- Enter the API key and any other required details.
- Click Connect. You can use this integration in pipelines and indexes in the current workspace.
Add Organization-Level Integration
- Click your profile icon and choose Settings.
- Go to Organization>Integrations.
- Find the provider you want to connect and click Connect next to them.
- Enter the API key and any other required details.
- Click Connect. You can use this integration in pipelines and indexes in all workspaces in the current organization.
- Drag the
TwelveLabsDocumentEmbeddercomponent onto the canvas from the Component Library. - Click on the component to open the configuration panel.
- On the General tab:
- Connect Haystack Platform to TwelveLabs by creating a secret called
TWELVELABS_API_KEY. For more information about secrets, see Create Secrets. - Set the
modelto the Marengo model you want to use. The default ismarengo3.0.
- Connect Haystack Platform to TwelveLabs by creating a secret called
- Go to the Advanced tab to configure
prefix,suffix,batch_size,meta_fields_to_embed, andembedding_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
| Parameter | Type | Description |
|---|---|---|
documents | List[Document] | The documents to embed. Their content field is embedded. |
Outputs
| Parameter | Type | Description |
|---|---|---|
documents | List[Document] | Copies of the input documents with embedding populated. |
meta | Dict[str, Any] | Metadata about the request, including the model used. |
Init Parameters
These are the parameters you can configure in Pipeline Builder:
| Parameter | Type | Default | Description |
|---|---|---|---|
api_key | Secret | Secret.from_env_var("TWELVELABS_API_KEY") | The TwelveLabs API key. |
model | str | marengo3.0 | The Marengo model name. |
prefix | str | "" | A string to add to the beginning of each text before embedding. |
suffix | str | "" | A string to add to the end of each text before embedding. |
batch_size | int | 32 | Number of documents per batch. Within a batch, run_async embeds concurrently. |
progress_bar | bool | True | Whether to show a progress bar while embedding. |
meta_fields_to_embed | Optional[List[str]] | None | List of metadata fields to embed along with the document text. |
embedding_separator | str | \n | Separator 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.
| Parameter | Type | Default | Description |
|---|---|---|---|
documents | List[Document] | The documents to embed. |
Related Information
Was this page helpful?