Skip to content

Cosine Similarity

Class: CosineSimilarityBlockV1

Source: inference.core.workflows.core_steps.math.cosine_similarity.v1.CosineSimilarityBlockV1

Calculate the cosine similarity between two embeddings.

A cosine similarity of 1 means the two embeddings are identical, while a cosine similarity of 0 means the two embeddings are orthogonal. Greater values indicate greater similarity.

Type identifier

Use the following identifier in step "type" field: roboflow_core/cosine_similarity@v1to add the block as as step in your workflow.

Properties

Name Type Description Refs
name str Unique name of step in workflows.

The Refs column marks possibility to parametrise the property with dynamic values available in workflow runtime. See Bindings for more info.

Available Connections

Compatible Blocks

Check what blocks you can connect to Cosine Similarity in version v1.

Input and Output Bindings

The available connections depend on its binding kinds. Check what binding kinds Cosine Similarity in version v1 has.

Bindings
  • input

  • output

    • similarity (float): Float value.
Example JSON definition of step Cosine Similarity in version v1
{
    "name": "<your_step_name_here>",
    "type": "roboflow_core/cosine_similarity@v1",
    "embedding_1": "$steps.clip_image.embedding",
    "embedding_2": "$steps.clip_text.embedding"
}