You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardexpand all lines: README.md
+56-18
Original file line number
Diff line number
Diff line change
@@ -3,9 +3,12 @@ Header-only C++ HNSW implementation with python bindings. Paper's code for the H
3
3
4
4
**NEWS:**
5
5
6
-
***Thanks to Apoorv Sharma [@apoorv-sharma](https://github.com/apoorv-sharma), hnswlib now supports true element updates (the interface remained the same, but when you the perfromance/memory should not degrade as you update the element embeddinds).**
7
6
8
-
***Thanks to Dmitry [@2ooom](https://github.com/2ooom), hnswlib got a boost in performance for vector dimensions that are not mutiple of 4**
7
+
***hnswlib is now 0.5.0. Added support for pickling indices, support for PEP-517 and PEP-518 building, small speedups, bug and documentation fixes. Many thanks to [@dbespalov](https://github.com/dbespalov), [@dyashuni](https://github.com/dyashuni), [@groodt](https://github.com/groodt),[@uestc-lfs](https://github.com/uestc-lfs), [@vinnitu](https://github.com/vinnitu), [@fabiencastan](https://github.com/fabiencastan), [@JinHai-CN](https://github.com/JinHai-CN), [@js1010](https://github.com/js1010)!**
8
+
9
+
***Thanks to Apoorv Sharma [@apoorv-sharma](https://github.com/apoorv-sharma), hnswlib now supports true element updates (the interface remained the same, but when you the performance/memory should not degrade as you update the element embeddings).**
10
+
11
+
***Thanks to Dmitry [@2ooom](https://github.com/2ooom), hnswlib got a boost in performance for vector dimensions that are not multiple of 4**
9
12
10
13
***Thanks to Louis Abraham ([@louisabraham](https://github.com/louisabraham)) hnswlib can now be installed via pip!**
11
14
@@ -37,7 +40,7 @@ For other spaces use the nmslib library https://github.com/nmslib/nmslib.
37
40
#### Short API description
38
41
*`hnswlib.Index(space, dim)` creates a non-initialized index an HNSW in space `space` with integer dimension `dim`.
39
42
40
-
Index methods:
43
+
`hnswlib.Index` methods:
41
44
*`init_index(max_elements, ef_construction = 200, M = 16, random_seed = 100)` initializes the index from with no elements.
42
45
*`max_elements` defines the maximum number of elements that can be stored in the structure(can be increased/shrunk).
43
46
*`ef_construction` defines a construction time/accuracy trade-off (see [ALGO_PARAMS.md](ALGO_PARAMS.md)).
@@ -49,14 +52,14 @@ Index methods:
49
52
*`data_labels` specifies the labels for the data. If index already has the elements with the same labels, their features will be updated. Note that update procedure is slower than insertion of a new element, but more memory- and query-efficient.
50
53
* Thread-safe with other `add_items` calls, but not with `knn_query`.
51
54
52
-
*`mark_deleted(data_label)` - marks the element as deleted, so it will be ommited from search results.
55
+
*`mark_deleted(data_label)` - marks the element as deleted, so it will be omitted from search results.
53
56
54
57
*`resize_index(new_size)` - changes the maximum capacity of the index. Not thread safe with `add_items` and `knn_query`.
55
58
56
59
*`set_ef(ef)` - sets the query time accuracy/speed trade-off, defined by the `ef` parameter (
57
60
[ALGO_PARAMS.md](ALGO_PARAMS.md)). Note that the parameter is currently not saved along with the index, so you need to set it manually after loading.
58
61
59
-
*`knn_query(data, k = 1, num_threads = -1)` make a batch query for `k`closests elements for each element of the
62
+
*`knn_query(data, k = 1, num_threads = -1)` make a batch query for `k`closest elements for each element of the
60
63
*`data` (shape:`N*dim`). Returns a numpy array of (shape:`N*k`).
61
64
*`num_threads` sets the number of cpu threads to use (-1 means use default).
62
65
* Thread-safe with other `knn_query` calls, but not with `add_items`.
@@ -76,14 +79,34 @@ Index methods:
76
79
77
80
*`get_current_count()` - returns the current number of element stored in the index
78
81
79
-
80
-
82
+
Read-only properties of `hnswlib.Index` class:
83
+
84
+
*`space` - name of the space (can be one of "l2", "ip", or "cosine").
85
+
86
+
*`dim` - dimensionality of the space.
87
+
88
+
*`M` - parameter that defines the maximum number of outgoing connections in the graph.
89
+
90
+
*`ef_construction` - parameter that controls speed/accuracy trade-off during the index construction.
91
+
92
+
*`max_elements` - current capacity of the index. Equivalent to `p.get_max_elements()`.
93
+
94
+
*`element_count` - number of items in the index. Equivalent to `p.get_current_count()`.
95
+
96
+
Properties of `hnswlib.Index` that support reading and writing:
*`num_threads` - default number of threads to use in `add_items` or `knn_query`. Note that calling `p.set_num_threads(3)` is equivalent to `p.num_threads=3`.
0 commit comments