Efficient similarity search
1. A system for measuring similarity between a binary query vector and a plurality of binary candidate vectors, the system comprising:
a storage unit for storing the binary query vector and the plurality of candidate vectors; and
a processor for performing a valley calculation as a function of hamming distance, the processor comprising:
a valley to Hamming threshold converter for converting a valley threshold to a Hamming threshold;
a Hamming measurer for measuring a Hamming distance between the candidate vector and the query vector; and
a Hamming comparator for selecting candidate vectors whose Hamming distance from the query vector is less than or equal to the Hamming threshold.
2. The system of claim 1, wherein the valley threshold and the hamming distance are a function of a pop-up count and a boolean XOR function between the candidate vector and the query vector.
3. The system of claim 1, wherein the valley-to-hamming threshold converter comprises:
a pop-up counter for counting the number of occurrences of the selected symbol in one of the binary vectors; and
a Hamming threshold calculator to calculate the Hamming threshold based on the valley metric, the valley metric being based on a pop-up count of one of the query vector and the candidate vector.
4. The system of claim 1, wherein the hamming measurer comprises:
an XOR calculator for calculating an XOR between the two binary vectors; and
a pop counter for counting a number of occurrences of a logical true value in an output of the XOR calculator.
5. The system of claim 1, further comprising:
a chunker for grouping the candidate vectors into chunks according to their pop counts; and
a chunk comparator for rejecting those chunks that cannot contain the candidate vector that is similar to the query vector, and for providing the hamming measurer with chunks that are not rejected.
6. The system of claim 5, wherein the chunker comprises:
a pop counter for counting a pop count of the candidate vector; and
a vector classifier for grouping the candidate vectors into chunks with homogenous pop counts.
7. The system of claim 5, wherein the chunk comparator comprises:
an eject counter for counting an eject count of the chunk; and
a Hamming minimum comparator to compare the pop count of the chunk with the Hamming threshold and reject the chunk with a pop count above the Hamming threshold.
8. The system of claim 5, further comprising:
a clusterer to group the candidate vectors in the chunks into clusters having prototype centroids by a clustering algorithm; and
a cluster comparator to select at least one of the clusters having the centroids similar to the query vector.
9. The system of claim 8, wherein the clustering algorithm is one of: the K-means algorithm and the K nearest neighbor algorithm.
10. The system of claim 8, wherein the cluster comparator comprises:
a hamming measurer for measuring the hamming distance between the query vector and the centroid; and
a Hamming comparator to select only the clusters having the centroid within the Hamming measurement threshold of the at least one of the query vector and the chunk.
11. The system of claim 1, implemented in associative memory.
12. A method for measuring similarity between a binary query vector and a plurality of binary candidate vectors, the method comprising:
storing the binary query vector and the plurality of candidate vectors;
performing a valley metric calculation based on the hamming distance;
converting the valley threshold into a Hamming threshold;
measuring a hamming distance between the candidate vector and the query vector; and
selecting candidate vectors whose Hamming distance from the query vector is less than or equal to the Hamming threshold.
13. The method of claim 12, wherein the valley metric and the hamming distance are a function of a pop-up count and a boolean XOR function between the candidate vector and the query vector.
14. The method of claim 12, wherein the converting comprises:
counting a number of occurrences of the selected symbol in one of the binary vectors; and
computing the Hamming threshold based on the valley metric based on a pop-up count of one of the query and the candidate vector.
15. The method of claim 12, wherein the measuring comprises:
calculating an XOR between the two binary vectors; and
counting a number of occurrences of a logical true value in the computed output.
16. The method of claim 12, further comprising:
blocking the candidate vector into chunks according to the pop-up count of the candidate vector; and
rejecting those chunks that cannot contain the candidate vector that is similar to the query vector, and providing non-rejected chunks for measurement.
17. The method of claim 16, wherein the partitioning comprises:
counting a pop-up count of the candidate vector; and
sorting to group the candidate vectors into the chunks with homogenous pop counts.
18. The method of claim 16, wherein the rejecting comprises:
counting a pop count of the chunk; and
comparing the pop count for the chunk to the Hamming threshold, and rejecting the chunk with the pop count above the Hamming threshold.
19. The method of claim 16, further comprising:
clustering the candidate vectors in the chunks into clusters having prototype centroids by a clustering algorithm; and
selecting the clusters having the centroids similar to the query vector.
20. The method of claim 19, wherein the clustering algorithm is one of: the K-means algorithm and the K nearest neighbor algorithm.
21. The method of claim 19, wherein the selecting comprises:
measuring the hamming distance between the query vector and the centroid; and
selecting only the clusters having the centroid within the hamming measurement threshold for the query vector and the chunk.
Background
Similarity searches are used to find items that are similar to each other. For example, chemists use such tools to search chemical and biological informatics databases to help design new molecules. The basic assumption in these calculations is that molecules with similar structures may have similar biological and physicochemical properties. This is commonly referred to as the "principle of similarity".
Five main search methods are utilized in molecular search of databases: text search, molecular formula search, identity search, substructure search, and similarity search.
The text search is a simple keyword search, e.g., for the word "aspirin".
Molecular formula search is used to find molecules containing a certain number and type of elements (e.g., C6H 6).
Identity searches are used to locate a particular chemical structure that is "the same" as the query structure.
Substructure searches require specialized search engines that identify schematics (illedustrations) of molecules to find chemical structures that appear as part of a larger chemical structure.
Similarity searches are used to find molecules similar to the query molecule. Various aspects of the molecules used in the comparison may vary depending on the application. The number of similar aspects may also vary depending on the nature of the search.
The similarity search operates on a similarity measure (similarity measure). All degrees of similarity include three basic components — molecular descriptors, weights, and similarity coefficients.
The molecular descriptors may also be referred to as features. A feature is a numerical representation of a physical, chemical, or other property of a molecule. One set of features is called a "molecular fingerprint".
The weights are used to prioritize and de-prioritize features to reflect their relative importance in a particular fingerprinting method. Over time, different molecular fingerprinting methods have been developed to address different measurement needs. They may contain different numbers and types of features and weights obtained in different ways.
The similarity coefficient (also known as similarity measure) provides a numerical value to the degree of similarity between two molecules. The type of molecular fingerprint being used, the size of the search sample, and other factors may influence the selection of the similarity metric. Examples of similarity measures are notebook (Tanimoto), hamming, L1, L2, and Jaccard.
Chemists and biologists often use the valley measure α to quantify the similarity between molecular fingerprints. The valley measure α is the ratio of the common features of two molecular fingerprints being compared (i.e., the intersection of their fingerprint features) to the features that are present together in two molecules (i.e., the union of their fingerprint features) and can be expressed as:
where A and B are the molecular fingerprints of molecules a and B, respectively,. sup.n is the intersection of the fingerprint features, and. sup.u is the union of the fingerprint features, and where the value of α (A, B) is between zero and one-the more similar the molecular fingerprints A and B are, the more towards 1 the value of the valley metric α (A, B).
For example, if numerator a has 28 features and numerator b has 32 features, where 15 of the features are common to both a and b, then the valley metric α can be calculated using equation 1:
referring now to fig. 1, there is shown a prior art valley measurement system 10 including a valley measurer 12, a valley comparator 13 and a candidate vector database 14. The valley measurer 12 measures a valley measure α between the query vector q and the candidate vector C from the candidate vector database 14m. The valley comparator 13 then measures the measured valleyαmAnd a defined threshold cost metric alphatA comparison is made. Threshold trough metric alphatDefine such amThe value: above this value, the compared vectors are considered similar. For the above-mentioned example, if αtDefined as 0.85, then the measured valley metric αmA value of 0.33 indicates that q and C are not similar. If α ismIs equal to or greater than alphatThen the valley comparator 13 identifies vector C as a valid candidate vector. This measurement is repeated for all vectors in the candidate vector database 14.
Because molecular fingerprints may contain thousands of features, and a molecular fingerprint database may contain hundreds of thousands of candidates, performing a similarity search on molecular fingerprints using a trough metric may be computationally expensive, complex, and time consuming.
Disclosure of Invention
Thus, in accordance with a preferred embodiment of the present invention, there is provided a system for measuring similarity between a binary query vector and a plurality of binary candidate vectors. The system includes a memory unit and a processor. The storage unit stores a binary query vector and a plurality of candidate vectors, and the processor performs a valley calculation according to a hamming distance. The processor includes: a valley to hamming threshold converter, a hamming measurer and a hamming comparator. A valley to Hamming threshold converter converts a valley threshold to a Hamming threshold. The hamming measurer measures the hamming distance between the candidate vector and the query vector. The hamming comparator selects candidate vectors having a hamming distance from the query vector that is less than or equal to a hamming threshold.
Additionally, according to a preferred embodiment of the present invention, the valley threshold and the hamming distance are a function of the pop counts (pop counts) and a boolean XOR function between the candidate vector and the query vector.
Furthermore, in accordance with a preferred embodiment of the present invention, a valley to hamming threshold converter includes: a pop counter (pop counter) and a hamming threshold calculator. The pop-up counter counts the number of occurrences of the selected symbol in one of the binary vectors. The Hamming threshold calculator calculates the Hamming threshold based on a valley metric based on one of the candidate vectors and a pop-up count of the query.
Further, according to a preferred embodiment of the present invention, the hamming measurer includes: an XOR calculator and a pop-up counter. The XOR calculator calculates the XOR between the two binary vectors, and the pop-up counter counts the number of occurrences of a logical true value in the output of the XOR calculator.
Furthermore, in accordance with a preferred embodiment of the present invention, the system further comprises: chunker and chunk comparators. The chunker groups the candidate vectors into chunks according to their pop counts. The chunk comparator rejects those chunks that cannot contain a candidate vector similar to the query vector and provides chunks to the hamming measurer that are not rejected.
Further in accordance with a preferred embodiment of the present invention, a chunker includes: a pop-up counter and a vector classifier. The pop counter counts the pop counts of the candidate vectors, and the vector classifier groups the candidate vectors into chunks with homogenous pop counts.
Further, according to a preferred embodiment of the present invention, the chunk comparator includes: a pop-up counter and a Hamming minimum comparator (Hamming minimum comparator). The pop counter counts a pop count of the chunk. The hamming minimum comparator compares the pop-up count of a chunk to a hamming threshold and rejects chunks with a pop-up count above the hamming threshold.
Additionally, in accordance with a preferred embodiment of the present invention, the system includes: a clusterer and a cluster comparator. The clusterer groups candidate vectors in the chunks into clusters having prototype centroids through a clustering algorithm, and the cluster comparator selects clusters having centroids similar to the query vector.
Furthermore, in accordance with a preferred embodiment of the present invention, the clustering algorithm is a K-means algorithm or a K-nearest neighbor algorithm.
Further in accordance with a preferred embodiment of the present invention, the cluster comparator includes: a hamming measurer and a hamming comparator. The hamming measurer measures the hamming distance between the query vector and the centroid. The hamming comparator selects only clusters that have centroids within the hamming measurement thresholds of the clusters and query vectors.
Additionally in accordance with a preferred embodiment of the present invention the system is implemented in associative memory.
There is also provided in accordance with a preferred embodiment of the present invention a method for measuring similarity between a binary query vector and a plurality of binary candidate vectors. The method comprises the following steps: storing a binary query vector and a plurality of candidate vectors; performing a valley metric calculation based on the hamming distance; and converting the valley threshold to a hamming threshold. The method further comprises the following steps: the hamming distance between the candidate vector and the query vector is measured and candidate vectors whose hamming distance from the query vector is less than or equal to a hamming threshold are selected.
Furthermore, in accordance with a preferred embodiment of the present invention, the converting includes: the number of occurrences of the selected symbol in one of the binary vectors is counted, and a hamming threshold is calculated based on a valley metric based on one of the candidate vectors and a pop-up count of the query.
Further in accordance with a preferred embodiment of the present invention, the measuring comprises: an XOR between the two binary vectors is calculated and the number of occurrences of a logical true value in the calculated output is counted.
Further in accordance with a preferred embodiment of the present invention, the method further comprises: the candidate vectors are blocked into chunks according to their pop counts, and those chunks that cannot contain candidate vectors similar to the query vector are rejected and the non-rejected chunks are provided for measurement.
Additionally, in accordance with a preferred embodiment of the present invention, the partitioning comprises: the pop-up counts of the candidate vectors are counted, and the candidate vectors are sorted to group into chunks with homogenous pop-up counts.
Furthermore, in accordance with a preferred embodiment of the present invention, rejecting comprises: the method further includes counting a pop count for the chunk, and comparing the pop count for the chunk to a hamming threshold and rejecting chunks having a pop count above the hamming threshold.
Further in accordance with a preferred embodiment of the present invention, the method further comprises: the candidate vectors in the chunks are clustered by a clustering algorithm into clusters having prototype centroids, and clusters having centroids similar to the query vector are selected.
Additionally, in accordance with a preferred embodiment of the present invention, the selecting includes: the hamming distance between the query vector and the centroid is measured, and only clusters having centroids within the hamming measurement thresholds of the query vector and the chunk are selected.
Drawings
The subject matter which is regarded as the invention is particularly pointed out and distinctly claimed in the claims at the conclusion of the specification. The invention, however, both as to organization and method of operation, together with objects, features, and advantages thereof, may best be understood by reference to the following detailed description when read with the accompanying drawings in which:
FIG. 1 is a schematic diagram of a prior art valley measurement system;
FIGS. 2A and 2B are diagrams of binary vectors;
FIG. 3 is a schematic diagram of a preferred embodiment of a Hamming-Valley measurement system;
FIG. 4 is a schematic diagram of elements of a valley to Hamming threshold converter useful in the system of FIG. 3;
FIG. 5 is a schematic diagram of the elements of a Hamming measurer;
6A, 6B, and 6C are illustrations of binary vectors;
FIG. 7 is a schematic view of an alternative preferred embodiment of a valley measurement system;
FIG. 8 is a schematic diagram of elements of a chunking device useful in the system of FIG. 7;
FIG. 9 is a diagram of elements of a chunk comparator useful in the system of FIG. 7;
10A, 10B, and 10C are diagrams of clustering binary vectors;
FIG. 11 is a schematic view of an alternative preferred embodiment of a valley measurement system;
FIG. 12 is a schematic diagram of elements of a cluster comparator useful in the system of FIG. 11;
FIG. 13 is a schematic diagram of a associative memory array useful in the systems of FIGS. 3, 7 and 11;
FIG. 14A is a diagram of unclassified vectors in associative memory arrays useful in the systems of FIGS. 3, 7 and 11;
FIG. 14B is a diagrammatic representation of a patch vector in a associative memory array useful in the systems of FIGS. 7 and 11; and
FIG. 14C is an illustration of partition and cluster vectors in an associative memory array useful in the system of FIG. 11.
It will be appreciated that for simplicity and clarity of illustration, elements shown in the figures have not necessarily been drawn to scale. For example, the dimensions of some of the elements may be exaggerated relative to other elements for clarity. Further, where considered appropriate, reference numerals may be repeated among the figures to indicate corresponding or analogous elements.
Detailed Description
In the following detailed description, numerous specific details are set forth in order to provide a thorough understanding of the present invention. However, it will be understood by those skilled in the art that the present invention may be practiced without these specific details. In other instances, well-known methods, procedures, and components have not been described in detail so as not to obscure the present invention.
Applicants have recognized that the valley metric α can be calculated from another similarity search metric, hamming distance h, and that the hamming distance h can be calculated with a simple boolean operation. Thus, molecular searches can be significantly accelerated, often by orders of magnitude.
Applicants have recognized that by clustering candidate vectors C in advance (e.g., by a k-means algorithm), as detailed below, multiple candidate vectors C may be rejected (because of dissimilarity) before they have been measured. However, in the case of the valley metric α, clustering with k-means is difficult. Applicants have recognized that using the hamming distance h to find the k-means cluster centroid is a simple boolean operation. The hamming distance h between two binary vectors of the same length is defined as the number of corresponding bit positions (where the symbols are different). Referring now to FIG. 2A, two binary vectors q and r are shown. The binary vector q has a length of 7 bits and a value 1010101. The binary vector r also has a length of 7 bits, but has a value of 1010010. It can be seen that the 3 least significant bit positions of the vector q and the vector r contain different symbols. Vector q contains symbols 101 and vector r contains symbols 010. All other bit positions contain similar symbols. Here, the hamming distance h between the vector q and the vector r is h (q, r) ═ 3. Thus, the bit positions contributing to the total hamming distance are bit positions that have dissimilar signs in the corresponding bit positions. If the symbols (1 or 0 in this case) are located in two corresponding bit positions, they have no effect on the hamming distance.
It will be understood that the boolean operator XOR is defined as an operator: when only one of the two inputs is logically true, its output is logically true, but when both inputs are logically true or logically false, its output is not logically true. This is the same logic we apply to the corresponding bits in vector q and vector r: if the symbols are different, they are added to the hamming distance h (e.g., logically true), and if they are similar, they do not affect the hamming distance h (e.g., logically false).
Referring now to FIG. 2B, a Boolean XOR function is shown along with the XOR of vector q and vector r. The boolean operator XOR is defined as the operator: when only one of the two inputs is logically true, its output is logically true, but when both inputs are logically true or logically false, its output is not logically true. The hamming distance h is a count of the number of corresponding bits that differ in sign (or in this case, bit). A boolean function that counts the occurrence of a logical true (1 in our case) in a binary vector is called a pop count. Thus, the Hamming distance h may be defined as the pop-up count of the XOR of vector q and vector r. This can be expressed as:
h(q,r)=pop(XOR(q,r)) (2)
where pop is the pop count and XOR (q, r) is the XOR of vector q and vector r.
The valley coefficient α can be expressed in terms of a hamming distance h and a pop-up count of two vectors (vector a and vector B), as follows:
where α (a, B) is the valley coefficient between vector a and vector B, pop (a) and pop (B) are the pop counts of binary vectors a and B, respectively, and h (a, B) is the hamming distance between vector a and vector B as defined in equation 2.
It should be noted that the hamming distance is a "dissimilarity" metric, meaning that the value of the hamming distance h between two compared vectors tends to go from 1 to 0 as they become more similar to each other. Conversely, since the valley coefficient is a similarity measure, the value of the valley coefficient tends to go from 0 to 1 when the two compared vectors become more similar to each other.
Applicants have recognized that the pop-up count and XOR are two very simple boolean operations that can be easily computed.
In practice, when chemists and biologists make similarity measurements, they can compare the results to threshold values. For example, when using a valley coefficient, the threshold value may be selected based on a number of factors such as sample set size and number of features. It will be appreciated that this is due to the fact that the measured hamming distance h can be relied uponmTo measure the valley coefficient alpha between two binary vectorsmThen can be based on Hamming threshold ht(which is the threshold below which the two binary vectors are considered similar) defines a trough threshold at(which is such an alpha)mThe value: above this value, the two binary vectors are considered similar).
By rearranging the terms in equation 3, the Hamming threshold htCan be represented as follows:
wherein h ist(A, B) are for two directionsHamming distance h measured between quantities (vector A and vector B)mIs calculated as a hamming threshold value, and alphat(A, B) are for the valley coefficient α measured between the same two vectors (vector A and vector B)mIs predefined valley threshold alphat。
Thus, as the applicant has appreciated, the valley metric α can be calculated from the hamming distance h and the boolean pop-up count, and the hamming distance h itself can be calculated from the boolean XOR and the pop-up count.
Reference is now made to fig. 3, which is a diagram of a preferred embodiment of a hamming-valley measurement system 20, the hamming-valley measurement system 20 including a valley to hamming threshold converter 21, a hamming measurer 22 and a hamming comparator 24. In this embodiment, Hamming-Valley measurement system 20 calculates whether candidate vector C is similar to query vector q, e.g., by a Valley threshold value αtAnd (4) defining.
The valley to Hamming threshold converter 21 converts the valley threshold alphatConversion to hamming threshold ht. The Hamming measurer 22 measures the Hamming distance h between the query vector q and the candidate vector CmAnd the hamming comparator 24 selects only such candidate vectors C: its measured Hamming distance h to the query vector qmLess than or equal to Hamming threshold ht。
Referring now to fig. 4, the elements of a valley to hamming threshold converter 21 are shown. The converter 21 comprises an ejection counter 26 and a hamming threshold calculator 27. Pop counter 26 calculates pop counts pop (q) and pop (C) for query vector q and candidate vector C, respectively. Hamming threshold calculator 27 calculates h according to equation 4t(q,C)。
Referring now to FIG. 5, the elements of Hamming measurer 22 used to implement equation 2 are shown. The measurer 22 comprises a further pop-up counter 26 and an XOR calculator 29. The XOR calculator 29 outputs the XOR of the query vector q and the candidate vector C to the pop-up counter 26. The pop counter 26 outputs a pop count of the XOR of the query vector q and the candidate vector C, which is equal to the Hamming distance h between the query vector q and the candidate vector Cm。
Returning to FIG. 3, the Hamming comparator 24Only such candidate vectors C are then selected: its measured Hamming distance hm(q,Ci) Less than or equal to Hamming threshold ht(q,Ci)。
Applicants have recognized that the Hamming threshold htIs a function of pop (q) and pop (c), and pop (q) is constant, but pop (c) may vary. Thus, system 5 may recalculate a new h for each successive query vector and candidate vector pairtThe value is obtained. This is computationally expensive.
Applicants have further recognized that by grouping all candidate vectors C having the same pop count together into chunk D, each chunk Dj may be considered to have a pop count pop (Dj) of all candidate vectors Ci contained in chunk Dj. The Hamming threshold calculator 27 may only need to calculate a Hamming threshold h for each pair of query vector q and chunk Dj according to equation 4t(q,Dj)。
Applicants have further recognized that blocking candidate vectors may use a valley metric to speed up the similarity search by allowing the entire chunk of candidate vectors to be rejected prior to measurement.
It will be understood that the minimum Hamming distance h between any two binary vectorsmIt will be when all corresponding bit positions contain similar symbols or bits. Referring now to FIG. 6A, the same vectors are shown, vector q and vector r1. In this example, a query vector q and a candidate vector r1Are identical and therefore have a hamming distance h of zerom(q,r1). It will be understood that pop (q) is equal to pop (r) only if pop (q) is equal to pop (r)1) Time, Hamming distance hm(q,r1) Zero values of (b) may occur, however, equal pop (q) and pop (r)1) The minimum Hamming distance h cannot be guaranteedm. Referring now to FIG. 6B, two vectors, vector q and vector r, are shown2. Since vector q and vector r2Do not have similar symbols in the corresponding bit positions, so the Hamming distance hm(q,r2) Is the maximum value. In this case, since the vector is a 6-bit vector, hmIs 6.
It will be appreciated that in order to get the Hamming distance hm0, then if there is a sign in any bit position of vector q, then there will be a similar sign in the corresponding bit position of vector C. Thus, for Hamming distance hmAt 0, the same number of 1's must be present in vectors q and C, in other words, they have equal pop counts. This is the case in fig. 6A. However, in FIG. 6C, vector q has a pop-up count of 3, and vector r3With an eject count of 2. In this example, there will always be at least one bit position in vector q containing a 1, while in vector r3Contains a 0 in the corresponding bit position. Hence Hamming distance hm(q,r3) And cannot be less than 1.
At vector q and vector r3The minimum hamming distance h betweenmCan be expressed as:
hmin(q,r3)=|pop(q)–pop(r3)| (5)
thus, if the difference between pop (q) and pop (dj) is greater than the defined Hamming threshold htThen none of the candidate vectors Ci in the chunk Dj may be similar to the query vector q and thus the chunk Dj may be rejected a priori.
Referring now to fig. 7, a particular embodiment of a system, here labeled 5', that implements chunking of candidate vector C is shown. In addition to the valley-to-hamming threshold converter 21, hamming measurer 22 and hamming comparator 24 of the system 5, the system 5' also includes a chunker 30, a chunker 32, and a chunker and cluster repository 23.
Chunker 30 may group all candidate vectors C into homogenous pop count chunks D. The valley to hamming threshold converter 21 may threshold the valley threshold alpha for each pair of candidate vectors q and chunks DjtConversion to hamming threshold ht. Using equation 5, chunk comparator 32 may select only those likely to contain candidate vector CiChunk Dj. For the chunk Dj selected by the chunk comparator 32, the Hamming measurer 22 may measure each candidate vector C in the current chunk DjiChinese character between the above query vector qClear distance hm. The hamming comparator 24 may select only such candidate vectors Ci: its measured Hamming distance h to the query vector qmLess than or equal to Hamming threshold ht. For all chunks Dj and all vectors C within each chunk DjiThis process is repeated.
Referring now to FIG. 8, the elements of the chunking block 30 are shown. The chunker 30 includes another pop-up counter 26 and a vector classifier 33. For chunker 30, pop counter 26 may calculate each candidate vector CiPop-up count of (pop) (C)i) And the vector classifier 33 may classify the candidate vector CiInto chunk Dj. Chunks Di and pop (Di) may be stored in chunk and cluster store 23, as shown in fig. 7.
Referring now to FIG. 9, the elements of the chunk comparator 32 are shown including another pop counter 26 and a Hamming minimum comparator 35. As discussed above, if the difference between pop (q) and pop (dj) is less than or equal to htThen chunk Dj may contain a candidate vector C similar to query vector qi. The hamming minimum comparator 35 may only select those with a hamming threshold h less than or equal totThose current chunks Dj of pop (q, Dj) of (a).
It will be appreciated that by grouping candidate vectors C with homogenous pop-up counts into chunks D, the search speed will be increased. This is due to the elimination of the same for the same pop (q) and pop (C)i) Of repeated hamming threshold h of vector pairsmThe calculation, and elimination of the measurement, of chunks D that may not contain candidate vectors C similar to the query vector q.
Applicants have recognized that of the candidate vectors C in chunk D that chunk comparator 32 may have selected for measurement, only some, but not all, of the candidate vectors C will be similar to the query vector q. Applicants have recognized that clustering candidate vector C within chunk D may further reduce the number of candidate vectors to be measured, and thus may further reduce the processing time for the search.
Reference is now made to fig. 10A, 10B and 10C, which illustrate the steps of clustering candidate vectors C within a chunk D. Fig. 10A shows a chunk Dj with a candidate vector C (a point within the two-dimensional space labeled Dj). As can be seen, candidate C are distributed through space; however, they are not evenly distributed throughout space.
Assuming that candidate C appears to be clustered within the space of fig. 10A, candidate vector C may be clustered into cluster E using a clustering algorithm (e.g., K-means or KNN (K nearest neighbors)). The clustering algorithm may place chunks Dj within moderate proximity to each cluster EkMean or centroid FkThose candidates C of (a) are grouped. As shown in fig. 10B, depending on the clustering algorithm and how to set its value, there may be a plurality of clusters Ek. Each centroid FkCan represent its cluster EkAnd may have as cluster EkRepresentative binary vector values of prototypes of candidate C within.
Fig. 10C shows how the centroid F is used to determine which clusters E may be rejected. FIG. 10C shows the query vector q to each centroid FkArrow of (c). The arrows indicate each centroid FkHamming distance h ofm(q,Fk). Note that some of the clusters E are relatively close to query q, and labeled E3Is much further away.
If Hamming distance hm(q,Fk) Greater than htThen the whole cluster EkCan be rejected due to the large hamming distance hm(q,Fk) Indicating that the entire cluster cannot contain a candidate vector C similar to the query vector qi. To ensure this is true, the clustering algorithm may require tight clustering so that only very close to centroid F is presentkThose candidates C of one of may be included in the cluster EkIn (1).
Referring now to FIG. 11, a particular embodiment of a system, here labeled 5 ", is shown that enables clustering of candidate vectors C. In addition to the chunker 30, the valley to hamming threshold converter 21, the chunk comparator 32, the hamming measurer 22, the hamming comparator 24, and the chunk and cluster repository 23, the system 5 "also includes a clusterer 36 and a cluster comparator 38. As previously described, chunker 30 may combine allCandidate vector CiSorted into homogenous pop count chunks Dj. The clusterer 36 may use a clustering algorithm as described above to cluster candidate vectors C within chunks DjiGrouping into clusters EkIn (1). The valley to hamming threshold converter 21 may convert the valley threshold alpha for each chunk DjtConversion to the appropriate hamming threshold ht。
As in the previous embodiment, chunk comparator 32 may calculate whether each chunk Dj is likely to contain a useful candidate vector CiAnd may output the index value j of the selected chunk Dj. The cluster comparator 38 may look at the selected chunk Dj and may select a candidate vector C that may contain useful candidatesiThose clusters of Ek. The cluster comparator 38 may output the selected cluster EkIndex k of (2). Hamming measurer 22 and Hamming comparator 24 can now operate on the reduced candidate vector CiOperating on the set, measuring in the selected cluster EkEach candidate vector C in (1)iAnd a hamming distance h between query vectors qmAnd the candidate vector C isiHamming measurement result h ofmAnd Hamming threshold htA comparison is made as previously described. For all selected clusters EkThis process is repeated.
Referring now to fig. 12, the elements of the cluster comparator 38 are shown including another hamming measurer 22 and another hamming comparator 24. The Hamming measurer 22 can measure the query vector q and each cluster centroid FkHamming distance h betweenm(q,Fk). The Hamming comparator 24 may compare hm(q,Fk) And ht(q,Dj) Make a comparison, and if hm(q,Fk) Is less than or equal to ht(q,Dj) Then the hamming comparator 24 may output a cluster index k.
It will be appreciated that by excluding its centroid FkClustering E dissimilar to query vector qkThe search speed will be further increased since the number of candidate vectors being measured is further reduced.
The embodiments described above may be implemented on any suitable computing device.
Applicants have recognized that Boolean functions are readily implemented on associative memory arrays in an Associative Processing Unit (APU), and may be executed in relatively few memory cycles. Further, the Boolean function may be performed in parallel across multiple (32k, 64k, 128k … …) binary vectors stored in the associative memory array columns. The boolean functions and massively parallel processing implemented on associative memories may together provide orders of magnitude increase in processing time and significant reduction in computational complexity.
Referring now to FIG. 13, there is shown a joint memory array 40 including a plurality of bit line processors 42 and a controller 43 acting on the memory array 40. The bit line processors 42 may be arranged in columns and rows in the array 40, wherein each column of the bit line processors 42 may be paired from a large number of multiple candidate vectors CiA single candidate vector C ofiOperate and wherein each row of the bit line processor 42 may be for each candidate vector CiOperates on the same bit. Each bit line processor 42 may occupy a portion 44 of the memory that may have R rows (each row containing 1-bit registers). Each register in the bit line processor may have a different function: registers 1 and 2 may be store data to be operated on (e.g., candidate vector C)iOr query vector q), while registers 3 to R may be boolean registers for boolean functions and calculations. Thus, for example, candidate vector C may be1And bit line processor 42 that stores bit 1 of query vector q in column 1, respectively1,1Registers 1 and 2; bit line processor 42 that may store bit 2 in column 11,2Registers 1 and 2; and so on.
Each 1-bit register (in each row) of each bit line processor 42 may be connected to a corresponding register in all rows by a word line 45. Word line 45 is connected to controller 43. Controller 43 may activate all corresponding registers in a row at the same time. This is the basis for massively parallel processing on associative memory array 40.
In addition, the registers in each bit line processor 42 are vertically connected together via bit lines 46. Using a combination of word lines 45 and bit lines 46, controller 43 may activate a single register or multiple registers simultaneously. When performing operations between candidate vector Ci and query q, controller 43 may simultaneously activate all rows storing each vector, thereby performing the same function on all bits of the vector at once, each operation being performed within its bit line processor. By activating multiple bit lines 46, multiple bits can be operated on in parallel.
An associated processing unit APU (not shown), which includes both bitline processor 42 and controller 43, may perform Boolean functions. For example, on memory cycle 1, controller 43 may activate a row of register 1 (store candidate vector Ci). This will cause the bit line 46 to receive the data of register 1. On cycle 2, controller 43 may activate a row of register 5 to receive data on bit line 46. At cycle 3, controller 43 may repeat the process for register 2 (which stores query vector q) and may activate register 5 to receive data on bit line 46 only if the data to be written is different from the data already stored therein. This creates a boolean XOR between the contents from register 1 and the contents from register 2. Controller 43 may perform this operation in parallel for all bits of the vector stored in the column, but may also perform this operation for all parallel columns by manipulating word lines 45 and bit lines 46.
It will be appreciated that by storing multiple vectors in parallel columns, computations and boolean functions can be performed quickly and on multiple vectors.
Applicants have recognized that the embodiments of FIGS. 3, 7, and 11 may be implemented in a consolidated memory (e.g., as described with respect to FIG. 13), and that the similarity search time may be increased by many orders of magnitude due to the massively parallel processing of the APUs of FIG. 13.
Referring now to fig. 14A, 14B and 14C, a candidate binary vector C stored in parallel columns of the associative memory 40 is shown. In the embodiment of fig. 3, a hamming distance h is measured between the candidate vector C and the query vector q. Fig. 14A shows candidate vector C stored in a column of the associative memory. The controller and the individual row and bit line processors are not shown, but in this example, each bit of candidate vector C is stored in register 1 of each bit line processor, as described above. The controller will activate all bits of candidate vector C simultaneously and also perform all computations and manipulations in parallel on the multiple candidate vectors C and query vector q.
In the embodiment of fig. 7, candidate vectors C having the same pop count are grouped into chunk D. Each chunk is then stored in a portion of memory. FIG. 14B shows how the candidate vectors are still stored in parallel columns in the associative memory, but are organized in chunk D. By manipulating the word lines and bit lines, the controller can perform massively parallel processing on block D. As mentioned previously, this reduces the number of hamming threshold calculations that need to be performed and allows the entire chunk of candidate vectors to be ignored.
In the embodiment of fig. 11, the candidate vectors in a chunk are grouped into clusters E each having a centroid F. FIG. 14C shows a cluster E of candidate vectors C within a chunk D. Again, by manipulating word lines and bit lines, controller 43 may operate on individual clusters E to increase search speed.
While certain features of the invention have been illustrated and described herein, many modifications, substitutions, changes, and equivalents will now occur to those of ordinary skill in the art. It is, therefore, to be understood that the appended claims are intended to cover all such modifications and changes as fall within the true spirit of the invention.