Semantic Comparator Node
This node compares the semantic similarity of two input texts using OpenAI’s embedding models. It calculates the similarity score between the embeddings of the input texts using various similarity metrics such as cosine similarity, dot product, or Euclidean distance.
Inputs
input 1: Accepts a ‘string’ input representing the first text to compare.
input 2: Accepts a ‘string’ input representing the second text to compare.
Outputs
output: Outputs a ‘number’ representing the similarity score between the input texts.
Properties
Model: Choose from available embedding models like “text-embedding-ada-002”, “text-embedding-3-small”, “text-embedding-3-large”.
Secret: API key for accessing OpenAI services.
Comparison: Select the similarity metric to use for comparing the embeddings. Options include ‘cosine’ (cosine similarity), ‘dot’ (dot product), and ‘euclidean’ (Euclidean distance).
Functionalities
The node sends requests to the OpenAI API to generate embeddings for the input texts using the selected model. It then calculates the similarity score between the embeddings using the chosen similarity metric. The resulting similarity score is output by the node.
Widgets
Model Selector: Choose the embedding model to use.
Secret Selector: Select the API key for access.
Comparison Selector: Choose the similarity metric for comparing the embeddings.
Usage
1. Connect two string inputs representing the texts to compare.
2. Choose the desired embedding model, provide the API key, and select the similarity metric.
3. The node generates embeddings for the input texts, calculates the similarity score, and outputs the result.
4. The similarity score can be used to determine the semantic relatedness between the input texts, which can be useful for various applications such as text similarity analysis, document clustering, or recommendation systems.