Many Watson Developer Cloud services and other cognitive software systems provide a numerical score for how confident the system is in some result.Â For example, the IBM Watson Retrieve and Rank serviceÂ provides a Ranker confidence score. The IBM Watson Natural Language ClassifierÂ also provides a confidence scoreÂ as do Watson services for language identification, speech processing, entity and relation detection, etc.
Some of these confidence scores may have some meaningful interpretation as a probability (e.g., a probability that some result is â€ścorrectâ€ť or â€śrelevantâ€ť).Â Other may not.Â You cannot assume that all results with a very high confidence score are very good and all results with a very low confidence score are very bad.Â However, you can generally assume that results with a higher confidence score are more likely to be better.Â Â
One use of confidence scores is setting a threshold for when to act.Â For example, imagine a specialized authoring tool that monitors what the author is writing and interrupts the author with relevant information if and only if it is extremely confident that it has some information that is relevant.Â Such an application needs to be very precise and should thus have a very high confidence threshold.Â In contrast, imagine a more typical search application where a user types in a query in a search box and waits for search results to come back.Â In that type of application, users definitely want to see some results, so such a system may be better with a much lower threshold or no threshold at all.
Ideal method for selecting a threshold
The ideal approach to selecting a threshold is:
- Â Assign numerical reward to each possible outcome.Â For example, for the authoring tool described earlier, we might decide that interrupting with a highly relevant document is worth $0.07, that interrupting with a moderately relevant document is worth $0.02, that interrupting with a non-relevant document is worth -$0.15 (i.e., it has a very high cost), and that not interrupting is worth 0.
- Run a large set of queries for which you know what the relevant responses are.Â These should be queries that are not in the set you use to train the system.
- For each possible threshold (e.g., each number that is the confidence of at least one instance in your set), compute the net reward for the system at that threshold.
- Select the threshold that has the greatest net reward.
However, there are several reasons why attaining this ideal might be challenging.Â Assigning numerical rewards to outcomes is very hard and often data is not available to make these assignments in an informed way.Â Also, you may not always have large set of requests for which you know what the relevant responses are.Â Below are more details on how to deal with these issues.
Computing outcome rewards from user data
For some applications, it may be possible to compute meaningful rewards from observations of user behavior.Â For example, if you know that when you present a relevant result to a user that 7% of the time it results in selling a product with an average profit of $22 so the reward for a relevant result is 7% of $22.
In some cases, the outcomes may not have a directly measurable cash benefit but may still result in something that is desirable.Â For example, for some application you may have logs that indicate what queries were asked, what responses the system gave, and whether the user used the application again on the next day.Â If you have an expert go through a random sample of those logs and mark-up which responses are good and which are bad, you can compute how quality of the responses correlates with the user returning.Â That can allow you to compute some expected impact on whether the user will return for each outcome, which you can use as a reward for that outcome.Â If there is a big negative impact from a bad response but no corresponding negative impact for not responding, then you would compute a large penalty for a bad response (relative to not responding) and as a result, you would wind up making the system very cautious (by setting a high threshold).Â If the negative impact of a bad response is only a little bit worse than negative response, then you might have a very low threshold.Â If the negative impact of a bad response is not as bad as no response, then you would want a 0 threshold so that you always respond since in that application a bad response tends to be better than nothing.
Eliciting outcome rewards via example
Many applications cannot compute outcome rewards from user data either because they do not have any user data yet (e.g., because they are under development) or because the user data they have does not provide information about the consequences of the system behavior (e.g., nothing that links requests and responses to sales or retention or anything else that you want).Â In that case, the long term goal should be to eventually start accumulating relevant user data and using it as described in the previous section.Â However, in the short term, it makes sense to try to make a best guess at what the rewards should be for different outcomes.Â One can try to guess the reward values directly, but that is extremely hard to do well; often when you ask an expert to do that and then they do and see what the implication of those guesses are, they find that they are unhappy with those implications.Â Instead, experts should see as much as possible about the consequences of different thresholds are so they can choose the set of consequences that seem best.
Here is one approach to letting experts see the consequences of different thresholds so that the system can be optimized to be consistent with the expertsâ€™ goals:
- Run the system on a validation set (a large set of requests for which you know what the relevant responses are) and record which requests had correct responses and how confident those responses were.
- For an assortment of thresholds (e.g., .04, .08, .12, .16, etc.), compute at that threshold:Â
One way to compute numerical rewards for outcomes that is consistent with a chosen threshold (step 6 above) is to arbitrarily fix the rewards for all but one outcome, compute the rewards for the remaining outcome that would make the system indifferent between the selected threshold and the ones above and below it, and then average those two.Â For example, consider the following table in a simple case where there are only three outcomes (in this example, if the confidence is above the threshold then a response is provided that is either right or wrong and if the confidence is not above the threshold then the response is ignored):
If the experts select the â€ś.08â€ť row then we want to find rewards consistent with that being the best row.Â We arbitrarily assign a reward of 1 to being right and a reward of 0 to ignoring a request, so we need to compute what the (negative) reward should be for being wrong.Â The point at which we should be indifferent between threshold .04 and .08 is 60%*1+32%*r1+8%*0 = 58%*1+26%*r1+16%*0; solving this equation, we get r1=-0.333.Â Similarly, the point at which we should be indifferent between .08 and .12 is 58%*1+26%*r2+16%*0=56%*1+14%*r2+30%*0, implying r2=-0.167.Â We compute the average of r1 and r2 to get the middle of the range of rewards that are consistent with this choice of threshold; in this case, the middle of the range is -0.25.Â Thus in this example we select the following set of rewards: 1 for being right, -0.25 for being wrong, and 0 for not responding.
In a more complex example, you may have more kinds of outcomes.Â For example, a question answering system may use confidence scores to decide whether to â€śhedgeâ€ť an answer (e.g., to say something like â€śI donâ€™t really know the answer to your question but maybe the following is relevantâ€ť).Â Also, some systems may use confidence scores to decide whether to respond with a single answer or multiple answers (it may use the confidence in the single best ranked answer to make this decision or it may also consider the confidence scores of lower ranked answers).Â The same basic principles apply.Â First, list possible outcomes (e.g., system does not respond, system responds with a hedge and a single answer and that answer is correct, system responds three answers and none of the answers is correct, etc.).Â Then produce examples of thresholds, see how often different outcomes occur at those thresholds. Then have domain experts which frequencies of outcomes are most desirable.Â Finally, find rewards for the outcomes that are consistent with the preferences of the experts.
One example of a tool for plotting graphs (instead of tables) for selecting a threshold is the IBM Watson Performance Evaluation Framework which you can access using sample data or bring your own data.Â The Performance Evaluation Framework does not fully address some complex cases such as having multiple thresholds for multiple outcomes, but you can download the code and adapt it to your specific needs.Â The graphs serve the same purpose as the outcome tables, but in a more comprehensive way: you can see the consequences of all possible threshold settings and use that information to choose an optimal threshold.Â Regardless of whether you use graphs or tables, you should determine a set of rewards that are consistent with this optimal threshold so you can automatically recompute the optimal threshold for those rewards every time you update the system.
This section explains how to enable experts to guess what an ideal behavior of the system should be so that a system can be configured to be consistent with that guess.Â However, it is still important to remember that guesses from experts are not as good as direct observations from large volumes of real user data.Â Do not forget that the approach described in the previous section (â€śComputing outcome rewards from user dataâ€ť) is the preferred approach.Â If you do not have the data that would enable that approach, you should try to get that sort of data eventually and to use the approach described in this section only as a temporary measure.
Heuristic rules instead of outcome rewards
Instead of determining rewards for outcomes, you can use some sort of rule to determine how you want the system to behave and then compute a threshold that is consistent with that behavior.Â Here are some examples of such rules:
For each of these rules, you can run the system on a pool of queries with known responses and compute an optimal threshold for that rule.Â In principle, rules like this are not as good as the approach described in earlier sections (because they do not guarantee an optimal total reward).Â However, sometimes domain experts prefer rules like these.Â These sorts of rules are (at least) much better than simply selecting an arbitrary threshold and keeping it fixed.Â Once you have a rule like this or a set of rewards as discussed earlier, you can update the threshold automatically on a continual basis as described in the next section.
Keeping thresholds up to date
In general, it is a bad idea to select a confidence score once and then assume that this confidence score remains good for all time.Â Instead, you should update the confidence thresholds whenever you make a substantial change to the system such as adding more content or changing the configuration.Â You should have some sort of validation process that you run every time you make a substantial change anyway, to verify that you havenâ€™t broken the system (e.g., for a search system, you might have a batch of sample queries that you run to validate that the system still works and produces results of comparable or better quality to the ones you were getting before).Â It is a good idea to embed the process for computing the confidence into your standard validation process.Â As much as possible, you should automate both computing and updating the threshold to prevent user error and ensure that it gets done.
The first sample rule listed in the previous question (â€śwe want the system to act 60% of the timeâ€¦â€ť) is different from the others in that you can compute an optimal threshold for this rule without knowing what the outcomes are (e.g., without knowing which responses are good and which ones are bad).Â For most purposes, it is a pretty bad rule: in general, you should want your system to answer more often when it is more accurate instead of answering a fixed amount regardless of how accurate it is.Â However, it does have the advantage that the threshold is easier to compute and easier to keep up to date.Â In fact, with this rule, you can continuously update your threshold to be more and more optimal as you continue, e.g., by updating the threshold every time you get a new response to be the threshold that would have caused you to respond to the desired percentage of all past queries including the one you just responded with.Â For most other types of rules, you do need information about outcomes (e.g., whether a response was good or bad), which often requires expert labeling.
Regardless of whether you have heuristic rules or outcome rewards, updating your threshold when you do a major update to your system is very important.Â For example, imagine that you make a change to your system that causes the confidence scores for all responses (good or bad) to be cut in half (and has no other effect).Â That change should not cause any change in the behavior of the system: the new confidence scores are just as useful for distinguishing between good responses and bad ones as the old was.Â If you automatically update your threshold using any of the heuristic rules discussed in the previous section or by computing an optimal threshold for a set of rewards, you will see that the system behavior is unchanged.Â However, if you donâ€™t do that and you assume that the numerical threshold that was good for the previous version of your system is still good, then you will see a dramatic change in the behavior, and if the threshold was good before, it will probably be bad now.Â In practice you generally do not see anything as extreme as all the scores being cut in half, but there is often some amount of drift in scores in one direction or another (that may be conflated with other changes in behavior such as the system being more accurate).Â Real improvements to a system can easily be counteracted by unintended and meaningless drift in absolute scores if you keep the threshold fixed.Â In contrast, if you recompute the optimal threshold on each update, you prevent this from happening and wind up with a system that is more stable in its behavior and more steadily improving as the underlying capabilities improve.
What if you only have training data?
All of the processes above assume that you have some validation data that you can use to compute thresholds.Â However, in some cases you have barely enough training data to train your system.Â One method for addressing this is cross-fold validation:
This is a lot more work than having separate validation data because you have to train the system many times.Â However, if you donâ€™t have separate validation data, this is a reasonable alternative.
What if you donâ€™t even have training data?
Many cognitive systems will not work at all without training data.Â However, some will work to some extent â€śout of the boxâ€ť without any training data; for example, you can use the Retrieve portion of IBM Watson Retrieve and Rank with no training data at first and gather training data over time to train a Ranker and get better results.Â In general, when you have no training data, it is probably a good idea to not use a threshold at all and present all the results you have to the users (and make sure that you have users who are very tolerant of poor results at this phase of your project).Â Once you gather a little data, you can use this for training and validating by cross-folding as described in the previous section.Â When you have even more, you can split that data up into training and validation data.
If the net reward for not responding is worse than the reward for responding with a bad result, then obviously you do not want to use a threshold to decide whether to respond: instead you should always respond no matter what.
At the other extreme, you may have an application where the cost of allowing a bad result through is so high that the optimal threshold involves never responding to any request.Â If you are in this situation, then either your rewards are wrong or you should not be deploying your system until it is more effective at what it does.Â In some cases, you may want to adjust the rewards to reflect the fact that there is some benefit to having the system operate so that it can gather some data that you can use for more training and more improvements.Â Such an adjustment generally involves temporarily increasing the reward for both right and wrong responses (or decreasing the reward for not responding).Â For example, consider a system where rewards for right, wrong, and not responding should be 1, -20, and 0 in the long run (i.e., there is a huge cost to getting any wrong, so it should only respond when it is extremely certain); if the system is not very precise, the optimal behavior for these rewards may be to never respond. However, if the system is in preliminary alpha testing and really needs to accumulate training data, then maybe the rewards for right and wrong should get a temporary boost of +5 (making the rewards 6, -15, and 0). That makes the system more aggressive.Â If this allows the system to respond sometimes, it can start accumulating data with a threshold optimized for these adjusted rewards.Â Once it accumulates enough data, the rewards should be adjusted back to their long-term values.Â If the optimal behavior is still to never respond, then the system still needs improvement.Â However, with more training data, you may find that there is now a lower threshold that is optimal because the system is more precise in its high confidence responses.
For most cognitive systems, it is not possible to set a threshold that accepts some results and have that threshold be â€śperfectâ€ť in either sense: it cannot guarantee that you will never accept a bad result and it cannot guarantee that you will never reject a good one.Â Instead, a threshold can only adjust the frequency of different outcomes: it can make you provide bad results less often at the cost of occasionally rejecting good ones.
Side Note: Interpreting confidence scores
With some exceptions, you should not treat the confidence scores from a cognitive system as a â€śpercentageâ€ť indicating degree of match or probability of match.Â For example, in Retrieve and Rank, a score of 0.8 does not indicate that the query matches the search result 80% (whatever that might mean) or that the search result has an 80% chance of being relevant to the query.Â For a deeper discussion of the complexities inherent in computing a percentage score for search results, see this article at the Apache Lucene site [hyperlink to wiki.apache.org/lucene-java/ScoresAsPercentages].Â If you really want a probability that some search result has some degree of relevance to your query, one reasonable method for computing that probability is as follows:
For example, if you have many results with a score between 0.181 and 0.182 and 13% of them are relevant, then you can conclude that results with a score between 0.181 and 0.182 have a 13% chance of being correct.Â For most applications, this is not worth the effort; instead it is sufficient to know that higher scores are better and to have some threshold for deciding how high a score is good enough.
Many people provided helpful input on drafts of this document.Â I would particularly like to thank John Prager, Jiri Navratil, Rishav Chakravarti, Anna Chaney, Anish Mathur, Seth Bachman, Scot Taylor, A.J. Morello, Chitra Venkatramani, Raimo Bakis, and Stephan Roorda for their contibutions.