查找相似项目

来源:互联网 发布:java crontrigger 编辑:程序博客网 时间:2024/05/21 20:22

Finding similar items (including LSH)

Given a large set of text documents, find pairs that are near duplicates.

Problems:

A. Many small pieces of one document can appear out og order in another.

B. Too many documents to compare all pairs.

C. Documents are so large or so many that they cannot fit in main theory.


Locality sensitive hashing

Three steps:

1.Shingling: convert documents to sets.

(used hashing to assign each shingle an ID)

2.convert large sets to short signatures, while preserving similarity

We used similarity preserving hashing to generate signature.

We used  hashing to get around generating random permutations.

3.locality-sensitive hashing: Focus on pairs of signatures likely to be from similar documents.

We used hashing to find candidate pairs of

     similarity >=s

 

1.Shingles example:

 

Hash the singles in order to reduce the space. 

In order to find similar items(such as docs, pic.)We usually compare all of the items . So the time is vast. This is the motivation for the minhash/LSH

 

2.with the problem of 1.we:

A. Encode the set of shingles using 0/1 vectors.

B. Build the boolean matrix 

The matrix is 

 

We can finding similar columns using the following formula

 

But comparing all paris may take too much time, so hash columns(signatures) is put forward. 

C.hash the columns. The result is also called signatures.

 

Minhashing example  

 

 

 So we achieve the goal. Compressed long bit vectors into short signatures.And the note is :

 

 

3.LSH

Goal: find documents with jaccard similarity at least s. 

LSH(general idea): use a function f(x,y) that tells wether x and y is a candidate pair: a pair of elements whose similarity must be evaluated.

Method:

Split signatures into bands and hash them. Documents with similar signatures get hashed into same buckets: candidate pairs.

Here we use bands:

A. Partition M into bands.

B. Hashing the bands.

Example:

 

 

 

Assumption :  

 

the pairs in the same bucket is called candidate pair.

The method can cause the false positive and false negatives.

1.false negative

 

 

2. False positive

 

 

So there is a tradeoff:


0 0
原创粉丝点击