• Aucun résultat trouvé

Query-Adaptative Locality Sensitive Hashing

N/A
N/A
Protected

Academic year: 2022

Partager "Query-Adaptative Locality Sensitive Hashing"

Copied!
19
0
0

Texte intégral

(1)

Query-Adaptative Locality Sensitive Hashing

Hervé Jégou, INRIA/LJK Laurent Amsaleg, CNRS/IRISA Cordelia Schmid, INRIA/LJK Patrick Gros, INRIA/IRISA

ICASSP’2008

April 4

th

2008

(2)

Problem setup

We want to find the (k-)nearest neighbor(s) of a given query vector

→ without computing all distances!

Curse of the dimensionality

• exact search inefficient

→ approximate nearest neighbor

dataset: n d-dimensional vectors

query

x i q

i = 1 ::n; x i = ( x 1 ; : : : ; x d )

q = ( q 1 ; : : : ; q d )

(3)

Application : large-scale (= 1 million) image search

State-of-the-art for image search:

• local description ≈ 2000 local descriptors per image

• SIFT descriptors [Lowe 04]: d=128, Euclidean unitary vectors

INTENSIVE USE OF NEAREST NEIGHBOR SEARCH

Image search system

ranked image list Image

dataset

query

(4)

Approximate nearest neighbor (ANN) search

Many existing approaches

• very popular one: Locality Sensitive Hashing (LSH)

→ provides some guarantees on the search quality for some distributions

LSH: many variants, e.g.,

• for the Hamming space [Gionis, Indyk, Motwani, 99]

• Euclidean version [Datar, Indyk, Immorlica, Mirrokni, 04] → E2LSH

• using Leech lattice quantization [Andoni, Indyk, 06]

• spherical LSH [Terasawa, Tanaka, 07]

and applications: computer vision [Shakhnarovich & al, 05], music search [Casey, Slaney, 07], etc

(5)

Euclidean Locality Sensitive Hashing (E2LSH)

1) Projection on m random directions

2) Construction of l hash functions:

concatenate k indexes hi per hash function

3) For each gj, compute two hash values universal hash functions: u1(.), u2(.)

store the vector id in a hash table

h

i

(x ) = b h

ri

(x) c h r i (x ) = hxja w

i

i¡b

i

g

j

(x ) = ( h

j;1

(x); : : : ; h

j;k(x)

)

(1,0) (2,0) (3,0) (0,0)

(3,1) (2,1)

(1,1) (0,1)

(0,-1) (1,-1) (2,-1)

b

i

0 1

1

1

1 2

2

2

w

O

a

1

(6)

Search: algorithm summary and complexity

• For all hi, compute hi(q) O(m d)

• For j = 1..l, compute gj(q) and hash values u1(gj(q)) and u2(gj(q)) O(l k)

• For j = 1..l, retrieve the vectors id having the same hash keys O(l  n)

• proportion  of the dataset vectors, i.e. *n vectors

• Exact distance computation between query and retrieved vectors O(ln d)

Large dataset ⇒ step 4 is by far the most computationally intensive

Performance measure: rate of correct nearest neighbors found vs average short-list size

(7)

Geometric hash function: the lattice choice

[Andoni Indyk 06]

Motivation: instead of using

and in turn hash functions as

Why not directly using a structured vector quantizer?

• spheres would be the best choice (but no such space partitioning) Well-know lattice quantizers: Hexagonal (d=2), E8 (d=8), Leech (d=24)

h

i

: R

d

! Z

g

j

(x ) = ¡

h

j;1

(x); : : : ; h

j;k(x)

¢

(8)

LSH using Lattice

Several lattices or concatenation of lattices are used for geometric hashing

bj is now a vectorial random offset

xi,j,d’ is formed of d* components of x (≠ for each gj)

Previous work by Andoni and Indyk makes use of the Leech lattice (d*=24)

• very good quantization properties

d* = 24, 48, …

Here, we use the E8 lattice

• very fast computation together with excellent quantization properties

d* = 8, 16, 24, …

g

j

(x ) = lattice-idx( x

i;j;d¤

¡ b

j

)

(9)

Hash function selection criterion: motivation

Let consider several hash functions and corresponding space partitioning

The position of the query within the cell has a strong impact on the probability that vectors which are close are in the same cell or not

HASH FUNCTION RELEVANCE CRITERION 

j: the distance to the cell center in the projected k-dimensional subspace

= root square of the square Euclidean error in a quantization context

(10)

Hash function relevance criterion: E2LSH or lattice-based

E2LSH: Recall that

square of the relevance criterion = quantization error in the projected space

For lattice-based LSH, distance between query and lattice point Remark for E8: 

j requires no extra-computation

→ byproduct of the lattice point calculation

h

i

(x ) = b h

ri

(x) c h r i (x ) = hxja w

i

i¡b

i

¸

j

(x)

2

= X

i=1::k

¡ h

rj;i

(x) ¡ h

i

(x) ¡ 0:5 ¢

2

(11)

Relevance criterion: impact on quality (SIFT descriptors)

 closer to 0: much higher confidence in the vectors retrieved

0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1

0 0.25 0.5 0.75 1.0 1.25

p

1.5

¸(g

j

(x)) k=2

P ( g

j

( N N ( x )) = g

j

( x ) j ¸ ( g

j

( x ))

(12)

Query adaptative LSH: exploiting the criterion

Idea:

• define a larger pool of l hash functions

• use only for the most relevant ones

Search is modified as follows

• for j = 1..l, compute criterion 

j

• select the l’ (<< l) hash functions associated with the lowest values of 

j

Perform the final steps as in standard LSH, using the hash function subset only

• compute u1 and u2 and parse the corresponding buckets

• compute the exact distances between query and vectors retrieved from buckets

l=3, l’=1

(13)

Query adaptative LSH: exploiting the criterion

Idea:

• define a larger pool of l hash functions

• use only for the most relevant ones

Search is modified as follows

• for j = 1..l, compute criterion 

j

• select the l’ (<< l) hash functions associated with the lowest values of 

j

Perform the final steps as in standard LSH, using the hash function subset only

• compute u1 and u2 and parse the corresponding buckets

• compute the exact distances between query and vectors retrieved from buckets

l=3, l’=1

(14)

Results: SIFT descriptors

Proj-QALSH Proj-LSH

E8-QALSH E8-LSH

0 0.2 0.4 0.6 0.8 1

0.001 0.01 0.1 1

rate of nearest neighbors correctly found

% of the database retrieved

(15)

Conclusion

Using E8 Lattice for LSH provides

• excellent quantization properties

• high flexibility for d*

QALSH trades memory against accuracy

→ without noticably increasing search complexity for large datasets

This a quite generic approach: can be jointly used with other versions of LSH

• binary or spherical LSH

(16)

Thank you for your attention!

?

(17)

Brute force search of optimal parameters

0 0.2 0.4 0.6 0.8 1

0.001 0.01 0.1 1

rate of nearest neighbors correctly found

% of the database retrieved E8 LSH

LSH QALSH

0 0.2 0.4 0.6 0.8 1

0.001 0.01 0.1 1

rate of nearest neighbors correctly found

% of the database retrieved Random projection LSH

QALSHLSH

(18)

p.d.f. of the relevance criterion

(19)

Euclidean Locality Sensitive Hashing (E2LSH)

1) Projection on m random directions

2) Construction of l hash functions:

concatenate k indexes hi per hash function

3) For each gj, compute two hash values universal hash functions: u1(.), u2(.)

store the vector id in a hash table

h

i

(x ) = b h

ri

(x) c h r i (x ) = hxja w

i

i¡b

i

0 1

1

1

1 2

2

2

b i

w

O

a 1

(1,0) (2,0) (3,0)

(0,0)

(3,1) (2,1)

(1,1) (0,1)

(0,-1) (1,-1) (2,-1)

g

j

(x ) = ( h

j;1

(x); : : : ; h

j;k(x)

)

Références

Documents relatifs

Keywords— Fisher vector, vector of locally aggregated descrip- tors, log-Euclidean metric, covariance matrices, SIFT descriptors, deep neural network, classification..

We propose using the E 8 lattice instead, which offers excellent quantization properties together with a low decoding cost, as shown in subsection 2.2. For each hash function

To address these limitations, we design a novel algorithm, PQ Fast Scan, that transforms the cache- resident lookup tables into small tables, sized to fit SIMD registers..

Unité de recherche INRIA Rhône-Alpes : 655, avenue de l’Europe - 38334 Montbonnot Saint-Ismier (France) Unité de recherche INRIA Rocquencourt : Domaine de Voluceau - Rocquencourt -

The IVFADC method is parametrized by the shortlist size R used for re-ranking the vector with the L2 distance, and the two parameters w and k 0 of the inverted file, which correspond

In the model we analyze, unrated items are estimated by averaging ratings of users who are “similar” to the user we would like to ad- vise.. The similarity is assessed by a

The most time-consuming step of all frequent itemset mining algorithms is to decide the frequency of itemsets, i.e., whether an itemset is supported by at least a certain number

In our study, we compared the performance of simple voting KNN and distance weighted KNN using both euclidean distance and cosine similarity, with another cost sensitive KNN, de-