Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Fixing standalone examples #335
  • Loading branch information
searchivairus committed Jul 20, 2018
1 parent 63511ee commit b133329
Show file tree
Hide file tree
Showing 5 changed files with 71 additions and 13 deletions.
2 changes: 1 addition & 1 deletion README.md
Expand Up @@ -19,7 +19,7 @@ Other contributors: Lawrence Cayton, Wei Dong, Avrelin Nikita, Dmitry Yashunin,

**Citing:** If you find this library useful, feel free to cite our SISAP paper [**[BibTex]**](http://dblp.uni-trier.de/rec/bibtex/conf/sisap/BoytsovN13) as well as other papers listed in the end. One crucial contribution to cite is the fast Hierarchical Navigable World graph (HNSW) method [**[BibTex]**](https://dblp.uni-trier.de/rec/bibtex/journals/corr/MalkovY16).

Leo(nid) Boytsov is a maintainer. Leo is supported by the [Open Advancement of Question Answering Systems (OAQA) group](https://github.com/oaqa) and the following NSF grant #1618159: "[Matching and Ranking via Proximity Graphs: Applications to Question Answering and Beyond](https://www.nsf.gov/awardsearch/showAward?AWD_ID=1618159&HistoricalAwards=false)". Bileg was supported by the [iAd Center](https://web.archive.org/web/20160306011711/http://www.iad-center.com/).
Leo(nid) Boytsov is a maintainer. Leo was supported by the [Open Advancement of Question Answering Systems (OAQA) group](https://github.com/oaqa) and the following NSF grant #1618159: "[Matching and Ranking via Proximity Graphs: Applications to Question Answering and Beyond](https://www.nsf.gov/awardsearch/showAward?AWD_ID=1618159&HistoricalAwards=false)". Bileg was supported by the [iAd Center](https://web.archive.org/web/20160306011711/http://www.iad-center.com/).

**Should you decide to modify the library (and, perhaps, create a pull request), please, use the [develoment branch](https://github.com/nmslib/nmslib/tree/develop)**. For generic questions/inquiries, please, use Gitter (see the badge above). Bug reports should be submitted as GitHub issues.

Expand Down
64 changes: 58 additions & 6 deletions python_bindings/notebooks/search_sparse_cosine.ipynb
Expand Up @@ -105,7 +105,9 @@
{
"cell_type": "code",
"execution_count": 6,
"metadata": {},
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"# Set index parameters\n",
Expand Down Expand Up @@ -160,8 +162,8 @@
"name": "stdout",
"output_type": "stream",
"text": [
"Index-time parameters {'indexThreadQty': 4, 'post': 0, 'M': 30, 'efConstruction': 100}\n",
"Indexing time = 16.409487\n"
"Index-time parameters {'efConstruction': 100, 'indexThreadQty': 4, 'M': 30, 'post': 0}\n",
"Indexing time = 7.880086\n"
]
}
],
Expand Down Expand Up @@ -204,7 +206,7 @@
"name": "stdout",
"output_type": "stream",
"text": [
"kNN time total=2.378762 (sec), per query=0.004758 (sec), per query adjusted for thread number=0.019030 (sec)\n"
"kNN time total=0.895622 (sec), per query=0.001791 (sec), per query adjusted for thread number=0.007165 (sec)\n"
]
}
],
Expand All @@ -218,6 +220,56 @@
" (end-start, float(end-start)/query_qty, num_threads*float(end-start)/query_qty)) "
]
},
{
"cell_type": "code",
"execution_count": 14,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"(array([3286, 1842, 1100, 3986, 1306, 738, 1610, 2314, 3452, 3857, 2502,\n",
" 3318, 2101, 342, 1283, 3996, 1372, 4143, 4351, 4391, 2830, 597,\n",
" 2909, 2725, 3166, 2126, 470, 1853, 1179, 846, 2945, 3169, 663,\n",
" 4159, 152, 4493, 3933, 1722, 3328, 2549, 3026, 1555, 4121, 3301,\n",
" 1544, 80, 3051, 3021, 3476, 285, 3237, 4229, 1717, 3296, 1751,\n",
" 1580, 276, 414, 1429, 3521, 1047, 3589, 2594, 135, 2630, 1888,\n",
" 3716, 77, 2084, 2672, 1382, 3673, 3410, 346, 178, 2669, 3084,\n",
" 4451, 1326, 2252, 352, 857, 3436, 2728, 1492, 4434, 4481, 2608,\n",
" 3036, 3261, 776, 1728, 3002, 639, 207, 3524, 3660, 1299, 2155,\n",
" 621], dtype=int32),\n",
" array([0.8992085 , 0.91679084, 0.92188805, 0.92216325, 0.9252443 ,\n",
" 0.92593366, 0.92699254, 0.9270664 , 0.9273616 , 0.92750293,\n",
" 0.92814606, 0.92821515, 0.9283294 , 0.9285394 , 0.9288384 ,\n",
" 0.9300575 , 0.9302731 , 0.9303532 , 0.9307519 , 0.9307837 ,\n",
" 0.9312843 , 0.93236256, 0.9334375 , 0.9341124 , 0.9342348 ,\n",
" 0.93441284, 0.9352284 , 0.9355068 , 0.93568337, 0.93570966,\n",
" 0.93624324, 0.9366741 , 0.9367511 , 0.9369517 , 0.937425 ,\n",
" 0.9375497 , 0.93755674, 0.9382414 , 0.9383088 , 0.9385568 ,\n",
" 0.9392182 , 0.9395664 , 0.93977386, 0.9400221 , 0.9401452 ,\n",
" 0.94024456, 0.9404075 , 0.94044054, 0.94111145, 0.9413601 ,\n",
" 0.94136894, 0.9414181 , 0.9415044 , 0.94155735, 0.9416793 ,\n",
" 0.94186294, 0.9419466 , 0.9420507 , 0.942109 , 0.9422395 ,\n",
" 0.94345766, 0.9439351 , 0.9448485 , 0.94510096, 0.94514424,\n",
" 0.9454838 , 0.9455471 , 0.9455797 , 0.9455871 , 0.9459824 ,\n",
" 0.94622993, 0.9464909 , 0.94653654, 0.9465798 , 0.94671726,\n",
" 0.9467379 , 0.9468312 , 0.9469833 , 0.94807124, 0.9482827 ,\n",
" 0.9483958 , 0.94864804, 0.9490715 , 0.94914687, 0.9492137 ,\n",
" 0.94924515, 0.94926417, 0.949486 , 0.95013225, 0.9503755 ,\n",
" 0.950492 , 0.9505498 , 0.9505967 , 0.95077056, 0.9507993 ,\n",
" 0.950863 , 0.9509655 , 0.95128053, 0.9514849 , 0.95162797],\n",
" dtype=float32))"
]
},
"execution_count": 14,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"nbrs[0]"
]
},
{
"cell_type": "code",
"execution_count": 12,
Expand All @@ -228,8 +280,8 @@
"output_type": "stream",
"text": [
"Computing gold-standard data\n",
"Brute-force preparation time 0.058578\n",
"brute-force kNN time total=2.372437 (sec), per query=0.004745 (sec)\n"
"Brute-force preparation time 0.018111\n",
"brute-force kNN time total=0.655375 (sec), per query=0.001311 (sec)\n"
]
}
],
Expand Down
6 changes: 6 additions & 0 deletions sample_standalone_app/README.md
@@ -0,0 +1,6 @@
This works only if the library is compiled without extras. Just type make. Then you can run tests like this:
```
./sample_standalone_app1 ../sample_data/sift_10k.txt
./sample_standalone_app2 l2 ../sample_data/sift_10k.txt ../sample_data/final128_10K.txt
```
8 changes: 4 additions & 4 deletions sample_standalone_app/sample_standalone_app1.cc
Expand Up @@ -177,11 +177,11 @@ int main(int argc, char* argv[]) {
AnyParams IndexParams(
{
"NN=11",
"initIndexAttempts=3",
"efConstruction=50",
"indexThreadQty=4" /* 4 indexing threads */
});

AnyParams QueryTimeParams( { "initSearchAttempts=3" });
AnyParams QueryTimeParams( { "efSearch=50" });

Index<float>* indexSmallWorld =
MethodFactoryRegistry<float>::Instance().
Expand Down Expand Up @@ -246,10 +246,10 @@ int main(int argc, char* argv[]) {
KNNQuery<float> knnQ(customSpace, queryObj, K);

cout << "Setting one value of a query-time param (small world)" << endl;
indexSmallWorld->SetQueryTimeParams(AnyParams({ "initSearchAttempts=3" }));
indexSmallWorld->SetQueryTimeParams(AnyParams({ "efSearch=100" }));
doSearch(indexSmallWorld, &knnQ, REP_QTY);
cout << "Setting one value of a query-time param (small world)" << endl;
indexSmallWorld->SetQueryTimeParams(AnyParams({ "initSearchAttempts=1" }));
indexSmallWorld->SetQueryTimeParams(AnyParams({ "efSearch=50" }));
doSearch(indexSmallWorld, &knnQ, REP_QTY);

doSearch(indexVPTree, &knnQ, REP_QTY);
Expand Down
4 changes: 2 additions & 2 deletions sample_standalone_app/sample_standalone_app2.cc
Expand Up @@ -114,14 +114,14 @@ int main(int argc, char* argv[]) {
AnyParams IndexParams(
{
"NN=17",
"initIndexAttempts=3",
"efConstruction=50",
"indexThreadQty=4", /* 4 indexing threads */
}
);

AnyParams QueryTimeParams(
{
"initSearchAttempts=1",
"efSearch=50",
}
);

Expand Down

0 comments on commit b133329

Please sign in to comment.