Skip to main content

Similarity

This endpoint uses embeddings to measure the semantic similarity between a text anchor and its targets.

Usage#

curl --location --request POST 'https://api.cohere.ai/baseline-seal/similarity' \
--header 'Authorization: BEARER {api_key}' \
--header 'Content-Type: application/json' \
--data-raw '{
"anchor": "hi how are you doing today?",
"targets": ['greeting', 'request for assistance', 'asking a question']
}'

Sample Response#

{
"similarities": [0.17979126, -0.027569637, 0.1500656]
}

Request#

anchor#

string

Used for comparison against the strings in targets.

targets#

array of strings

To be compared to anchor.

Response#

similarities#

array of floats

An array of floats, where each entry represents the similarity of each target to the anchor respectively. A higher value means that a target is more similar to the anchor. The similarity between the anchor and a target is symmetric, i.e.

similarity(a,b)=similarity(b,a)similarity(a, b) = similarity(b, a)