Skip to content

Commit 8a295df

Browse files
authored
Merge pull request #289 from TakaakiFuruse/fix-add_item-doc-description
Improved description of `add_items`
2 parents cc2b94f + af284e6 commit 8a295df

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

README.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -41,18 +41,18 @@ For other spaces use the nmslib library https://github.com/nmslib/nmslib.
4141
* `hnswlib.Index(space, dim)` creates a non-initialized index an HNSW in space `space` with integer dimension `dim`.
4242

4343
`hnswlib.Index` methods:
44-
* `init_index(max_elements, ef_construction = 200, M = 16, random_seed = 100)` initializes the index from with no elements.
44+
* `init_index(max_elements, M = 16, ef_construction = 200, random_seed = 100)` initializes the index from with no elements.
4545
* `max_elements` defines the maximum number of elements that can be stored in the structure(can be increased/shrunk).
4646
* `ef_construction` defines a construction time/accuracy trade-off (see [ALGO_PARAMS.md](ALGO_PARAMS.md)).
4747
* `M` defines tha maximum number of outgoing connections in the graph ([ALGO_PARAMS.md](ALGO_PARAMS.md)).
4848

49-
* `add_items(data, data_labels, num_threads = -1)` - inserts the `data`(numpy array of vectors, shape:`N*dim`) into the structure.
50-
* `labels` is an optional N-size numpy array of integer labels for all elements in `data`.
49+
* `add_items(data, ids, num_threads = -1)` - inserts the `data`(numpy array of vectors, shape:`N*dim`) into the structure.
5150
* `num_threads` sets the number of cpu threads to use (-1 means use default).
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.
51+
* `ids` are optional N-size numpy array of integer labels for all elements in `data`.
52+
- 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.
5353
* Thread-safe with other `add_items` calls, but not with `knn_query`.
5454

55-
* `mark_deleted(data_label)` - marks the element as deleted, so it will be omitted from search results.
55+
* `mark_deleted(label)` - marks the element as deleted, so it will be omitted from search results.
5656

5757
* `resize_index(new_size)` - changes the maximum capacity of the index. Not thread safe with `add_items` and `knn_query`.
5858

@@ -113,7 +113,7 @@ num_elements = 10000
113113

114114
# Generating sample data
115115
data = np.float32(np.random.random((num_elements, dim)))
116-
data_labels = np.arange(num_elements)
116+
ids = np.arange(num_elements)
117117

118118
# Declaring index
119119
p = hnswlib.Index(space = 'l2', dim = dim) # possible options are l2, cosine or ip
@@ -122,7 +122,7 @@ p = hnswlib.Index(space = 'l2', dim = dim) # possible options are l2, cosine or
122122
p.init_index(max_elements = num_elements, ef_construction = 200, M = 16)
123123

124124
# Element insertion (can be called several times):
125-
p.add_items(data, data_labels)
125+
p.add_items(data, ids)
126126

127127
# Controlling the recall by setting ef:
128128
p.set_ef(50) # ef should always be > k

0 commit comments

Comments
 (0)