Background Knowledge
Glossary
| Term | Description |
|---|---|
| Flat | Brute-force search. No complex index structure is built. The query vector is compared against all vectors in the base library one by one to compute distances. It features 100% recall (absolutely precise), but has high computational overhead and latency. It is commonly used for small-scale datasets or as an accuracy baseline for other algorithms. |
| INT8 | 8-bit integer format. A low-precision data type that reduces memory usage by 75% compared to standard FP32 (32-bit floating point) and improves computational throughput. It is commonly used as a quantized data storage format to balance performance and precision in hardware-constrained scenarios. |
| IVF (Inverted File) | Inverted file index. A classic acceleration method for approximate nearest neighbor search (ANNS). It partitions the vector space into multiple clusters using a clustering algorithm (similar to a directory). During retrieval, only the most relevant clusters are traversed, significantly reducing computation. It trades a small amount of precision for greatly improved retrieval performance. |
| PQ (Product Quantization) | Product quantization. An efficient deep vector compression algorithm. It splits high-dimensional vectors into multiple low-dimensional subspaces and builds codebooks for quantization encoding in each subspace. It can greatly reduce memory consumption (typically by tens of times) and is a core technology for handling vector retrieval at the billion-scale and beyond. |
| SQ (Scalar Quantization) | Scalar quantization. A vector compression algorithm that reduces memory usage by independently mapping each dimension of an FP32 vector to a finite set of integers (such as INT8). Compared to PQ, SQ is simpler to implement and offers faster query speeds, making it suitable for approximate retrieval scenarios that require a certain level of precision. |
| RaBitQ (Random Binary Quantization) | Random binary quantization. A cutting-edge extreme compression retrieval algorithm. It compresses FP32 vectors into 1-bit binary representations through mathematical transformations (theoretical compression ratio of 32x) and uses fast Hamming distance for initial screening. It significantly reduces memory bandwidth pressure and storage costs while maintaining high recall rates. |
| Cagra | Graph-based approximate nearest neighbor search algorithm. It organizes base library vectors by constructing a neighbor graph. During retrieval, it iteratively searches along graph edges, gradually approaching the nearest neighbors. Compared to IVF-based methods, graph retrieval offers better search efficiency in low-latency scenarios and is suitable for high-performance approximate retrieval with billion-level base libraries. |
| BinaryFlat | Binary brute-force retrieval. An exhaustive search algorithm designed specifically for binary vectors. Vectors consist of 0s and 1s, and similarity is calculated using Hamming distance. Because it uses bitwise operations (XOR) at the low level, it is extremely fast and has very low memory usage, making it suitable for binary feature scenarios such as image fingerprinting. |
| L2 (Euclidean Distance) | Euclidean distance. Measures the absolute straight-line distance between two vectors in a multi-dimensional space. A smaller distance value indicates that the two vectors are more similar. It is suitable for scenarios that focus on absolute numerical differences, such as image pixel feature comparison. |
| IP (Inner Product) | Inner product. Measures similarity by computing the dot product of two vectors. A larger inner product value indicates higher similarity. When vectors are normalized (unit length), IP is equivalent to cosine similarity. It is widely used in scenarios that focus on directional consistency, such as text semantic matching. |
| Hamming (Hamming Distance) | Hamming distance. Specifically used to measure the difference between two equal-length binary vectors. It calculates the distance by counting the number of positions where the corresponding characters differ (0 vs. 1). Fewer differing bits indicate greater similarity. It is the core metric for binary retrieval algorithms such as BinaryFlat and RaBitQ. |
Application Scenarios
| Question | Condition | Recommendation |
|---|---|---|
| Do you need exact search results? | Exact results are required | Full retrieval algorithms, index types that guarantee completely exact results. |
| Minor precision loss is acceptable | Approximate retrieval algorithms, which reduce memory usage and improve retrieval performance. | |
| How large is the base library? | 300K–1M records (small library) | AscendIndexFlat / AscendIndexSQ / AscendIndexInt8Flat and other full retrieval algorithms, offering the highest precision. |
| Tens of millions (medium library) | AscendIndexIVFSQ / AscendIndexVStar / AscendIndexGreat, compressing features to balance performance and precision, suitable for medium-scale retrieval. | |
| Hundreds of millions (large library) | AscendIndexIVFSP / AscendIndexIVFSQT / AscendIndexIVFFlat / AscendIndexIVFPQ / AscendIndexIVFRaBitQ / AscendIndexCagra, using clustering + quantization or graph indexing for extreme memory compression, supporting massive data indexing. | |
| Is device memory limited? | Sufficient memory | Full retrieval algorithms, prioritizing retrieval precision, but with the highest memory usage (except Int8Flat). |
| Limited memory | AscendIndexSQ / AscendIndexIVFFlat, sacrificing some precision with moderate memory usage. | |
| Very limited memory | Other approximate retrieval algorithms, significantly reducing memory usage, preferred for large-scale deployment. | |
| What is the feature type? | FP32 | Supports most index types, offering the broadest compatibility. |
| FP16 | AscendIndexFlat / AscendIndexILFlat, supporting L2 and Cos distances. | |
| INT8 | AscendIndexInt8Flat, designed for integer features, supporting L2 and Cos distances. | |
| Binary features | AscendIndexBinaryFlat, using Hamming distance for ultra-fast comparison. | |
| Any advanced feature requirements? | Need to filter by time/spatial attributes | AscendIndexTS, supporting multi-attribute filtered retrieval with time and spatial constraints. |
| Need to search across multiple libraries simultaneously | Use multi-Index batch retrieval related interfaces. |