--- license: apache-2.0 tags: - embeddings - vector-search - quantization --- # Embedding rotations Fixed orthogonal matrices for embedding vectors. Each file is a constant: an embedding space whose name ends in `-rot1` means exactly the bytes of `rot1/.npy`, forever. A different matrix gets a new transform name (`rot2`), never a new revision of this file. | Transform | Dim | File | sha256 | | --- | --- | --- | --- | | `rot1` | 768 | `rot1/768.npy` | `947552c113aff0959091773bb89536d75e8a8746112e7cd1fe8f0db0a07ad4c5` | Pin a revision when you fetch it, and check the sha256. An orthogonal matrix preserves every dot product and norm, so exact cosine search is unchanged, while it spreads energy that is concentrated in a few dimensions over all of them. That can help scalar quantization of such embeddings. ## Recipe (`rot1`) ```python rng = numpy.random.default_rng(20261001) g = rng.standard_normal((768, 768)) # float64 q, r = numpy.linalg.qr(g) q *= numpy.sign(numpy.diag(r)) # Haar-distributed (Mezzadri 2007) R = q.astype("