GetEmbedding

Returns a vector representation as container data for input text using an embedding model.

Format 

GetEmbedding ( account ; model ; text )

Parameters 

account - the AI account for this function to use. In the current file, use the Configure AI Account script step to set up the account and assign it this name any time before this function is used.

model - the name of the model to generate embedding vectors. Specify the model name as a text expression, which is available from the model provider.

text - any text expression to send to the model for conversion to embedding vectors.

Data type returned 

container

Originated in version 

21.0

Description 

Similar to the Insert Embedding script step, this function gets embedding vectors for the specified text using an AI account and model. However, this function returns embedding vectors only as container data, which can be smaller than when stored as text and can improve performance in any further processing with the embedding vectors.

If no AI account is currently configured, this function returns "?", and the EvaluationError function returns error code 877 ("Can't find AI account").

Example 1 

Configures an AI account, goes to the Meeting Details layout, then sets the value of the Meetings::Note_Embedding container field in the current record to the binary embedding vector data for the text "Claris."

Copy
Configure AI Account [ Account Name: "my-account" ; Model Provider: OpenAI ; API key: "sk-RZCtpWT..." ]
Go to Layout [ "Meeting Details" (Meetings) ; Animation: None ]

Set Field [ Meetings::Note_Embedding ; GetEmbedding ( "my-account" ; "text-embedding-3-small" ; "Claris" ) ]

Example 2 

Configures an AI account, goes to the Meeting Details layout, and asks the user to enter text to compare with the Note field in the current record. Next, gets the embedding vectors for the input and stores them in a variable as container data, and does the same with the text in the Meetings::Note field. Then displays the cosine similarity of the embedding vectors in the two variables.

Copy
Configure AI Account [ Account Name: "my-account" ; Model Provider: OpenAI ; API key: "sk-RZCtpWT..." ]

Go to Layout [ "Meeting Details" (Meetings) ; Animation: None ]

Show Custom Dialog [ "Compare this text to the meeting note:" ; $Input ]
Set Variable [ $Input_Embedding ; Value: GetEmbedding ( "my-account" ; "text-embedding-3-small" ; $Input ) ]
Set Variable [ $Note_Embedding ; Value: GetEmbedding ( "my-account" ; "text-embedding-3-small" ; Meetings::Note ) ]

Show Custom Dialog [ "Cosine Similarity" ; CosineSimilarity ( $Input_Embedding ; $Note_Embedding ) ]