SimHash
In computer science, SimHash is a technique for quickly estimating how similar two sets are. The algorithm is used by the Google Crawler to find near duplicate pages. It was created by Moses Charikar. In 2021 Google announced its intent to also use the algorithm in their newly created FLoC (Federated Learning of Cohorts) system.[1]
Implementation
A hash function maps arbitrary data onto outputs of a fixed size. Hashing the same data produces the same result each time; a different hash output implies a distinct input. This, along with their fixed size, makes hashes useful for the comparison of large data. However, small differences in input data can yield significantly different hashes. Hash comparison is a binary signal (different or not), rather than a continuous similarity measure.
In contrast, SimHash creates hashes that produce similar hashes for similar input data, measured as the bitwise hamming distance between values. This means that not only do SimHashes indicate whether two inputs are different or not, but also their degree of difference, unlike other hashing functions.
The function operates by first breaking input data into a set of features. Each feature in the set is then hashed. The overall hash is defined by, for each bit within the input hashes, subtracting the count of hashes where the bit is not set (0) from the count of hashes where the bit is set (1). For indices of the hash where the difference is positive, the bit is set. For indices with a greater number of bits not set, the bit at that index in the final hash is not set.[2]
In other words, each bit of the SimHash of a datum is set if, for each hash of the set of features in that datum, the sum of bits at that index is greater than the sum of the bitwise NOT of bits at that index.
Use cases
As a result, two pieces of data with similar feature sets will have hashes that differ less than data where the sets of features diverge further. Additionally, "if the SimHash bitwise hamming distance of two phrases is low then their Jaccard coefficient is high." [3] This allows for efficiencies including more efficient sorting (by comparing objects' SimHashes, rather than the entire object) and faster discovery of similar objects by sorting a list and comparing adjacent objects rather than the O(n^2) computation of each comparison in the list.[4]
Evaluation and benchmarks
A large scale evaluation has been conducted by Google in 2006[5] to compare the performance of Minhash and Simhash[6] algorithms. In 2007 Google reported using Simhash for duplicate detection for web crawling[7] and using Minhash and LSH for Google News personalization.[8]
See also
References
- ↑ Cyphers, Bennett (2021-03-03). "Google's FLoC Is a Terrible Idea". https://www.eff.org/deeplinks/2021/03/googles-floc-terrible-idea.
- ↑ Kelcey, Mat (2009), "part 3: the simhash algorithm", brain of mat kelcey..., https://matpalm.com/resemblance/simhash/.
- ↑ Kelcey, Mat (2009), "part 3: the simhash algorithm", brain of mat kelcey..., https://matpalm.com/resemblance/simhash/.
- ↑ Kelcey, Mat (2009), "part 3: the simhash algorithm", brain of mat kelcey..., https://matpalm.com/resemblance/simhash/.
- ↑ Henzinger, Monika (2006), "Finding near-duplicate web pages: a large-scale evaluation of algorithms", Proceedings of the 29th Annual International ACM SIGIR Conference on Research and Development in Information Retrieval, pp. 284, doi:10.1145/1148170.1148222, ISBN 978-1595933690, http://infoscience.epfl.ch/record/99373.
- ↑ Charikar, Moses S. (2002), "Similarity estimation techniques from rounding algorithms", Proceedings of the 34th Annual ACM Symposium on Theory of Computing, pp. 380–388, doi:10.1145/509907.509965, ISBN 978-1581134957.
- ↑ Gurmeet Singh, Manku; Jain, Arvind; Das Sarma, Anish (2007), "Detecting near-duplicates for web crawling", Proceedings of the 16th International Conference on World Wide Web, pp. 141, doi:10.1145/1242572.1242592, ISBN 9781595936547, http://static.googleusercontent.com/media/research.google.com/en//pubs/archive/33026.pdf.
- ↑ Das, Abhinandan S. et al. (2007), "Google news personalization: scalable online collaborative filtering", Proceedings of the 16th International Conference on World Wide Web, pp. 271, doi:10.1145/1242572.1242610, ISBN 9781595936547.
External links
