Text embeddings
This guide shows how you can create text embeddings.
The following table lists the available models for generating text embeddings and their key characteristics:
The Marengo video understanding model generates embeddings for all modalities in the same latent space. This shared space enables any-to-any searches across different types of content.
Prerequisites
-
To use the platform, you need an API key:
-
Depending on the programming language you are using, install the TwelveLabs SDK by entering one of the following commands:
Complete example
This complete example shows how you can create text embeddings. Ensure you replace the placeholders surrounded by <> with your values.
Step-by-step guide
Python
Node.js
Import the SDK and initialize the client
Create a client instance to interact with the TwelveLabs Video Understanding Platform.
Function call: You call the constructor of the TwelveLabs class.
Parameters:
api_key: The API key to authenticate your requests to the platform.
Return value: An object of type TwelveLabs configured for making API calls.
Create text embeddings
Function call: You call the embed.create function.
Parameters:
-
model_name: The name of the model you want to use (example: “marengo3.0”). -
text: The text for which you wish to create an embedding. -
(Optional)
text_truncate: A string that specifies how the platform handles text that exceeds token limits.Available options by model version:
Marengo 3.0: This parameter is deprecated. The platform automatically truncates text exceeding 500 tokens from the end.
Marengo 2.7: Specifies truncation method for text exceeding 77 tokens:
start: Removes tokens from the beginningend: Removes tokens from the end (default)none: Returns an error if the text is longer than the maximum token limit.
Return value: The response contains the following fields:
text_embedding: An object that contains the embedding data for your text. It includes the following fields:segments: An object that contains the following:float_: An array of floats representing the embedding
metadata: An object that contains metadata about the embedding.
model_name: The name of the video understanding model the platform has used to create this embedding.