1. A system, comprising: one or more computers configured to perform operations comprising: storing a plurality of training examples; generating a sequence of hash functions, wherein each hash function defines a mapping of features of an item to a bit in a corresponding ordered sequence of bits, wherein the hash function for a particular bit determines the value of the particular bit according to a respective weight vector, wherein generating the hash function comprises sequentially determining the weight vectors for each hash function, and wherein determining the weight vector for a current hash function in the sequence after a weight vector for at least one previously determined hash function has been determined comprises: determining the weight vector for the current hash function, wherein the determined weight vector maximizes an accuracy measure derived from a respective set of constraints generated for all previously determined hash functions; selecting a plurality of pseudo-neighbor pairs of training examples and a plurality of pseudo-non-neighbor pair of training examples for use in determining the weight vector for a next hash function in the sequence, wherein the pseudo-neighbor pairs of training examples and the pseudo-non-neighbor pairs of training examples are selected according to the determined weight vector; and generating a group of constraints for the current hash function, wherein the generated constraints reflect the selected pseudo-neighbor pairs of training examples and the selected pseudo-non-neighbor pairs training examples; and storing the determined weight vectors in a data store.