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.
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
- 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
TwelveLabsTextEmbeddercomponent 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
prefixandsuffix.
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
| Parameter | Type | Description |
|---|---|---|
text | str | The string to embed. |
Outputs
| Parameter | Type | Description |
|---|---|---|
embedding | List[float] | The embedding vector for the input string. |
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 the text before embedding. |
suffix | str | "" | 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.
| Parameter | Type | Default | Description |
|---|---|---|---|
text | str | The string to embed. |
Related Information
Was this page helpful?