Configuration
Configuration options for HNSW index.
max_connections, metric and precision are fixed when an index is
created, with the defaults below for any left out. Opening it again takes
each from the file unless it's given, and checks any that is.
Attributes:
| Name | Type | Description |
|---|---|---|
max_connections |
int | None
|
Maximum connections per node (M parameter). Higher = better recall, more memory. Default: 16 when creating |
ef_construction |
int
|
Construction quality parameter. Higher = better index quality, slower build. Default: 200 |
ef_search |
int
|
Search quality parameter. Higher = better search quality, slower search. Default: 50 |
metric |
str | None
|
"euclidean" (L2) or "cosine" (1 - cosine similarity; vectors are stored at unit length and zero vectors are rejected). Default: "euclidean" when creating |
precision |
str | None
|
"full" keeps each component of a vector as a 32-bit float, "half" as a 16-bit float: half the file and half the memory, each component rounded to about three decimal digits, and a vector with a component of 65,520 or more in magnitude refused. Default: "full" when creating |
huge_pages |
bool | None
|
Whether to ask the operating system to keep the vectors
on huge pages. On an index too large for the CPU's caches,
searches are up to a quarter faster. Only on Linux, and only where
the kernel and filesystem keep files on huge pages (ext4 on Linux
6.17 does); elsewhere it does nothing. True asks from the moment
the index is opened: a page not yet in memory is then read 2 MB at
a time, which an index much larger than memory pays for on every
miss. False never asks. None leaves it to |
warm |
bool
|
Read the whole index into memory on another thread from the
moment it is opened, so that searches stop waiting for the disk
one page at a time. For an index that fits in memory. It takes
Linux 5.14 or macOS: an older Linux reads only some of the
index, and Windows none. Unless |
Source code in chassisdb/index.py
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 | |
validate()
Check the options, and spell metric and precision as Chassis does: "L2" becomes "euclidean" and "float16" becomes "half".
Raises:
| Type | Description |
|---|---|
InvalidArgumentError
|
If an option is out of range or unknown |
TypeError
|
If an option has the wrong type |
Source code in chassisdb/index.py
91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 | |
A single search result.
Attributes:
| Name | Type | Description |
|---|---|---|
id |
int
|
Vector ID in the index |
distance |
float
|
Distance to the query vector (lower is closer) |
Source code in chassisdb/index.py
164 165 166 167 168 169 170 171 172 173 174 175 176 177 | |