Skip to main content

Choose Best

This endpoint reports the log-likelihoods of the concatenation between the option strings and a query string. The options can either go at the beginning of the query (prepend) or at the end (append).

Usage#

curl --location --request POST 'https://api.cohere.ai/baseline-shark/choose-best' \
--header 'Authorization: BEARER {api_key}' \
--header 'Content-Type: application/json' \
--data-raw '{
"query": "Carol picked up a book and walked to the kitchen. She set it down, picked up her glasses and left. This is in the kitchen now: ",
"options": ["book", "glasses", "dog"],
"mode": "APPEND_OPTION"
}'

Sample Response#

{
"likelihoods": [
5.1482406,
2.4001937,
-2.476759
]
}

Request#

query#

string

Used to query the options.

options#

array of strings
Each string concatenates to the query.

mode#

One of PREPEND_OPTION|APPEND_OPTION to specify where the option string will be placed and how to compute the log-likelihood.

If PREPEND_OPTION is selected, the output will be the log-likelihood of the queryquery conditioned on the optionoption:   log p(queryoption)log\ p(query | option)

If APPEND_OPTION is selected, the output will be the log-likelihood of the optionoption conditioned on the queryquery:   log p(optionquery)log\ p(option | query)

Response#

likelihoods#

array of floats
An array of floats corresponding to a score for each of the options, where a higher score represents a more likely query-option pair. This score is computed as:
score=10+(log_likelihood/n_tokens)score = 10 + (log\_likelihood/n\_tokens)

where n_tokens is the number of tokens that are summed over to compute the log_likelihood.