Vector Types
Zvec supports two fundamental vector types:- Dense vectors: Fixed-length arrays where every dimension has a value
- Sparse vectors: Variable-length dictionaries where most dimensions are zero
Dense Vectors
Dense vectors are represented as arrays where every position contains a value:- Text embeddings (e.g., from transformers like BERT, GPT)
- Image embeddings (e.g., from CNNs or vision transformers)
- Audio embeddings
- General-purpose semantic representations
Sparse Vectors
Sparse vectors are represented as dictionaries mapping indices to non-zero values:- Keyword-based search (e.g., BM25 embeddings)
- TF-IDF vectors
- Bag-of-words representations
- High-dimensional feature vectors with few active features
Dense Vector Data Types
Zvec supports multiple precision levels for dense vectors:DataType.VECTOR_FP32 (Recommended)
32-bit floating point (single precision) - the most common choice:- Precision: ~7 decimal digits
- Memory: 4 bytes per dimension
- Use case: Standard choice for most applications
DataType.VECTOR_FP16
16-bit floating point (half precision) - reduced memory:- Precision: ~3 decimal digits
- Memory: 2 bytes per dimension (50% reduction vs FP32)
- Use case: Large-scale systems where memory is constrained
DataType.VECTOR_FP64
64-bit floating point (double precision) - maximum precision:- Precision: ~15 decimal digits
- Memory: 8 bytes per dimension (2x FP32)
- Use case: Scientific applications requiring high precision
DataType.VECTOR_INT8
8-bit integer - quantized vectors:- Precision: Integer values from -128 to 127
- Memory: 1 byte per dimension (75% reduction vs FP32)
- Use case: Extreme memory optimization, quantized embeddings
Sparse Vector Data Types
Zvec supports two sparse vector types:DataType.SPARSE_VECTOR_FP32
32-bit floating point sparse vectors:DataType.SPARSE_VECTOR_FP16
16-bit floating point sparse vectors:For sparse vectors, set
dimension=0 since the actual dimensionality is implicit in the data.Working with Vectors
Inserting Documents with Dense Vectors
Inserting Documents with Sparse Vectors
Querying with Vectors
Multi-Vector Support
Zvec supports multiple vector fields per collection for hybrid search:Vector Dimensions
Choosing Dimensions
Common embedding dimensions:| Model | Dimension | Type |
|---|---|---|
| BERT-base | 768 | Dense |
| BERT-large | 1024 | Dense |
| GPT-3 (small) | 1536 | Dense |
| OpenAI text-embedding-3-small | 1536 | Dense |
| OpenAI text-embedding-3-large | 3072 | Dense |
| CLIP (image+text) | 512 | Dense |
| BM25 | Variable | Sparse |
Dimension Validation
Zvec validates vector dimensions at insertion time:Vector Type Conversion
Zvec automatically handles type conversions:Performance Considerations
Dense vs Sparse: When to use each
Dense vs Sparse: When to use each
Use dense vectors when:
- Working with neural network embeddings (transformers, CNNs)
- Dimensions are relatively low (< 2000)
- Most dimensions have non-zero values
- Working with keyword-based methods (BM25, TF-IDF)
- Dimensionality is very high (> 10,000)
- Most dimensions are zero (sparsity > 95%)
Choosing precision: FP32 vs FP16 vs INT8
Choosing precision: FP32 vs FP16 vs INT8
FP32 (recommended):
- Standard precision for most applications
- Good balance of accuracy and performance
- 50% memory savings
- Minimal accuracy loss for most embeddings
- Good for large-scale deployments
- 75% memory savings
- Requires quantization-aware training or calibration
- Best for extreme memory constraints
Memory usage calculation
Memory usage calculation
Calculate memory per vector:
Vector normalization
Vector normalization
Some distance metrics benefit from normalized vectors:
Best Practices
Match vector type to your embedding model
Choose the data type that matches your embedding model’s output:
- Most transformer models →
VECTOR_FP32 - BM25/TF-IDF →
SPARSE_VECTOR_FP32
Validate dimensions before insertion
Ensure your vectors match the schema’s dimension before inserting:
Use consistent precision
Don’t mix precision levels for the same field. If you define
VECTOR_FP32, always insert FP32 vectors.Consider memory constraints
For large collections (millions of vectors), consider:
- Using FP16 instead of FP32 (50% memory savings)
- Quantizing to INT8 (75% memory savings)
- Using sparse vectors for high-dimensional data
Next Steps
Indexing
Learn how to index vectors for fast similarity search
Querying
Execute vector similarity searches
Schemas
Understand how to define vector fields in schemas
Collections
Work with collections containing vectors