nmslib icon indicating copy to clipboard operation
nmslib copied to clipboard

FEATURE REQUEST: Distance metric weighting

Open cibic89 opened this issue 6 years ago • 9 comments

Is it possible to use distance metric weighting if using l1, l2, or p norm ?

cibic89 avatar Feb 22 '18 17:02 cibic89

Hi @cibic89 this requires extending a library and implementing a new "space".

searchivarius avatar Feb 22 '18 17:02 searchivarius

@searchivarius Hi, I do not find the doc about how to use space and the param of any space, where could I find the doc about space/distance method?

an example:

index = nmslib.init(method='hnsw', space='cosinesimil')
index.addDataPointBatch(data)
index.createIndex({'post': 2}, print_progress=True)

where is the info of param {post:2} ?

Thanks.

ubear avatar Feb 24 '18 06:02 ubear

Hi @ubear info on spaces is the manual (just skip all the installation stuff). It's not fully up to date, but kinda close: https://github.com/searchivarius/nmslib/blob/master/manual/manual.pdf post=0 means shortest indexing time post=1 and post=2 means some postprocessing of the index which leads to better performance, but at the expense of longer indexing.

searchivarius avatar Feb 24 '18 18:02 searchivarius

@searchivarius thanks. I have another question. if I want to use L2 space, but sort the search result by asc, how to do it ?

ubear avatar Feb 26 '18 06:02 ubear

@ubear asc? do you mean finding the farthest neighbor?

searchivarius avatar Feb 26 '18 06:02 searchivarius

@searchivarius I'm sorry that I have mistaken it. Thank very much!

ubear avatar Feb 26 '18 06:02 ubear

@ubear no worries, but I still didn't get your question :-)

searchivarius avatar Feb 26 '18 06:02 searchivarius

Well, maybe u can refer to https://arxiv.org/pdf/1405.5869.pdf about Chapter 3.3. @searchivarius

ubear avatar Feb 26 '18 08:02 ubear

@ubear we support for inner product spaces, but eventually we sort results in the order of their ascending distance, because the actual dissimilarity we use is the negative inner product. So, I still don't understand what you ask me about.

searchivarius avatar Feb 28 '18 06:02 searchivarius