In computer science, locality-sensitive hashing (LSH) is a fuzzy hashing technique that hashes similar input items into the same "buckets" with high probability.[1] (The number of buckets is much smaller than the universe of possible input items.)[1] Since similar items end up in the same buckets, this technique can be used for data clustering and nearest neighbor search. It differs from conventional hashing techniques in that hash collisions are maximized, not minimized. Alternatively, the technique can be seen as a way to reduce the dimensionality of high-dimensional data; high-dimensional input items can be reduced to low-dimensional versions while preserving relative distances between items.
Hashing-based approximate nearest-neighbor search algorithms generally use one of two main categories of hashing methods: either data-independent methods, such as locality-sensitive hashing (LSH); or data-dependent methods, such as locality-preserving hashing (LPH).[2][3]
if it satisfies the following condition. For any two points and a hash function chosen uniformly at random from :
If , then (i.e., a and b collide) with probability at least ,
If , then with probability at most .
Such a family is called -sensitive.
LSH with respect to a similarity measure
Alternatively[8] it is possible to define an LSH family on a universe of items U endowed with a similarity function . In this setting, a LSH scheme is a family of hash functionsH coupled with a probability distributionD over H such that a function chosen according to D satisfies for each .
Amplification
Given a -sensitive family , we can construct new families by either the AND-construction or OR-construction of .[1]
To create an AND-construction, we define a new family of hash functions g, where each function g is constructed from k random functions from . We then say that for a hash function , if and only if all for . Since the members of are independently chosen for any , is a -sensitive family.
To create an OR-construction, we define a new family of hash functions g, where each function g is constructed from k random functions from . We then say that for a hash function , if and only if for one or more values of i. Since the members of are independently chosen for any , is a -sensitive family.
Applications
LSH has been applied to several problem domains, including:
One of the easiest ways to construct an LSH family is by bit sampling.[7] This approach works for the Hamming distance over d-dimensional vectors . Here, the family of hash functions is simply the family of all the projections of points on one of the coordinates, i.e., , where is the th coordinate of . A random function from simply selects a random bit from the input point. This family has the following parameters: , .
That is, any two vectors with Hamming distance at most collide under a random with probability at least .
Any with Hamming distance at least collide with probability at most .
Suppose U is composed of subsets of some ground set of enumerable items S and the similarity function of interest is the Jaccard indexJ. If π is a permutation on the indices of S, for let . Each possible choice of π defines a single hash function h mapping input sets to elements of S.
Define the function family H to be the set of all such functions and let D be the uniform distribution. Given two sets the event that corresponds exactly to the event that the minimizer of π over lies inside . As h was chosen uniformly at random, and define an LSH scheme for the Jaccard index.
Because the symmetric group on n elements has size n!, choosing a truly random permutation from the full symmetric group is infeasible for even moderately sized n. Because of this fact, there has been significant work on finding a family of permutations that is "min-wise independent" — a permutation family for which each element of the domain has equal probability of being the minimum under a randomly chosen π. It has been established that a min-wise independent family of permutations is at least of size ,[19] and that this bound is tight.[20]
Because min-wise independent families are too big for practical applications, two variant notions of min-wise independence are introduced: restricted min-wise independent permutations families, and approximate min-wise independent families.
Restricted min-wise independence is the min-wise independence property restricted to certain sets of cardinality at most k.[21]
Approximate min-wise independence differs from the property by at most a fixed ε.[22]
Nilsimsa is a locality-sensitive hashing algorithm used in anti-spam efforts.[23] The goal of Nilsimsa is to generate a hash digest of an email message such that the digests of two similar messages are similar to each other. The paper suggests that the Nilsimsa satisfies three requirements:
The digest identifying each message should not vary significantly for changes that can be produced automatically.
The encoding must be robust against intentional attacks.
The encoding should support an extremely low risk of false positives.
Testing performed in the paper on a range of file types identified the Nilsimsa hash as having a significantly higher false positive rate when compared to other similarity digest schemes such as TLSH, Ssdeep and Sdhash.[24]
TLSH
TLSH is locality-sensitive hashing algorithm designed for a range of security and digital forensic applications.[17] The goal of TLSH is to generate hash digests for messages such that low distances between digests indicate that their corresponding messages are likely to be similar.
The random projection method of LSH due to Moses Charikar[8] called SimHash (also sometimes called arccos[26]) uses an approximation of the cosine distance between vectors. The technique was used to approximate the NP-complete max-cut problem.[8]
The basic idea of this technique is to choose a random hyperplane (defined by a normal unit vector r) at the outset and use the hyperplane to hash input vectors.
Given an input vector v and a hyperplane defined by r, we let . That is, depending on which side of the hyperplane v lies. This way, each possible choice of a random hyperplane r can be interpreted as a hash function .
For two vectors u,v with angle between them, it can be shown that
Since the ratio between and is at least 0.87856 when ,[8][27] the probability of two vectors being on the same side of the random hyperplane is approximately proportional to the cosine distance between them.
Stable distributions
The hash function
[28] maps a d-dimensional vector
onto the set of integers. Each hash function
in the family is indexed by a choice of random and
where is a d-dimensional
vector with
entries chosen independently from a stable distribution and
is
a real number chosen uniformly from the range [0,r]. For a fixed
the hash function is
given by .
Other construction methods for hash functions have been proposed to better fit the data.
[29]
In particular k-means hash functions are better in practice than projection-based hash functions, but without any theoretical guarantee.
One of the main applications of LSH is to provide a method for efficient approximate nearest neighbor search algorithms. Consider an LSH family . The algorithm has two main parameters: the width parameter k and the number of hash tables L.
In the first step, we define a new family of hash functions g, where each function g is obtained by concatenating k functions from , i.e., . In other words, a random hash function g is obtained by concatenating k randomly chosen hash functions from . The algorithm then constructs L hash tables, each corresponding to a different randomly chosen hash function g.
In the preprocessing step we hash all nd-dimensional points from the data set S into each of the L hash tables. Given that the resulting hash tables have only n non-zero entries, one can reduce the amount of memory used per each hash table to using standard hash functions.
Given a query point q, the algorithm iterates over the L hash functions g. For each g considered, it retrieves the data points that are hashed into the same bucket as q. The process is stopped as soon as a point within distance cR from q is found.
Given the parameters k and L, the algorithm has the following performance guarantees:
preprocessing time: , where t is the time to evaluate a function on an input point p;
space: , plus the space for storing data points;
query time: ;
the algorithm succeeds in finding a point within distance cR from q (if there exists a point within distance R) with probability at least ;
For a fixed approximation ratio and probabilities and , one can set and , where . Then one obtains the following performance guarantees:
preprocessing time: ;
space: , plus the space for storing data points;
query time: ;
Improvements
When t is large, it is possible to reduce the hashing time from .
This was shown by[31] and[32] which gave
query time: ;
space: ;
It is also sometimes the case that the factor can be very large.
This happens for example with Jaccard similarity data, where even the most similar neighbor often has a quite low Jaccard similarity with the query.
In[33] it was shown how to reduce the query time to (not including hashing costs) and similarly the space usage.
See also
Bloom filter – Data structure for approximate set membership
Curse of dimensionality – Difficulties arising when analyzing data with many aspects ("dimensions")
Feature hashing – Vectorizing features using a hash function
^
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–280, doi:10.1145/1242572.1242610, ISBN9781595936547, S2CID207163129.
^
Koga, Hisashi; Tetsuo Ishibashi; Toshinori Watanabe (2007), "Fast agglomerative hierarchical clustering algorithm using Locality-Sensitive Hashing", Knowledge and Information Systems, 12 (1): 25–53, doi:10.1007/s10115-006-0027-5, S2CID4613827.
^
Aluç, Güneş; Özsu, M. Tamer; Daudjee, Khuzaima (2018), "Building self-clustering RDF databases using Tunable-LSH", The VLDB Journal, 28 (2): 173–195, doi:10.1007/s00778-018-0530-9, S2CID53695535
^Chen, Beidi; Medini, Tharun; Farwell, James; Gobriel, Sameh; Tai, Charlie; Shrivastava, Anshumali (2020-02-29). "SLIDE : In Defense of Smart Algorithms over Hardware Acceleration for Large-Scale Deep Learning Systems". arXiv:1903.03129 [cs.DC].
^Ahle, Thomas Dybdahl. "On the Problem of in Locality-Sensitive Hashing." International Conference on Similarity Search and Applications. Springer, Cham, 2020.
^Gorman, James, and James R. Curran. "Scaling distributional similarity to large corpora." Proceedings of the 21st International Conference on Computational Linguistics and the 44th annual meeting of the Association for Computational Linguistics. Association for Computational Linguistics, 2006.
Further reading
Samet, H. (2006) Foundations of Multidimensional and Metric Data Structures. Morgan Kaufmann. ISBN0-12-369446-9
Caltech Large Scale Image Search Toolbox: a Matlab toolbox implementing several LSH hash functions, in addition to Kd-Trees, Hierarchical K-Means, and Inverted File search algorithms.
Compagnie des Transports en commun de Neuchâtel et environsTrade nameTransports Publics du Littoral NeuchâteloisIndustryTransportDefunct2012 (2012)SuccessorTransports publics NeuchâteloisHeadquartersNeuchâtel, SwitzerlandArea servedNeuchâtel The Compagnie des Transports en commun de Neuchâtel et environs (TN) was a public transport operator in and around the Swiss city of Neuchâtel. It operated the city's network of trams, trolleybuses and motor buses, under the marketing name Tra...
Game and anime television series Puzzle & Dragons XPuzzle & Dragons X key visualパズドラクロス(Pazudora Kurosu)GenreAdventure, fantasy[1] Anime television seriesDirected byHajime KamegakiProduced byNobuyuki HosoyaShuichi FujimuraMasashi MatsuiTetsuya EndoWritten byDai SatōStory RidersMusic byKousuke YamashitaStudioPierrotLicensed byNA: FunimationOriginal networkTV Tokyo, TVA, BS JapanOriginal run July 4, 2016 – March 26, 2018Episodes89 (List ...
Perang FalklandBagian dari Perang DinginHMS Conqueror pulang setelah berjaya.Tanggal2 April – 14 Juni 1982LokasiKepulauan Falkland, Pulau Georgia Selatan dan Kepulauan Sandwich SelatanHasil Kemenangan Britania RayaPihak terlibat Britania Raya Kepulauan Falkland ArgentinaTokoh dan pemimpin Margaret ThatcherTerence LewinHenry LeachJohn FieldhouseSandy WoodwardJeremy MooreMichael ClappJulian ThompsonTony Wilson Leopoldo GaltieriJorge AnayaBasilio Lami DozoJuan LombardoErnesto ...
Kedutaan Besar Republik Indonesia di MadridEmbajada de la República de Indonesia en MadridKoordinat40°26′55″N 3°39′13″W / 40.448519°N 3.653657°W / 40.448519; -3.653657Lokasi Madrid, SpanyolAlamatCalle de Agastia, 6528043 Madrid, SpanyolDuta BesarMuhammad NajibSitus webkemlu.go.id/madrid/id Kedutaan Besar Republik Indonesia di Madrid (KBRI Madrid) (Spanyol: Embajada de la República de Indonesia en Madrid) adalah misi diplomatik Indonesia untuk Kerajaan...
1809 battle of the War of the Fifth Coalition Battle of EbelsbergPart of the War of the Fifth CoalitionBattle of Ebelsberg by Dietrich Monten, 1825Date3 May 1809[1]Locationnear Linz, Austria48°18′11″N 14°17′26″E / 48.30306°N 14.29056°E / 48.30306; 14.29056Result French victoryBelligerents Austrian Empire French EmpireCommanders and leaders Johann von Hiller André MassénaStrength 22,000-30,000,[1] 70 guns 22,100-30,000,[1 ...
The Gibraltar team lining up before the 2013 match against Slovakia, their first official match as a UEFA member. The Gibraltar national football team is the representative association football team of Gibraltar, a British Overseas Territory located at the southern tip of the Iberian Peninsula. Its governing body is the Gibraltar Football Association (GFA) and it competes as a member of the Union of European Football Associations (UEFA). Organised football has been played in Gibraltar since t...
American neo-Western crime drama television series JustifiedGenreNeo-WesternActionCrimeDramaBased onFire in the Holeby Elmore LeonardDeveloped byGraham YostStarring Timothy Olyphant Nick Searcy Jacob Pitts Erica Tazel Joelle Carter Natalie Zea Walton Goggins Jere Burns Opening themeLong Hard Times to Come by GangstagrassComposerSteve PorcaroCountry of originUnited StatesOriginal languageEnglishNo. of seasons6No. of episodes78 (list of episodes)ProductionExecutive producersElmore LeonardGraham...
U.S. House district for Texas TX-23 redirects here. The term may also refer to Texas State Highway 23. Not to be confused with Texas's 23rd House of Representatives district. Texas's 23rd congressional districtTexas's 23rd congressional district since January 3, 2023Representative Tony GonzalesR–San AntonioDistribution78.09% urban[1]21.91% ruralPopulation (2022)778,355[2]Median householdincome$71,327[2]Ethnicity68.34% Hispanic24.92% White3.85% Black1.6% Asian1....
British sci-fi character, created 1977 This article is about the Doctor Who character. For the television series, see K9 (TV series). For other uses, see K9 (disambiguation). Fictional character K9Doctor Who characterThe original K9 prop from 1977First appearanceThe Invisible Enemy (1977)Last appearanceGoodbye, Sarah Jane Smith (2010)Created byBob BakerDave MartinVoiced byJohn Leeson (1977–1979, 1980–2010)David Brierley (1979–1980)Roy Skelton (1979; uncredited)Shared universe appearance...
أماكساديس خريطة الموقع تقسيم إداري البلد اليونان [1] التقسيم الأعلى ياسموس خصائص جغرافية إحداثيات 41°07′28″N 25°03′58″E / 41.1245°N 25.066°E / 41.1245; 25.066 الارتفاع 52 متر السكان التعداد السكاني 1195 (إحصاء السكان) (2011)[2] معلومات أخرى التوقيت ت ع م+02:00 (ت�...
Indian educational company FIITJEE: Forum For Indian Institute of Technology Joint Entrance ExaminationFormation1992FounderDK GoelTypeCoaching instituteHeadquartersFIITJEE House, 29-A, Kalu Sarai, Sarvyapriya Vihar, New Delhi, IndiaRegion served IndiaServicesCoaching institute for IIT-JEE and various engineering entrance examinationKey peopleDinesh Goel (Founder)Staff 3,200+Websitefiitjee.com FIITJEE is a coaching institute for JEE and other competitive exams founded by Dinesh Kumar Goel. It ...
The Holy WarWisła Kraków supporters displaying banner Army of the White Star, 2011LocationKrakówTeamsWisła KrakówKS CracoviaFirst meeting20 September 1908StatisticsMost winsWisła Kraków (85-60-42) The Holy War (Polish: Święta Wojna, also Derby Krakowa) is a rivalry in Polish football between Wisła Kraków and KS Cracovia, the two biggest clubs in Kraków and reportedly the oldest in Poland, both founded in 1906.[1] The term Holy War was coined by the defender from KS Cracovi...
Mesopotamian god For the family name, see Haddad. For other uses, see Hadad (disambiguation). Adad, Ishkur, and Ramman redirect here. For other uses, see Ishkur's Guide to Electronic Music, Ramman (festival), and Ram-Man. This article includes a list of general references, but it lacks sufficient corresponding inline citations. Please help to improve this article by introducing more precise citations. (August 2010) (Learn how and when to remove this template message) HadadGod of Weather, Hurr...
Public technical university in Uttar Pradesh, India Indian Institute of Technology (BHU) Varanasiभारतीय प्रौद्योगिकी संस्थान (का.हि.वि.) वाराणसीSeal of the IIT-BHUFormer namesBanaras Engineering College (BENCO) (1919) College of Mining and Metallurgy (MINMET) (1923) College of Technology (TECHNO) (1932) Institute of Technology (IT-BHU) (1968)Mottoसंस्कार ही शिक्षाMotto in EnglishEduc...
This article has multiple issues. Please help improve it or discuss these issues on the talk page. (Learn how and when to remove these template messages) This article relies largely or entirely on a single source. Relevant discussion may be found on the talk page. Please help improve this article by introducing citations to additional sources.Find sources: Matrilineal succession – news · newspapers · books · scholar · JSTOR (December 2016) This article...
1983 single by Malcolm XNo Sell OutSingle by Malcolm XB-sideNo Sell Out (instrumental ver.)ReleasedNovember 14, 1983 (1983-11-14)[1]RecordedSweet Mountain Studio, Englewood, NJGenreHip hop, electroLength5:44LabelTommy BoySongwriter(s)Keith LeBlanc and Malcolm X[2]Producer(s)Keith LeBlancKeith LeBlanc singles chronology No Sell Out (1983) 'Support the Miners' (1984) No Sell Out is a hip hop piece composed by American drummer Keith LeBlanc and credited to Malc...
Overview of the role of Buddhism in Italy Peace pagoda in Comiso Buddhism in Italy is the third most spread religion, next to Christianity and Islam. According to Caritas Italiana, in the country there are 160,000 Buddhists,[1] that is to say the 0.3% of the total population. History According to some sources, Buddhism might have been practised in Italy, although marginally, already in Ancient Rome,[2] likely disappeared with the persecution of pagans in the late Roman Empire....