Skip to main content

Choose Best

The Choose Best endpoint uses likelihood to perform classification. Given a query text that you'd like to classify between a number of options, Choose Best will return a score between the query and each option. For some examples of Choose Best see classifiying questions and sentiment analysis.


    Sample Response#

    "scores": [
    "tokens": [
    [" positive"],
    [" negative"]
    "token_log_likelihoods": [




    Used to query the options.


    array of strings
    Each string concatenates to the query.


    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(\textrm{query} | \textrm{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(\textrm{option} | \textrm{query})

    See the Choose Best modes page for more details.



    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=log_likelihoodn_tokens\textrm{score} = \frac{\textrm{log\_likelihood}}{\textrm{n\_tokens}}

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


    array of tokens
    An array of tokens corresponding to the tokens for each of the options. The tokens are represented as an array of strings.


    array of token log likelihoods

    An array of log likelihoods corresponding to the tokens of each of the options. The log likelihoods are represented as an array of floats.