Skip to content

Commit 091b180

Browse files
author
Charlotte Gerhaher
authored
docs: change cosine similarity to distance for hnswlib doc index (#1476)
Signed-off-by: anna-charlotte <charlotte.gerhaher@jina.ai>
1 parent d497cba commit 091b180

1 file changed

Lines changed: 13 additions & 10 deletions

File tree

docs/user_guide/storing/index_hnswlib.md

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -123,16 +123,19 @@ In the example above you can see how to configure two different vector fields, w
123123

124124
In this way, you can pass [all options that Hnswlib supports](https://github.com/nmslib/hnswlib#api-description):
125125

126-
| Keyword | Description | Default |
127-
|-------------------|--------------------------------------------------------------------------------------------------------------------------------|---------|
128-
| `max_elements` | Maximum number of vector that can be stored | 1024 |
129-
| `space` | Vector space (similarity metric) the index operates in. Supports 'l2', 'ip', and 'cosine' | 'l2' |
130-
| `index` | Whether or not an index should be built for this field. | True |
131-
| `ef_construction` | defines a construction time/accuracy trade-off | 200 |
132-
| `ef` | parameter controlling query time/accuracy trade-off | 10 |
133-
| `M` | parameter that defines the maximum number of outgoing connections in the graph | 16 |
134-
| `allow_replace_deleted` | enables replacing of deleted elements with new added ones | True |
135-
| `num_threads` | sets the number of cpu threads to use | 1 |
126+
| Keyword | Description | Default |
127+
|-------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---------|
128+
| `max_elements` | Maximum number of vector that can be stored | 1024 |
129+
| `space` | Vector space (distance metric) the index operates in. Supports 'l2', 'ip', and 'cosine'. <br/><span style="color:black">**Note:** In contrast to the other backends, for HnswDocumentIndex `'cosine'` refers to **cosine distance**, not cosine similarity. To transform one to the other, you can use: `cos_sim = 1 - cos_dist`. For more details see [here](https://en.wikipedia.org/wiki/Cosine_similarity#Cosine_Distance)</span>. | 'l2' |
130+
| `index` | Whether or not an index should be built for this field. | True |
131+
| `ef_construction` | defines a construction time/accuracy trade-off | 200 |
132+
| `ef` | parameter controlling query time/accuracy trade-off | 10 |
133+
| `M` | parameter that defines the maximum number of outgoing connections in the graph | 16 |
134+
| `allow_replace_deleted` | enables replacing of deleted elements with new added ones | True |
135+
| `num_threads` | sets the number of cpu threads to use | 1 |
136+
137+
!!! note
138+
In HnswLibDocIndex `space='cosine'` refers to cosine distance, not to cosine similarity, as it does for the other backends.
136139

137140
You can find more details on the parameters [here](https://github.com/nmslib/hnswlib/blob/master/ALGO_PARAMS.md).
138141

0 commit comments

Comments
 (0)