Skip to main content

Likelihood

This endpoint provides the model log-likelihood of each token in a string as well as the sum of the log-likelihoods of each token in that string. To learn more about likelihood, see here.

Usage#

curl --location --request POST 'https://api.cohere.ai/baseline-shark/likelihood' \
--header 'Authorization: BEARER {api_key}' \
--header 'Content-Type: application/json' \
--data-raw '{
"text": "so I crept up the basement stairs and BOOOO!"
}'

Sample Response#

{
"likelihood":-46.74832,
"token_likelihoods":[
{"token":"so"},
{"token":" I","likelihood":-2.7963603},
{"token":" cre","likelihood":-11.007304},
{"token":"pt","likelihood":-0.18487053},
{"token":" up","likelihood":-1.7509942},
{"token":" the","likelihood":-2.2046893},
{"token":" basement","likelihood":-6.5210433},
{"token":" stairs","likelihood":-0.13984226},
{"token":" and","likelihood":-1.1252899},
{"token":" BO","likelihood":-10.85497},
{"token":"OO","likelihood":-4.700402},
{"token":"O", "likelihood":-1.6468925},
{"token":"!", "likelihood":-3.8156648}
]
}

Request#

text#

string
The string to compute the log-likelihood of.

Response#

likelihood#

float
The sum of the log-likelihoods of each token in the string.

token_likelihoods#

array of objects

An array of objects with the following shape:

{
"token": string,
"likelihood": float
}

The likelihood refers to the log-likelihood of the token. The first token will not have a likelihood.