Embedding systems can become expensive for a reason that has little to do with the embedding model itself: storing and scanning the vectors. A collection of millions of dense vectors can consume gigabytes even before an index adds its own data structures. Moving those vectors through memory can also become part of query latency.
Scalar quantization reduces that cost by representing each embedding coordinate with fewer bits. Instead of storing every coordinate as a 32-bit floating-point value, a system might map it to an 8-bit integer and keep enough information to approximately reconstruct or compare the original value.
The saving is straightforward; the quality trade-off is not. Quantization introduces approximation error, and retrieval depends on many small coordinate contributions adding up to a similarity score. This article builds a practical mental model for scalar quantization, works through a small example, and shows how to decide whether the memory and bandwidth savings are worth the change in retrieval quality.
Start with the storage problem
Suppose an embedding model produces vectors with 768 dimensions. Storing each coordinate as a 32-bit float requires:
768 dimensions * 4 bytes = 3,072 bytes per vectorIgnoring metadata and index overhead, one million vectors require about 3.07 GB in decimal units.
If each coordinate can instead be represented with one byte, the quantized payload becomes:
768 dimensions * 1 byte = 768 bytes per vectorThat is one quarter of the raw vector payload. The complete system will not necessarily shrink by exactly 4x because identifiers, metadata, index structures, alignment, and quantization parameters also consume space.
The important mental model is therefore:
floating-point vector
|
| map each coordinate to one of a limited set of values
v
compact quantized vector
|
| approximate scoring or reconstruction
v
similarity estimateQuantization trades numerical precision for a smaller representation. It does not change the semantic objective of the embedding model, and it does not create information that the original embedding failed to encode.
Quantize one coordinate before thinking about a whole vector
A simple uniform quantizer divides a numeric interval into evenly spaced levels. Assume, purely for teaching, that every coordinate is known to lie between -1 and 1, and we want only eight possible levels.
One convenient mapping uses integer codes from 0 through 7. The step size is:
step = (max - min) / (levels - 1)
= (1 - (-1)) / 7
= 2 / 7
~= 0.2857For a value x, a simple encoder is:
q = round((x - min) / step)with q clipped to the valid code range. Approximate reconstruction is:
x_hat = min + q * stepTake x = 0.40:
q = round((0.40 - (-1)) / 0.2857)
= round(4.9)
= 5
x_hat = -1 + 5 * 0.2857
~= 0.4286The stored code represents 0.40 approximately as 0.4286. The difference, about 0.0286, is quantization error.
Real systems often use more levels, different ranges, or different calibration rules. The example is intentionally small so the lossy step is visible.
Extend the same idea to an embedding
Consider a four-dimensional embedding:
[0.40, -0.73, 0.12, 0.91]Using the same eight-level quantizer over [-1, 1], the coordinates map approximately to:
0.40 -> code 5 -> 0.4286
-0.73 -> code 1 -> -0.7143
0.12 -> code 4 -> 0.1429
0.91 -> code 7 -> 1.0000The reconstructed vector is therefore approximately:
[0.4286, -0.7143, 0.1429, 1.0000]Every coordinate moved slightly. A dot product or cosine-style score computed from the reconstructed values can therefore differ from the score produced by the original vector.
That difference is the central retrieval trade-off. A large score error is not automatically harmful: if the nearest relevant document remains far ahead of every competitor, its rank may stay unchanged. A much smaller score error can matter when several candidates have nearly identical original scores and the perturbation changes their order.
For retrieval, ranking stability usually matters more than reconstructing every coordinate with tiny absolute error.
The quantization range controls two kinds of error
A uniform quantizer needs a numeric range. Choosing it creates a tension between rounding error and clipping error.
If the range is very wide, each quantization step is wider. Values remain inside the supported interval, but nearby values may collapse to the same code. This increases rounding error.
If the range is narrow, the steps become finer inside that interval. But values outside it must be clipped to an endpoint unless the representation has another way to handle them. For example, with a range of [-1, 1], an input coordinate of 1.4 cannot be represented faithfully by the eight-level scheme above; clipping maps it to the maximum level.
This is why calibration data matters. A practical quantizer should choose its parameters from data that resembles the embeddings it will encode. A range inferred from an unrepresentative sample can waste levels on values that rarely occur or clip values that occur frequently in production.
The correct calibration procedure depends on the quantizer and implementation. Do not assume that every library uses the same minimum/maximum rule simply because both produce 8-bit vectors.
Per-tensor and per-dimension scaling make different compromises
The teaching example used one shared range for every coordinate. This is often called a shared or per-tensor scale in tensor quantization terminology. It is simple and requires little side information.
But embedding dimensions do not necessarily have identical numeric distributions. Imagine two dimensions with typical ranges:
dimension A: -0.05 to 0.06
dimension B: -2.00 to 1.80A single range large enough for dimension B gives dimension A relatively coarse resolution. Using a separate scale for each dimension can allocate the available integer levels more closely to each coordinate’s observed range.
The trade-off is additional quantization metadata and potentially more work during scoring or reconstruction. Whether that overhead matters depends on the index design, hardware, batch size, and scoring implementation.
The broader lesson is that int8 describes the stored code width, not the entire quantization algorithm. Range selection, scale granularity, zero-point conventions, clipping, and scoring strategy all affect behavior.
Similarity scoring determines where approximation enters
There are several ways a vector-search system can use quantized embeddings.
One approach reconstructs approximate floating-point coordinates and then computes the usual similarity function. This is conceptually simple but may give up some of the bandwidth or compute advantage if full floating-point vectors are materialized for every candidate.
Another approach computes a similarity estimate directly from quantized representations, using arithmetic supported by the implementation. This can reduce data movement and may use efficient integer operations, but the exact performance benefit depends on hardware and software. Smaller values alone do not guarantee a faster end-to-end query.
A third pattern uses quantized vectors for candidate generation and original higher-precision vectors for rescoring. For example:
query
-> search compact quantized index
-> keep top 100 approximate candidates
-> rescore those candidates with original vectors
-> return top 10The numbers here are illustrative, not production defaults. The useful idea is separation of responsibilities: inexpensive approximate scoring narrows the search space, then higher-precision scoring repairs some ordering errors among the finalists.
Rescoring costs extra memory if the original vectors must also be retained, so it may reduce bandwidth during the broad search without delivering the maximum possible storage saving.
Normalization and quantization solve different problems
Embedding pipelines often use L2 normalization, especially when cosine-style comparison is intended. Normalization and quantization should not be treated as interchangeable operations.
L2 normalization rescales a nonzero vector so its Euclidean norm is one. It changes how magnitude participates in similarity. Quantization maps numerical values to a smaller set of representable levels. It changes numerical precision.
The order can matter because normalization changes the coordinate distribution that the quantizer sees. If an embedding model or retrieval system specifies a normalization convention, preserve that semantic contract and calibrate the quantizer for the vectors at the point where quantization actually occurs.
Also be careful about reconstructing a quantized unit vector: coordinate error can move its norm away from exactly one. Some pipelines renormalize reconstructed vectors before cosine comparison; others use scoring methods designed for their quantized representation. Follow the semantics of the implementation rather than assuming a particular correction is universal.
Measure retrieval quality, not only vector error
A quantizer can have a low average coordinate error and still damage the rankings that matter to an application. Conversely, visible coordinate error may have little effect on retrieval if relevant and irrelevant candidates are well separated.
Evaluate the quantized pipeline on the same retrieval objective used by the application. Depending on the system, useful measurements may include:
- recall at a candidate cutoff, such as whether the relevant item appears in the top
k; - ranking metrics when the order of several relevant results matters;
- overlap between high-precision and quantized nearest-neighbor sets as a diagnostic, not a substitute for relevance labels;
- end-to-end task success when retrieved items feed another component such as a RAG generator.
Keep the high-precision baseline fixed while changing the quantization scheme. Otherwise a simultaneous change to the embedding model, index parameters, or corpus can hide the source of a quality difference.
For systems that use approximate nearest-neighbor indexing, separate two sources of approximation where possible:
embedding quantization error
index search approximationIf both change at once, a recall drop cannot be attributed cleanly to either one.
Benchmark the resource you are trying to save
The raw byte calculation is useful, but production decisions need end-to-end measurements.
If memory capacity is the constraint, measure the complete resident index rather than multiplying dimensions by bytes. If latency is the constraint, measure query latency at realistic concurrency and candidate counts. If throughput is the goal, measure queries per second under the expected workload. If network transfer dominates, measure bytes moved across the relevant boundary.
Quantization can reduce memory traffic because more coordinates fit in the same amount of memory or cache. Whether that translates into lower latency depends on the rest of the pipeline. Dequantization, index traversal, filtering, metadata lookup, and reranking may dominate instead.
A useful experiment compares at least:
A: original embeddings + existing index settings
B: quantized embeddings + otherwise equivalent settings
C: quantized search + high-precision rescoring, if applicableRecord quality and resource metrics together. A smaller index is not an improvement if it pushes retrieval quality below the application’s acceptable threshold, and a tiny quality difference may be worth accepting when it removes a serious memory bottleneck.
Common mistakes hide the real trade-off
Assuming 8-bit storage means exactly 4x less total memory
The vector payload is four times smaller when moving from 32 bits to 8 bits per coordinate. The entire index usually contains more than vector payloads. Measure total storage or resident memory before claiming an end-to-end ratio.
Calibrating on arbitrary vectors
Quantization parameters derived from a different model, preprocessing path, or data distribution may not match production coordinates. Calibrate on representative embeddings produced by the same pipeline.
Comparing different similarity semantics
If the baseline uses cosine similarity over normalized vectors while the quantized path effectively uses a different scoring rule, the experiment tests more than quantization. Keep similarity semantics aligned unless changing them is intentional.
Judging quality from reconstruction error alone
Mean squared coordinate error is easy to compute, but users experience retrieval results. Include retrieval or downstream task metrics.
Quantizing both sides without checking the implementation
Some systems quantize stored document vectors while keeping the query in higher precision; others support quantized queries as well. These designs have different arithmetic and error behavior. Do not infer one from the other based only on the stored data type.
Changing quantization and index search parameters together
A faster query after lowering an approximate index’s search effort does not prove that quantization caused the speedup. Change one major variable at a time when establishing a baseline.
When scalar quantization is a good fit
Scalar quantization is worth testing when dense-vector storage or memory bandwidth is a meaningful system constraint and a small amount of score approximation is acceptable. Large retrieval collections are an obvious case because per-vector savings accumulate across many items.
It can also be useful as the broad-search stage of a two-stage design: compact vectors find a candidate set, then higher-precision data or a stronger reranker handles the final ordering.
A simpler representation is preferable when the collection is small enough that vector memory is insignificant, when operational simplicity matters more than the saving, or when measurements show that quantization does not improve the actual bottleneck. Keeping ordinary floating-point embeddings can make debugging and score interpretation easier.
Very aggressive compression also changes the problem. Scalar quantization treats coordinates individually. Methods that encode groups of dimensions jointly, binary representations, and learned compression schemes have different error and implementation trade-offs. They should be evaluated as distinct techniques rather than assumed to be drop-in extensions of the scalar method described here.
A practical evaluation workflow
For an existing embedding service, a disciplined rollout can stay small:
- Freeze the embedding model, preprocessing, similarity definition, corpus, and evaluation queries.
- Record the high-precision retrieval quality and resource baseline.
- Fit quantization parameters on representative embeddings without using the evaluation answers to tune for a favorable result.
- Build the quantized representation and measure the same quality metrics.
- Measure complete memory, latency, and throughput under a realistic workload.
- If quality drops too far, test a less aggressive quantizer or high-precision rescoring before changing unrelated retrieval components.
- Revalidate after meaningful embedding-model or data-distribution changes because the coordinate distribution may have shifted.
This process turns quantization from a datatype choice into an explicit engineering trade-off.
Conclusion
Scalar quantization compresses embeddings by mapping each coordinate from a large numeric representation to a limited set of levels. Fewer bits can substantially reduce raw vector storage and memory traffic, but the mapping introduces numerical error that can perturb similarity scores and rankings.
The practical question is not whether a quantized vector resembles its floating-point source perfectly. It is whether the compact representation preserves enough ranking quality while improving the resource that constrains the system. Start from a high-precision baseline, calibrate on representative embeddings, keep similarity semantics consistent, and evaluate retrieval quality alongside complete memory and latency measurements.