Skip to main content

Sentence Similarity

This endpoint will receive a series of texts from you, encode them using a BERT-derived model, and produce a series of scores using a Cosine Similarity function to rank them.

This functionality is designed to work best with short sentences.

Constraints

Limits

The maximum length accepted is 512 characters per sentence, and up to 20 sentences per request.

Invokation

curl -L -G 'http://api.textkit.ai/detect/similarity' \
--data-urlencode 'text=yeah, man! Go!' \
--header 'Content-Type: application/json' \
--data-raw '[
"the color is red",
"i want to unsubscribe",
"delete me from your emails",
"don'\''t send me anything anymore"
]'

Response

{
"time_ms": 109,
"scores": [
{
"score": 0.526,
"sentences": [
"delete me from your emails",
"don't send me anything anymore"
]
},
{
"score": 0.496,
"sentences": [
"i want to unsubscribe",
"delete me from your emails"
]
},
{
"score": 0.26,
"sentences": [
"i want to unsubscribe",
"don't send me anything anymore"
]
},
{
"score": 0.097,
"sentences": [
"the color is red",
"don't send me anything anymore"
]
},
{
"score": 0.052,
"sentences": [
"the color is red",
"i want to unsubscribe"
]
},
{
"score": -0.013,
"sentences": [
"the color is red",
"delete me from your emails"
]
}
]
}
FieldMeaning
scoreThe higher the number, the more similar the sentences are
sentencesthe 2 sentences being compared which resulted in the computed score