Skip to content

Commit 573bfa0

Browse files
author
Nitin Kanukolanu
committed
Update docs and info
1 parent 5787ddd commit 573bfa0

File tree

2 files changed

+347
-79
lines changed

2 files changed

+347
-79
lines changed

docs/api/schema.rst

Lines changed: 282 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -67,74 +67,166 @@ Each field type supports specific attributes that customize its behavior. Below
6767

6868
**Text Field Attributes**:
6969

70-
- `weight`: Importance of the field in result calculation.
71-
- `no_stem`: Disables stemming during indexing.
72-
- `withsuffixtrie`: Optimizes queries by maintaining a suffix trie.
73-
- `phonetic_matcher`: Enables phonetic matching.
74-
- `sortable`: Allows sorting on this field.
75-
- `no_index`: When True, field is not indexed but can be returned in results (requires `sortable=True`).
76-
- `unf`: Un-normalized form. When True, preserves original case for sorting (requires `sortable=True`).
70+
.. autoclass:: TextFieldAttributes
71+
:members:
72+
:undoc-members:
7773

7874
**Tag Field Attributes**:
7975

80-
- `separator`: Character for splitting text into individual tags.
81-
- `case_sensitive`: Case sensitivity in tag matching.
82-
- `withsuffixtrie`: Suffix trie optimization for queries.
83-
- `sortable`: Enables sorting based on the tag field.
84-
- `no_index`: When True, field is not indexed but can be returned in results (requires `sortable=True`).
76+
.. autoclass:: TagFieldAttributes
77+
:members:
78+
:undoc-members:
8579

8680
**Numeric Field Attributes**:
8781

88-
- `sortable`: Enables sorting on the numeric field.
89-
- `no_index`: When True, field is not indexed but can be returned in results (requires `sortable=True`).
90-
- `unf`: Un-normalized form. When True, maintains original numeric representation for sorting (requires `sortable=True`).
82+
.. autoclass:: NumericFieldAttributes
83+
:members:
84+
:undoc-members:
9185

9286
**Geo Field Attributes**:
9387

94-
- `sortable`: Enables sorting based on the geo field.
95-
- `no_index`: When True, field is not indexed but can be returned in results (requires `sortable=True`).
88+
.. autoclass:: GeoFieldAttributes
89+
:members:
90+
:undoc-members:
9691

9792
**Common Vector Field Attributes**:
9893

99-
- `dims`: Dimensionality of the vector.
100-
- `algorithm`: Indexing algorithm (`flat`, `hnsw`, or `svs-vamana`).
101-
- `datatype`: Float datatype of the vector (`bfloat16`, `float16`, `float32`, `float64`). Note: SVS-VAMANA only supports `float16` and `float32`.
102-
- `distance_metric`: Metric for measuring query relevance (`COSINE`, `L2`, `IP`).
103-
- `initial_cap`: Initial capacity for the index (optional).
104-
- `index_missing`: When True, allows searching for documents missing this field (optional).
94+
- `dims`: Dimensionality of the vector (e.g., 768, 1536).
95+
- `algorithm`: Indexing algorithm for vector search:
10596

106-
**FLAT Vector Field Specific Attributes**:
97+
- `flat`: Brute-force exact search. 100% recall, slower for large datasets. Best for <10K vectors.
98+
- `hnsw`: Graph-based approximate search. Fast with high recall (95-99%). Best for general use.
99+
- `svs-vamana`: Compressed approximate search. Memory-efficient with compression. Best for large datasets on Intel hardware.
107100

108-
- `block_size`: Block size for the FLAT index (optional).
101+
.. note::
102+
For detailed algorithm comparison and selection guidance, see :ref:`vector-algorithm-comparison`.
103+
104+
- `datatype`: Float precision (`bfloat16`, `float16`, `float32`, `float64`). Note: SVS-VAMANA only supports `float16` and `float32`.
105+
- `distance_metric`: Similarity metric (`COSINE`, `L2`, `IP`).
106+
- `initial_cap`: Initial capacity hint for memory allocation (optional).
107+
- `index_missing`: When True, allows searching for documents missing this field (optional).
109108

110109
**HNSW Vector Field Specific Attributes**:
111110

112-
- `m`: Max outgoing edges per node in each layer (default: 16).
113-
- `ef_construction`: Max edge candidates during build time (default: 200).
114-
- `ef_runtime`: Max top candidates during search (default: 10).
115-
- `epsilon`: Range search boundary factor (default: 0.01).
111+
HNSW (Hierarchical Navigable Small World) - Graph-based approximate search with excellent recall. **Best for general-purpose vector search (10K-1M+ vectors).**
112+
113+
.. dropdown:: When to use HNSW & Performance Details
114+
:color: info
115+
116+
**Use HNSW when:**
117+
118+
- Medium to large datasets (10K-1M+ vectors) requiring high recall rates
119+
- Search accuracy is more important than memory usage
120+
- Need general-purpose vector search with balanced performance
121+
- Cross-platform deployments where hardware-specific optimizations aren't available
122+
123+
**Performance characteristics:**
124+
125+
- **Search speed**: Very fast approximate search with tunable accuracy
126+
- **Memory usage**: Higher than compressed SVS-VAMANA but reasonable for most applications
127+
- **Recall quality**: Excellent recall rates (95-99%), often better than other approximate methods
128+
- **Build time**: Moderate construction time, faster than SVS-VAMANA for smaller datasets
129+
130+
.. currentmodule:: redisvl.schema.fields
131+
132+
.. autoclass:: HNSWVectorFieldAttributes
133+
:members:
134+
:undoc-members:
135+
136+
**HNSW Examples:**
137+
138+
**Balanced configuration (recommended starting point):**
139+
140+
.. code-block:: yaml
141+
142+
- name: embedding
143+
type: vector
144+
attrs:
145+
algorithm: hnsw
146+
dims: 768
147+
distance_metric: cosine
148+
datatype: float32
149+
# Balanced settings for good recall and performance
150+
m: 16
151+
ef_construction: 200
152+
ef_runtime: 10
153+
154+
**High-recall configuration:**
155+
156+
.. code-block:: yaml
157+
158+
- name: embedding
159+
type: vector
160+
attrs:
161+
algorithm: hnsw
162+
dims: 768
163+
distance_metric: cosine
164+
datatype: float32
165+
# Tuned for maximum accuracy
166+
m: 32
167+
ef_construction: 400
168+
ef_runtime: 50
116169
117170
**SVS-VAMANA Vector Field Specific Attributes**:
118171

119-
SVS-VAMANA (Scalable Vector Search with VAMANA graph algorithm) provides fast approximate nearest neighbor search with optional compression support. This algorithm is optimized for Intel hardware and offers reduced memory usage through vector compression.
172+
SVS-VAMANA - High-performance search with optional compression. **Best for large datasets (>100K vectors) on Intel hardware with memory constraints.**
173+
174+
.. dropdown:: When to use SVS-VAMANA & Detailed Guide
175+
:color: info
176+
177+
**Requirements:**
178+
- Redis >= 8.2.0 with RediSearch >= 2.8.10
179+
- datatype must be 'float16' or 'float32' (float64/bfloat16 not supported)
180+
181+
**Use SVS-VAMANA when:**
182+
- Large datasets where memory is expensive
183+
- Cloud deployments with memory-based pricing
184+
- When 90-95% recall is acceptable
185+
- High-dimensional vectors (>1024 dims) with LeanVec compression
186+
187+
**Performance vs other algorithms:**
188+
- **vs FLAT**: Much faster search, significantly lower memory usage with compression, but approximate results
189+
190+
- **vs HNSW**: Better memory efficiency with compression, similar or better recall, Intel-optimized
191+
192+
**Compression selection guide:**
193+
194+
- **No compression**: Best performance, standard memory usage
120195

121-
- `graph_max_degree`: Maximum degree of the Vamana graph, i.e., the number of edges per node (default: 40).
122-
- `construction_window_size`: Size of the candidate list during graph construction. Higher values yield better quality graphs but increase construction time (default: 250).
123-
- `search_window_size`: Size of the candidate list during search. Higher values increase accuracy but also increase search latency (default: 20).
124-
- `epsilon`: Relative factor for range query boundaries (default: 0.01).
125-
- `compression`: Optional vector compression algorithm. Supported types:
196+
- **LVQ4/LVQ8**: Good balance of compression (2x-4x) and performance
126197

127-
- `LVQ4`: 4-bit Learned Vector Quantization
128-
- `LVQ4x4`: 4-bit LVQ with 4x compression
129-
- `LVQ4x8`: 4-bit LVQ with 8x compression
130-
- `LVQ8`: 8-bit Learned Vector Quantization
131-
- `LeanVec4x8`: 4-bit LeanVec with 8x compression and dimensionality reduction
132-
- `LeanVec8x8`: 8-bit LeanVec with 8x compression and dimensionality reduction
198+
- **LeanVec4x8/LeanVec8x8**: Maximum compression (up to 8x) with dimensionality reduction
133199

134-
- `reduce`: Reduced dimensionality for LeanVec compression. Must be less than `dims`. Only valid with `LeanVec4x8` or `LeanVec8x8` compression types. Lowering this value can speed up search and reduce memory usage (optional).
135-
- `training_threshold`: Minimum number of vectors required before compression training begins. Must be less than 100 * 1024 (default: 10 * 1024).
200+
**Memory Savings Examples (1M vectors, 768 dims):**
201+
- No compression (float32): 3.1 GB
136202

137-
**SVS-VAMANA Example**:
203+
- LVQ4x4 compression: 1.6 GB (~48% savings)
204+
205+
- LeanVec4x8 + reduce to 384: 580 MB (~81% savings)
206+
207+
.. autoclass:: SVSVectorFieldAttributes
208+
:members:
209+
:undoc-members:
210+
211+
**SVS-VAMANA Examples:**
212+
213+
**Basic configuration (no compression):**
214+
215+
.. code-block:: yaml
216+
217+
- name: embedding
218+
type: vector
219+
attrs:
220+
algorithm: svs-vamana
221+
dims: 768
222+
distance_metric: cosine
223+
datatype: float32
224+
# Standard settings for balanced performance
225+
graph_max_degree: 40
226+
construction_window_size: 250
227+
search_window_size: 20
228+
229+
**High-performance configuration with compression:**
138230

139231
.. code-block:: yaml
140232
@@ -145,16 +237,155 @@ SVS-VAMANA (Scalable Vector Search with VAMANA graph algorithm) provides fast ap
145237
dims: 768
146238
distance_metric: cosine
147239
datatype: float32
240+
# Tuned for better recall
148241
graph_max_degree: 64
149242
construction_window_size: 500
150243
search_window_size: 40
244+
# Maximum compression with dimensionality reduction
151245
compression: LeanVec4x8
152-
reduce: 384
246+
reduce: 384 # 50% dimensionality reduction
153247
training_threshold: 1000
154248
155-
Note:
156-
- SVS-VAMANA requires Redis >= 8.2 with RediSearch >= 2.8.10.
157-
- SVS-VAMANA only supports `float16` and `float32` datatypes.
158-
- The `reduce` parameter is only valid with LeanVec compression types (`LeanVec4x8` or `LeanVec8x8`).
159-
- Intel's proprietary LVQ and LeanVec optimizations are not available in Redis Open Source. On non-Intel platforms and Redis Open Source, SVS-VAMANA with compression falls back to basic 8-bit scalar quantization.
160-
- See fully documented Redis-supported fields and options here: https://redis.io/commands/ft.create/
249+
**Important Notes:**
250+
251+
- **Requirements**: SVS-VAMANA requires Redis >= 8.2 with RediSearch >= 2.8.10.
252+
- **Datatype limitations**: SVS-VAMANA only supports `float16` and `float32` datatypes (not `bfloat16` or `float64`).
253+
- **Compression compatibility**: The `reduce` parameter is only valid with LeanVec compression types (`LeanVec4x8` or `LeanVec8x8`).
254+
- **Platform considerations**: Intel's proprietary LVQ and LeanVec optimizations are not available in Redis Open Source. On non-Intel platforms and Redis Open Source, SVS-VAMANA with compression falls back to basic 8-bit scalar quantization.
255+
- **Performance tip**: Start with default parameters and tune `search_window_size` first for your speed vs accuracy requirements.
256+
257+
**FLAT Vector Field Specific Attributes**:
258+
259+
FLAT - Brute-force exact search. **Best for small datasets (<10K vectors) requiring 100% accuracy.**
260+
261+
.. dropdown:: When to use FLAT & Performance Details
262+
:color: info
263+
264+
**Use FLAT when:**
265+
- Small datasets (<10K vectors) where exact results are required
266+
- Search accuracy is critical and approximate results are not acceptable
267+
- Baseline comparisons when evaluating approximate algorithms
268+
- Simple use cases where setup simplicity is more important than performance
269+
270+
**Performance characteristics:**
271+
- **Search accuracy**: 100% exact results (no approximation)
272+
- **Search speed**: Linear time O(n) - slower as dataset grows
273+
- **Memory usage**: Minimal overhead, stores vectors as-is
274+
- **Build time**: Fastest index construction (no preprocessing)
275+
276+
**Trade-offs vs other algorithms:**
277+
- **vs HNSW**: Much slower search but exact results, faster index building
278+
- **vs SVS-VAMANA**: Slower search and higher memory usage, but exact results
279+
280+
.. autoclass:: FlatVectorFieldAttributes
281+
:members:
282+
:undoc-members:
283+
284+
**FLAT Example:**
285+
286+
.. code-block:: yaml
287+
288+
- name: embedding
289+
type: vector
290+
attrs:
291+
algorithm: flat
292+
dims: 768
293+
distance_metric: cosine
294+
datatype: float32
295+
# Optional: tune for batch processing
296+
block_size: 1024
297+
298+
**Note**: FLAT is recommended for small datasets or when exact results are mandatory. For larger datasets, consider HNSW or SVS-VAMANA for better performance.
299+
300+
.. _vector-algorithm-comparison:
301+
302+
Vector Algorithm Comparison
303+
===========================
304+
305+
This section provides detailed guidance for choosing between vector search algorithms.
306+
307+
Algorithm Selection Guide
308+
-------------------------
309+
310+
.. list-table:: Vector Algorithm Comparison
311+
:header-rows: 1
312+
:widths: 15 20 20 20 25
313+
314+
* - Algorithm
315+
- Best For
316+
- Performance
317+
- Memory Usage
318+
- Trade-offs
319+
* - **FLAT**
320+
- Small datasets (<10K vectors)
321+
- 100% recall, O(n) search
322+
- Minimal overhead
323+
- Exact but slow for large data
324+
* - **HNSW**
325+
- General purpose (10K-1M+ vectors)
326+
- 95-99% recall, O(log n) search
327+
- Moderate (graph overhead)
328+
- Fast approximate search
329+
* - **SVS-VAMANA**
330+
- Large datasets with memory constraints
331+
- 90-95% recall, O(log n) search
332+
- Low (with compression)
333+
- Intel-optimized, requires newer Redis
334+
335+
When to Use Each Algorithm
336+
--------------------------
337+
338+
**Choose FLAT when:**
339+
- Dataset size < 10,000 vectors
340+
- Exact results are mandatory
341+
- Simple setup is preferred
342+
- Query latency is not critical
343+
344+
**Choose HNSW when:**
345+
- Dataset size 10K - 1M+ vectors
346+
- Need balanced speed and accuracy
347+
- Cross-platform compatibility required
348+
- Most common choice for production
349+
350+
**Choose SVS-VAMANA when:**
351+
- Dataset size > 100K vectors
352+
- Memory usage is a primary concern
353+
- Running on Intel hardware
354+
- Can accept 90-95% recall for memory savings
355+
356+
Performance Characteristics
357+
---------------------------
358+
359+
**Search Speed:**
360+
- FLAT: Linear time O(n) - gets slower as data grows
361+
- HNSW: Logarithmic time O(log n) - scales well
362+
- SVS-VAMANA: Logarithmic time O(log n) - scales well
363+
364+
**Memory Usage (1M vectors, 768 dims, float32):**
365+
- FLAT: ~3.1 GB (baseline)
366+
- HNSW: ~3.7 GB (20% overhead for graph)
367+
- SVS-VAMANA: 1.6-3.1 GB (depends on compression)
368+
369+
**Recall Quality:**
370+
- FLAT: 100% (exact search)
371+
- HNSW: 95-99% (tunable via ef_runtime)
372+
- SVS-VAMANA: 90-95% (depends on compression)
373+
374+
Migration Considerations
375+
------------------------
376+
377+
**From FLAT to HNSW:**
378+
- Straightforward migration
379+
- Expect slight recall reduction but major speed improvement
380+
- Tune ef_runtime to balance speed vs accuracy
381+
382+
**From HNSW to SVS-VAMANA:**
383+
- Requires Redis >= 8.2 with RediSearch >= 2.8.10
384+
- Change datatype to float16 or float32 if using others
385+
- Consider compression options for memory savings
386+
387+
**From SVS-VAMANA to others:**
388+
- May need to change datatype back if using float64/bfloat16
389+
- HNSW provides similar performance with broader compatibility
390+
391+
For complete Redis field documentation, see: https://redis.io/commands/ft.create/

0 commit comments

Comments
 (0)