1. A system, comprising: one or more computers; and a computer-readable storage device storing instructions that, when executed by the one or more computers, cause the one or more computers to perform operations comprising: storing data identifying a plurality of training images for a query, wherein each of the training images is classified as being in a positive group of images for the query or a negative group of images for the query according to a respective query specific preference measure for the image; selecting a first image from either the positive group of images or the negative group of images, and applying a scoring model to the first image to determine a score for the first image; selecting a plurality of candidate images from the other group of images; applying the scoring model to each of the candidate images to determine a respective score for each candidate image, and then selecting a second image from the candidate images, the selection based on a probability that is proportional to a cardinality of the plurality of candidate images and a ranking of the second image relative to each other image in the candidate images based on the respective scores of the images; and determining that the scores for the first image and the second image fail to satisfy a criterion, wherein the criterion requires that a result of the score of the image selected from the positive group of images minus the score of the image selected from the negative group of images exceeds a threshold, updating the scoring model, and storing the updated scoring model.