-
Notifications
You must be signed in to change notification settings - Fork 21
/
Copy pathloaders.html
501 lines (459 loc) · 35.6 KB
/
loaders.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
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
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
<!DOCTYPE html>
<html class="writer-html5" lang="en" data-content_root="../">
<head>
<meta charset="utf-8" /><meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Loaders — Scalable Vector Search 0.0.1 documentation</title>
<link rel="stylesheet" type="text/css" href="../_static/pygments.css?v=80d5e7a1" />
<link rel="stylesheet" type="text/css" href="../_static/css/theme.css?v=19f00094" />
<link rel="stylesheet" type="text/css" href="../_static/sphinx_collapse.css?v=226d88b4" />
<link rel="stylesheet" type="text/css" href="../_static/css/custom.css" />
<!--[if lt IE 9]>
<script src="../_static/js/html5shiv.min.js"></script>
<![endif]-->
<script src="../_static/jquery.js?v=5d32c60e"></script>
<script src="../_static/_sphinx_javascript_frameworks_compat.js?v=2cd50e6c"></script>
<script src="../_static/documentation_options.js?v=d45e8c67"></script>
<script src="../_static/doctools.js?v=9a2dae69"></script>
<script src="../_static/sphinx_highlight.js?v=dc90522c"></script>
<script src="../_static/js/theme.js"></script>
<link rel="index" title="Index" href="../genindex.html" />
<link rel="search" title="Search" href="../search.html" />
<link rel="next" title="Flat Index" href="flat.html" />
<link rel="prev" title="Common Python API" href="common.html" />
</head>
<body class="wy-body-for-nav">
<div class="wy-grid-for-nav">
<nav data-toggle="wy-nav-shift" class="wy-nav-side">
<div class="wy-side-scroll">
<div class="wy-side-nav-search" >
<a href="../index.html" class="icon icon-home">
Scalable Vector Search
</a>
<div role="search">
<form id="rtd-search-form" class="wy-form" action="../search.html" method="get">
<input type="text" name="q" placeholder="Search docs" aria-label="Search docs" />
<input type="hidden" name="check_keywords" value="yes" />
<input type="hidden" name="area" value="default" />
</form>
</div>
</div><div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="Navigation menu">
<p class="caption" role="heading"><span class="caption-text">Contents:</span></p>
<ul>
<li class="toctree-l1"><a class="reference internal" href="../intro.html">Introduction</a></li>
<li class="toctree-l1"><a class="reference internal" href="../start.html">Getting started with Python</a></li>
<li class="toctree-l1"><a class="reference internal" href="../start_cpp.html">Getting started with C++</a></li>
<li class="toctree-l1"><a class="reference internal" href="../features.html">Library Features</a></li>
<li class="toctree-l1"><a class="reference internal" href="../howtos.html">How-Tos</a></li>
<li class="toctree-l1"><a class="reference internal" href="../io.html">I/O and Conversion Tools</a></li>
<li class="toctree-l1"><a class="reference internal" href="../performance/index.html">Performance Tuning</a></li>
<li class="toctree-l1"><a class="reference internal" href="../advanced/index.html">Advanced Topics</a></li>
<li class="toctree-l1"><a class="reference internal" href="../benchs/index.html">Benchmarks</a></li>
<li class="toctree-l1"><a class="reference internal" href="../roadmap.html">Roadmap</a></li>
<li class="toctree-l1"><a class="reference internal" href="../faq.html">FAQ</a></li>
<li class="toctree-l1"><a class="reference internal" href="../logging.html">Logging</a></li>
</ul>
<p class="caption" role="heading"><span class="caption-text">Python API</span></p>
<ul class="current">
<li class="toctree-l1"><a class="reference internal" href="common.html">Common Python API</a></li>
<li class="toctree-l1 current"><a class="current reference internal" href="#">Loaders</a><ul>
<li class="toctree-l2"><a class="reference internal" href="#uncompressed-file-loaders">Uncompressed File Loaders</a><ul>
<li class="toctree-l3"><a class="reference internal" href="#svs.VectorDataLoader"><code class="docutils literal notranslate"><span class="pre">VectorDataLoader</span></code></a><ul>
<li class="toctree-l4"><a class="reference internal" href="#svs.VectorDataLoader.__init__"><code class="docutils literal notranslate"><span class="pre">VectorDataLoader.__init__()</span></code></a></li>
<li class="toctree-l4"><a class="reference internal" href="#svs.VectorDataLoader.data_type"><code class="docutils literal notranslate"><span class="pre">VectorDataLoader.data_type</span></code></a></li>
<li class="toctree-l4"><a class="reference internal" href="#svs.VectorDataLoader.dims"><code class="docutils literal notranslate"><span class="pre">VectorDataLoader.dims</span></code></a></li>
<li class="toctree-l4"><a class="reference internal" href="#svs.VectorDataLoader.filepath"><code class="docutils literal notranslate"><span class="pre">VectorDataLoader.filepath</span></code></a></li>
</ul>
</li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="#lvq-loader">LVQ Loader</a><ul>
<li class="toctree-l3"><a class="reference internal" href="#svs.LVQLoader"><code class="docutils literal notranslate"><span class="pre">LVQLoader</span></code></a><ul>
<li class="toctree-l4"><a class="reference internal" href="#svs.LVQLoader.__init__"><code class="docutils literal notranslate"><span class="pre">LVQLoader.__init__()</span></code></a></li>
<li class="toctree-l4"><a class="reference internal" href="#svs.LVQLoader.dims"><code class="docutils literal notranslate"><span class="pre">LVQLoader.dims</span></code></a></li>
<li class="toctree-l4"><a class="reference internal" href="#svs.LVQLoader.primary_bits"><code class="docutils literal notranslate"><span class="pre">LVQLoader.primary_bits</span></code></a></li>
<li class="toctree-l4"><a class="reference internal" href="#svs.LVQLoader.reload_from"><code class="docutils literal notranslate"><span class="pre">LVQLoader.reload_from()</span></code></a></li>
<li class="toctree-l4"><a class="reference internal" href="#svs.LVQLoader.residual_bits"><code class="docutils literal notranslate"><span class="pre">LVQLoader.residual_bits</span></code></a></li>
<li class="toctree-l4"><a class="reference internal" href="#svs.LVQLoader.strategy"><code class="docutils literal notranslate"><span class="pre">LVQLoader.strategy</span></code></a></li>
</ul>
</li>
<li class="toctree-l3"><a class="reference internal" href="#strategy-selection">Strategy Selection</a><ul>
<li class="toctree-l4"><a class="reference internal" href="#svs.LVQStrategy"><code class="docutils literal notranslate"><span class="pre">LVQStrategy</span></code></a></li>
</ul>
</li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="#leanvecloader">LeanVecLoader</a><ul>
<li class="toctree-l3"><a class="reference internal" href="#svs.LeanVecLoader"><code class="docutils literal notranslate"><span class="pre">LeanVecLoader</span></code></a><ul>
<li class="toctree-l4"><a class="reference internal" href="#svs.LeanVecLoader.__init__"><code class="docutils literal notranslate"><span class="pre">LeanVecLoader.__init__()</span></code></a></li>
<li class="toctree-l4"><a class="reference internal" href="#svs.LeanVecLoader.alignment"><code class="docutils literal notranslate"><span class="pre">LeanVecLoader.alignment</span></code></a></li>
<li class="toctree-l4"><a class="reference internal" href="#svs.LeanVecLoader.dims"><code class="docutils literal notranslate"><span class="pre">LeanVecLoader.dims</span></code></a></li>
<li class="toctree-l4"><a class="reference internal" href="#svs.LeanVecLoader.leanvec_dims"><code class="docutils literal notranslate"><span class="pre">LeanVecLoader.leanvec_dims</span></code></a></li>
<li class="toctree-l4"><a class="reference internal" href="#svs.LeanVecLoader.primary_kind"><code class="docutils literal notranslate"><span class="pre">LeanVecLoader.primary_kind</span></code></a></li>
<li class="toctree-l4"><a class="reference internal" href="#svs.LeanVecLoader.reload_from"><code class="docutils literal notranslate"><span class="pre">LeanVecLoader.reload_from()</span></code></a></li>
<li class="toctree-l4"><a class="reference internal" href="#svs.LeanVecLoader.secondary_kind"><code class="docutils literal notranslate"><span class="pre">LeanVecLoader.secondary_kind</span></code></a></li>
</ul>
</li>
<li class="toctree-l3"><a class="reference internal" href="#svs.LeanVecKind"><code class="docutils literal notranslate"><span class="pre">LeanVecKind</span></code></a></li>
</ul>
</li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="flat.html">Flat Index</a></li>
<li class="toctree-l1"><a class="reference internal" href="vamana.html">Vamana Graph Index</a></li>
<li class="toctree-l1"><a class="reference internal" href="dynamic.html">Dynamic Vamana Graph Index</a></li>
<li class="toctree-l1"><a class="reference internal" href="backend.html">Backend Selection</a></li>
<li class="toctree-l1"><a class="reference internal" href="upgrader.html">Object Upgrader</a></li>
<li class="toctree-l1"><a class="reference internal" href="logging.html">Python Logging API</a></li>
</ul>
<p class="caption" role="heading"><span class="caption-text">C++ Documentation</span></p>
<ul>
<li class="toctree-l1"><a class="reference internal" href="../cpp/top.html">C++ Library</a></li>
<li class="toctree-l1"><a class="reference internal" href="../cpp/index/index.html">Indexes</a></li>
<li class="toctree-l1"><a class="reference internal" href="../cpp/core/index.html">Core Components</a></li>
<li class="toctree-l1"><a class="reference internal" href="../cpp/quantization/index.html">Quantization Support</a></li>
<li class="toctree-l1"><a class="reference internal" href="../cpp/concepts/index.html">Core Concepts</a></li>
<li class="toctree-l1"><a class="reference internal" href="../cpp/internal/index.html">Internals</a></li>
<li class="toctree-l1"><a class="reference internal" href="../cpp/testing.html">Testing</a></li>
</ul>
<p class="caption" role="heading"><span class="caption-text">Experimental Python Library</span></p>
<ul>
<li class="toctree-l1"><a class="reference internal" href="experimental/leanvec.html">Using LeanVec</a></li>
</ul>
</div>
</div>
</nav>
<section data-toggle="wy-nav-shift" class="wy-nav-content-wrap"><nav class="wy-nav-top" aria-label="Mobile navigation menu" >
<i data-toggle="wy-nav-top" class="fa fa-bars"></i>
<a href="../index.html">Scalable Vector Search</a>
</nav>
<div class="wy-nav-content">
<div class="rst-content">
<div role="navigation" aria-label="Page navigation">
<ul class="wy-breadcrumbs">
<li><a href="../index.html" class="icon icon-home" aria-label="Home"></a></li>
<li class="breadcrumb-item active">Loaders</li>
<li class="wy-breadcrumbs-aside">
<a href="../_sources/python/loaders.rst.txt" rel="nofollow"> View page source</a>
</li>
</ul>
<hr/>
</div>
<div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article">
<div itemprop="articleBody">
<section id="loaders">
<span id="python-api-loaders"></span><h1>Loaders<a class="headerlink" href="#loaders" title="Link to this heading"></a></h1>
<section id="uncompressed-file-loaders">
<h2>Uncompressed File Loaders<a class="headerlink" href="#uncompressed-file-loaders" title="Link to this heading"></a></h2>
<dl class="py class">
<dt class="sig sig-object py" id="svs.VectorDataLoader">
<em class="property"><span class="pre">class</span><span class="w"> </span></em><span class="sig-prename descclassname"><span class="pre">svs.</span></span><span class="sig-name descname"><span class="pre">VectorDataLoader</span></span><a class="headerlink" href="#svs.VectorDataLoader" title="Link to this definition"></a></dt>
<dd><p>Handle representing an uncompressed vector data file.</p>
<dl class="py method">
<dt class="sig sig-object py" id="svs.VectorDataLoader.__init__">
<span class="sig-name descname"><span class="pre">__init__</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">self:</span> <span class="pre">svs::python.VectorDataLoader</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">path:</span> <span class="pre">str</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">data_type:</span> <span class="pre">Optional[svs::python.DataType]</span> <span class="pre">=</span> <span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">dims:</span> <span class="pre">Optional[int]</span> <span class="pre">=</span> <span class="pre">None</span></span></em><span class="sig-paren">)</span> <span class="sig-return"><span class="sig-return-icon">→</span> <span class="sig-return-typehint"><span class="pre">None</span></span></span><a class="headerlink" href="#svs.VectorDataLoader.__init__" title="Link to this definition"></a></dt>
<dd><p>Construct a new <code class="docutils literal notranslate"><span class="pre">svs.VectorDataLoader</span></code>.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters<span class="colon">:</span></dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>path</strong> (<em>str</em>) – <p>The path to the file to load. This can either be:</p>
<ul>
<li><p>The path to the directory where a previous vector dataset was saved (preferred).</p></li>
<li><p>The direct path to the vector data file itself. In this case, the type of the file
will try to be inferred automatically. Recognized extensions: “.[b/i/f]vecs”,
“.bin”, and “.svs”.</p></li>
</ul>
</p></li>
<li><p><strong>data_type</strong> (<a class="reference internal" href="common.html#svs.DataType" title="svs.DataType"><code class="xref py py-class docutils literal notranslate"><span class="pre">svs.DataType</span></code></a>) – The native type of the elements in the dataset.</p></li>
<li><p><strong>dims</strong> (<em>int</em>) – The expected dimsionality of the dataset. While this argument is generally
optional, providing it may yield runtime speedups.</p></li>
</ul>
</dd>
</dl>
</dd></dl>
<dl class="py property">
<dt class="sig sig-object py" id="svs.VectorDataLoader.data_type">
<em class="property"><span class="pre">property</span><span class="w"> </span></em><span class="sig-name descname"><span class="pre">data_type</span></span><a class="headerlink" href="#svs.VectorDataLoader.data_type" title="Link to this definition"></a></dt>
<dd><p>Access the assigned data type.</p>
<dl class="field-list simple">
<dt class="field-odd">Type<span class="colon">:</span></dt>
<dd class="field-odd"><p>Read/Write (<a class="reference internal" href="common.html#svs.DataType" title="svs.DataType"><code class="xref py py-class docutils literal notranslate"><span class="pre">svs.DataType</span></code></a>)</p>
</dd>
</dl>
</dd></dl>
<dl class="py property">
<dt class="sig sig-object py" id="svs.VectorDataLoader.dims">
<em class="property"><span class="pre">property</span><span class="w"> </span></em><span class="sig-name descname"><span class="pre">dims</span></span><a class="headerlink" href="#svs.VectorDataLoader.dims" title="Link to this definition"></a></dt>
<dd><p>Access the expected dimensionality.</p>
<dl class="field-list simple">
<dt class="field-odd">Type<span class="colon">:</span></dt>
<dd class="field-odd"><p>Read/Write (int)</p>
</dd>
</dl>
</dd></dl>
<dl class="py property">
<dt class="sig sig-object py" id="svs.VectorDataLoader.filepath">
<em class="property"><span class="pre">property</span><span class="w"> </span></em><span class="sig-name descname"><span class="pre">filepath</span></span><a class="headerlink" href="#svs.VectorDataLoader.filepath" title="Link to this definition"></a></dt>
<dd><p>Access the underlying file path.</p>
<dl class="field-list simple">
<dt class="field-odd">Type<span class="colon">:</span></dt>
<dd class="field-odd"><p>Read/Write (str)</p>
</dd>
</dl>
</dd></dl>
</dd></dl>
</section>
<section id="lvq-loader">
<span id="python-api-lvq-loader"></span><h2>LVQ Loader<a class="headerlink" href="#lvq-loader" title="Link to this heading"></a></h2>
<p>The LVQ loader provides lazy compression of uncompressed data and reloading of previously
saved LVQ data.</p>
<dl class="py class">
<dt class="sig sig-object py" id="svs.LVQLoader">
<em class="property"><span class="pre">class</span><span class="w"> </span></em><span class="sig-prename descclassname"><span class="pre">svs.</span></span><span class="sig-name descname"><span class="pre">LVQLoader</span></span><a class="headerlink" href="#svs.LVQLoader" title="Link to this definition"></a></dt>
<dd><p>Generic LVQ Loader</p>
<dl class="py method">
<dt class="sig sig-object py" id="svs.LVQLoader.__init__">
<span class="sig-name descname"><span class="pre">__init__</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="o"><span class="pre">*</span></span><span class="n"><span class="pre">args</span></span></em>, <em class="sig-param"><span class="o"><span class="pre">**</span></span><span class="n"><span class="pre">kwargs</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#svs.LVQLoader.__init__" title="Link to this definition"></a></dt>
<dd><p>Overloaded function.</p>
<ol class="arabic simple">
<li><p>__init__(self: svs::python.LVQLoader, datafile: svs::python.VectorDataLoader, primary: int, residual: int = 0, padding: int = 0, strategy: svs::python.LVQStrategy = <LVQStrategy.Auto: 0>) -> None</p></li>
</ol>
<p>Construct a loader that will lazily compress the results of the data loader.
Requires an appropriate back-end to be compiled for all combinations of primary and residual
bits.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters<span class="colon">:</span></dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>loader</strong> (<a class="reference internal" href="#svs.VectorDataLoader" title="svs.VectorDataLoader"><code class="xref py py-class docutils literal notranslate"><span class="pre">svs.VectorDataLoader</span></code></a>) – The uncompressed dataset to compress
in-memory.</p></li>
<li><p><strong>primary</strong> (<em>int</em>) – The number of bits to use for compression in the primary dataset.</p></li>
<li><p><strong>residual</strong> (<em>int</em>) – The number of bits to use for compression in the residual dataset.
Default: 0.</p></li>
<li><p><strong>padding</strong> (<em>int</em>) – The value (in bytes) to align the beginning of each compressed vectors.
Values of 32 or 64 may offer the best performance at the cost of a lower compression
ratio. A value of 0 implies no special alignment.</p></li>
<li><p><strong>strategy</strong> (<a class="reference internal" href="#svs.LVQStrategy" title="svs.LVQStrategy"><code class="xref py py-class docutils literal notranslate"><span class="pre">svs.LVQStrategy</span></code></a>) – The packing strategy to use for the compressed
codes. See the associated documenation for that enum.</p></li>
</ul>
</dd>
</dl>
<ol class="arabic simple" start="2">
<li><p>__init__(self: svs::python.LVQLoader, directory: str, padding: int = 0, strategy: svs::python.LVQStrategy = <LVQStrategy.Auto: 0>) -> None</p></li>
</ol>
<p>Reload a compressed dataset from a previously saved dataset.
Requires an appropriate back-end to be compiled for all combinations of primary and residual
bits.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters<span class="colon">:</span></dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>directory</strong> (<em>str</em>) – The directory where the dataset was previously saved.</p></li>
<li><p><strong>primary</strong> (<em>int</em>) – The number of bits to use for compression in the primary dataset.</p></li>
<li><p><strong>residual</strong> (<em>int</em>) – The number of bits to use for compression in the residual dataset.
Default: 0></p></li>
<li><p><strong>dims</strong> (<em>int</em>) – The number of dimensions in the dataset. May provide a performance boost
if given if a specialization has been compiled. Default: Dynamic (any dimension).</p></li>
<li><p><strong>padding</strong> (<em>int</em>) – The value (in bytes) to align the beginning of each compressed vectors.
Values of 32 or 64 may offer the best performance at the cost of a lower compression
ratio. A value of 0 implies no special alignment. Default: 0.</p></li>
<li><p><strong>strategy</strong> (<a class="reference internal" href="#svs.LVQStrategy" title="svs.LVQStrategy"><code class="xref py py-class docutils literal notranslate"><span class="pre">svs.LVQStrategy</span></code></a>) – The packing strategy to use for the compressed
codes. See the associated documenation for that enum.</p></li>
</ul>
</dd>
</dl>
<ol class="arabic simple" start="3">
<li><p>__init__(self: svs::python.LVQLoader, legacy: svs::python.LVQ4) -> None</p></li>
<li><p>__init__(self: svs::python.LVQLoader, legacy: svs::python.LVQ8) -> None</p></li>
<li><p>__init__(self: svs::python.LVQLoader, legacy: svs::python.LVQ4x4) -> None</p></li>
<li><p>__init__(self: svs::python.LVQLoader, legacy: svs::python.LVQ4x8) -> None</p></li>
<li><p>__init__(self: svs::python.LVQLoader, legacy: svs::python.LVQ8x8) -> None</p></li>
</ol>
</dd></dl>
<dl class="py property">
<dt class="sig sig-object py" id="svs.LVQLoader.dims">
<em class="property"><span class="pre">property</span><span class="w"> </span></em><span class="sig-name descname"><span class="pre">dims</span></span><a class="headerlink" href="#svs.LVQLoader.dims" title="Link to this definition"></a></dt>
<dd><p>The number of dimensions.</p>
</dd></dl>
<dl class="py property">
<dt class="sig sig-object py" id="svs.LVQLoader.primary_bits">
<em class="property"><span class="pre">property</span><span class="w"> </span></em><span class="sig-name descname"><span class="pre">primary_bits</span></span><a class="headerlink" href="#svs.LVQLoader.primary_bits" title="Link to this definition"></a></dt>
<dd><p>The number of bits used for the primary encoding.</p>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="svs.LVQLoader.reload_from">
<span class="sig-name descname"><span class="pre">reload_from</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">self:</span> <span class="pre">svs::python.LVQLoader</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">directory:</span> <span class="pre">str</span></span></em><span class="sig-paren">)</span> <span class="sig-return"><span class="sig-return-icon">→</span> <span class="sig-return-typehint"><a class="reference internal" href="#svs.LVQLoader" title="svs::python.LVQLoader"><span class="pre">svs::python.LVQLoader</span></a></span></span><a class="headerlink" href="#svs.LVQLoader.reload_from" title="Link to this definition"></a></dt>
<dd><p>Create a copy of the argument loader configured to reload a previously saved LVQ dataset
from the given directory.</p>
</dd></dl>
<dl class="py property">
<dt class="sig sig-object py" id="svs.LVQLoader.residual_bits">
<em class="property"><span class="pre">property</span><span class="w"> </span></em><span class="sig-name descname"><span class="pre">residual_bits</span></span><a class="headerlink" href="#svs.LVQLoader.residual_bits" title="Link to this definition"></a></dt>
<dd><p>The number of bits used for the residual encoding.</p>
</dd></dl>
<dl class="py property">
<dt class="sig sig-object py" id="svs.LVQLoader.strategy">
<em class="property"><span class="pre">property</span><span class="w"> </span></em><span class="sig-name descname"><span class="pre">strategy</span></span><a class="headerlink" href="#svs.LVQLoader.strategy" title="Link to this definition"></a></dt>
<dd><p>The packing strategy to use.</p>
</dd></dl>
</dd></dl>
<section id="strategy-selection">
<h3>Strategy Selection<a class="headerlink" href="#strategy-selection" title="Link to this heading"></a></h3>
<p>The strategy argument of the LVQ loader provides a way of overriding the default selection
of the packing strategy used by a LVQ backend.</p>
<p>Note that overriding the default strategy requires the corresponding backend to
be compiled in the <cite>svs</cite> shared library component.</p>
<dl class="py class">
<dt class="sig sig-object py" id="svs.LVQStrategy">
<em class="property"><span class="pre">class</span><span class="w"> </span></em><span class="sig-prename descclassname"><span class="pre">svs.</span></span><span class="sig-name descname"><span class="pre">LVQStrategy</span></span><a class="headerlink" href="#svs.LVQStrategy" title="Link to this definition"></a></dt>
<dd><p>Select the packing mode for LVQ</p>
<p>Members:</p>
<blockquote>
<div><p>Auto : Let SVS decide the best strategy.</p>
<p>Sequential : Use the Sequential packing strategy.</p>
<p>Turbo : Use the best Turbo packing strategy for this architecture.</p>
</div></blockquote>
</dd></dl>
</section>
</section>
<section id="leanvecloader">
<h2>LeanVecLoader<a class="headerlink" href="#leanvecloader" title="Link to this heading"></a></h2>
<p>The LeanVec loader provides a way to use dimensionality reduction to improve
performance on high dimensional datasets.</p>
<p>Internally, a LeanVec dataset consists of the dimensionality reduced primary dataset
(over which the bulk of the index search is conducted) and a full dimensional secondary
dataset used to rerank and refine candidates returned from the initial search.</p>
<p><cite>svs</cite> allows selection of the storage format using the <a class="reference internal" href="#svs.LeanVecKind" title="svs.LeanVecKind"><code class="xref py py-class docutils literal notranslate"><span class="pre">svs.LeanVecKind</span></code></a> enum,
enabling <cite>float16</cite> and <cite>lvq</cite> compression for either of the primary and secondary datasets.</p>
<dl class="py class">
<dt class="sig sig-object py" id="svs.LeanVecLoader">
<em class="property"><span class="pre">class</span><span class="w"> </span></em><span class="sig-prename descclassname"><span class="pre">svs.</span></span><span class="sig-name descname"><span class="pre">LeanVecLoader</span></span><a class="headerlink" href="#svs.LeanVecLoader" title="Link to this definition"></a></dt>
<dd><p>Generic LeanVec Loader</p>
<dl class="py method">
<dt class="sig sig-object py" id="svs.LeanVecLoader.__init__">
<span class="sig-name descname"><span class="pre">__init__</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="o"><span class="pre">*</span></span><span class="n"><span class="pre">args</span></span></em>, <em class="sig-param"><span class="o"><span class="pre">**</span></span><span class="n"><span class="pre">kwargs</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#svs.LeanVecLoader.__init__" title="Link to this definition"></a></dt>
<dd><p>Overloaded function.</p>
<ol class="arabic simple">
<li><p>__init__(self: svs::python.LeanVecLoader, datafile: svs::python.VectorDataLoader, leanvec_dims: int, primary_kind: svs::python.LeanVecKind = <LeanVecKind.lvq8: 2>, secondary_kind: svs::python.LeanVecKind = <LeanVecKind.lvq8: 2>, data_matrix: Optional[numpy.ndarray[numpy.float32]] = None, query_matrix: Optional[numpy.ndarray[numpy.float32]] = None, alignment: int = 32) -> None</p></li>
</ol>
<p>Construct a loader that will lazily reduce the dimensionality of the data loader.
Requires an appropriate back-end to be compiled for all combinations of primary and
secondary types.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters<span class="colon">:</span></dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>loader</strong> (<a class="reference internal" href="#svs.VectorDataLoader" title="svs.VectorDataLoader"><code class="xref py py-class docutils literal notranslate"><span class="pre">svs.VectorDataLoader</span></code></a>) – The uncompressed original dataset.</p></li>
<li><p><strong>leanvec_dims</strong> (<em>int</em>) – resulting value of reduced dimensionality</p></li>
<li><p><strong>primary</strong> (<a class="reference internal" href="#svs.LeanVecKind" title="svs.LeanVecKind"><em>LeanVecKind</em></a>) – Type of dataset used for Primary (Default: LVQ8)</p></li>
<li><p><strong>secondary</strong> (<a class="reference internal" href="#svs.LeanVecKind" title="svs.LeanVecKind"><em>LeanVecKind</em></a>) – Type of dataset used for Secondary (Default: LVQ8)</p></li>
<li><p><strong>data_matrix</strong> (<em>Optional</em><em>[</em><em>numpy.ndarray</em><em>[</em><em>numpy.float32</em><em>]</em><em>]</em>) – Matrix for data transformation
[see note 1] (Default: None).</p></li>
<li><p><strong>query_matrix</strong> (<em>Optional</em><em>[</em><em>numpy.ndarray</em><em>[</em><em>numpy.float32</em><em>]</em><em>]</em>) – Matrix for query transformation
[see note 1] (Default: None).</p></li>
<li><p><strong>alignment</strong> (<em>int</em>) – alignement/padding used in LVQ data types (Default: 32)</p></li>
</ul>
</dd>
</dl>
<p><strong>Note 1</strong>: The arguments <code class="docutils literal notranslate"><span class="pre">data_matrix</span></code> and <code class="docutils literal notranslate"><span class="pre">data_matrix</span></code> are optional and have the
following requirements for valid combinations:</p>
<blockquote>
<div><ol class="loweralpha simple">
<li><p>Neither matrix provided: Transform dataset and queries using a default PCA-based
transformation.</p></li>
<li><p>Only <code class="docutils literal notranslate"><span class="pre">data_matrix</span></code> provided: The provided matrix is used to transform both the
queries and the original dataset.</p></li>
<li><p>Both arguments are provided: Use the respective matrices for transformation.</p></li>
</ol>
</div></blockquote>
<ol class="arabic simple" start="2">
<li><p>__init__(self: svs::python.LeanVecLoader, directory: str, alignment: int = 32) -> None</p></li>
</ol>
<p>Reload a LeanVec dataset from a previously saved dataset.
Requires an appropriate back-end to be compiled for all combinations of primary and
secondary types.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters<span class="colon">:</span></dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>directory</strong> (<em>str</em>) – The directory where the dataset was previously saved.</p></li>
<li><p><strong>leanvec_dims</strong> (<em>int</em>) – resulting value of reduced dimensionality.
Default: Dynamic (any dimension).</p></li>
<li><p><strong>dims</strong> (<em>int</em>) – The number of dimensions in the original dataset.
Default: Dynamic (any dimension).</p></li>
<li><p><strong>primary</strong> (<a class="reference internal" href="#svs.LeanVecKind" title="svs.LeanVecKind"><em>LeanVecKind</em></a>) – Type of dataset used for Primary
Default: <code class="docutils literal notranslate"><span class="pre">svs.LeanVecKind.lvq8</span></code>.</p></li>
<li><p><strong>secondary</strong> (<a class="reference internal" href="#svs.LeanVecKind" title="svs.LeanVecKind"><em>LeanVecKind</em></a>) – Type of dataset used for Secondary
Default: <code class="docutils literal notranslate"><span class="pre">svs.LeanVecKind.LVQ8</span></code>.</p></li>
<li><p><strong>alignment</strong> (<em>int</em>) – alignement/padding used in LVQ data types. Default: 32.</p></li>
</ul>
</dd>
</dl>
</dd></dl>
<dl class="py property">
<dt class="sig sig-object py" id="svs.LeanVecLoader.alignment">
<em class="property"><span class="pre">property</span><span class="w"> </span></em><span class="sig-name descname"><span class="pre">alignment</span></span><a class="headerlink" href="#svs.LeanVecLoader.alignment" title="Link to this definition"></a></dt>
<dd><p>The alignment to use for LVQ encoded data.</p>
</dd></dl>
<dl class="py property">
<dt class="sig sig-object py" id="svs.LeanVecLoader.dims">
<em class="property"><span class="pre">property</span><span class="w"> </span></em><span class="sig-name descname"><span class="pre">dims</span></span><a class="headerlink" href="#svs.LeanVecLoader.dims" title="Link to this definition"></a></dt>
<dd><p>The full-dimensionality.</p>
</dd></dl>
<dl class="py property">
<dt class="sig sig-object py" id="svs.LeanVecLoader.leanvec_dims">
<em class="property"><span class="pre">property</span><span class="w"> </span></em><span class="sig-name descname"><span class="pre">leanvec_dims</span></span><a class="headerlink" href="#svs.LeanVecLoader.leanvec_dims" title="Link to this definition"></a></dt>
<dd><p>The reduced dimensionality.</p>
</dd></dl>
<dl class="py property">
<dt class="sig sig-object py" id="svs.LeanVecLoader.primary_kind">
<em class="property"><span class="pre">property</span><span class="w"> </span></em><span class="sig-name descname"><span class="pre">primary_kind</span></span><a class="headerlink" href="#svs.LeanVecLoader.primary_kind" title="Link to this definition"></a></dt>
<dd><p>The encoding of the reduced dimensional dataset.</p>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="svs.LeanVecLoader.reload_from">
<span class="sig-name descname"><span class="pre">reload_from</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">self:</span> <span class="pre">svs::python.LeanVecLoader</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">directory:</span> <span class="pre">str</span></span></em><span class="sig-paren">)</span> <span class="sig-return"><span class="sig-return-icon">→</span> <span class="sig-return-typehint"><a class="reference internal" href="#svs.LeanVecLoader" title="svs::python.LeanVecLoader"><span class="pre">svs::python.LeanVecLoader</span></a></span></span><a class="headerlink" href="#svs.LeanVecLoader.reload_from" title="Link to this definition"></a></dt>
<dd><p>Create a copy of the argument loader configured to reload a previously saved LeanVec dataset
from the given directory.</p>
</dd></dl>
<dl class="py property">
<dt class="sig sig-object py" id="svs.LeanVecLoader.secondary_kind">
<em class="property"><span class="pre">property</span><span class="w"> </span></em><span class="sig-name descname"><span class="pre">secondary_kind</span></span><a class="headerlink" href="#svs.LeanVecLoader.secondary_kind" title="Link to this definition"></a></dt>
<dd><p>The encoding of the full-dimensional dataset.</p>
</dd></dl>
</dd></dl>
<dl class="py class">
<dt class="sig sig-object py" id="svs.LeanVecKind">
<em class="property"><span class="pre">class</span><span class="w"> </span></em><span class="sig-prename descclassname"><span class="pre">svs.</span></span><span class="sig-name descname"><span class="pre">LeanVecKind</span></span><a class="headerlink" href="#svs.LeanVecKind" title="Link to this definition"></a></dt>
<dd><p>LeanVec primary and secondary types</p>
<p>Members:</p>
<blockquote>
<div><p>float32 : Uncompressed float32</p>
<p>float16 : Uncompressed float16</p>
<p>lvq8 : Compressed with LVQ 8bits</p>
<p>lvq4 : Compressed with LVQ 4bits</p>
</div></blockquote>
</dd></dl>
</section>
</section>
</div>
</div>
<footer><div class="rst-footer-buttons" role="navigation" aria-label="Footer">
<a href="common.html" class="btn btn-neutral float-left" title="Common Python API" accesskey="p" rel="prev"><span class="fa fa-arrow-circle-left" aria-hidden="true"></span> Previous</a>
<a href="flat.html" class="btn btn-neutral float-right" title="Flat Index" accesskey="n" rel="next">Next <span class="fa fa-arrow-circle-right" aria-hidden="true"></span></a>
</div>
<hr/>
<div role="contentinfo">
<p>© Copyright 2023, Intel Corporation.</p>
</div>
Built with <a href="https://www.sphinx-doc.org/">Sphinx</a> using a
<a href="https://github.com/readthedocs/sphinx_rtd_theme">theme</a>
provided by <a href="https://readthedocs.org">Read the Docs</a>.
</footer>
</div>
</div>
</section>
</div>
<script>
jQuery(function () {
SphinxRtdTheme.Navigation.enable(true);
});
</script>
</body>
</html>