|
Download README.md from Veritone/embedding-rotations: direct link, hf CLI and curl.
- Browser
- Download file 1.63 kB
-
https://huggingface.co/Veritone/embedding-rotations/resolve/main/README.md
- Command line
-
hf download hf://Veritone/embedding-rotations/README.md
-
curl -L -o README.md https://huggingface.co/Veritone/embedding-rotations/resolve/main/README.md
1.63 kB
metadata
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/<dim>.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)
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("<f4")
Generated once on 2026-10-01 with numpy 2.5.3. Do not regenerate it to "verify" it: QR output is not bit-stable across numpy and BLAS versions. Load the file and check the sha256 instead.
Applying it
- One vector:
v_rot = R @ v. A batch of row vectors:V_rot = V @ R.T. - Never truncate a rotated vector (no Matryoshka cut): the rotation mixes all dimensions, so the first k dimensions of a rotated vector are not a smaller embedding.
- Normalization commutes with the rotation, so it can happen before or after.
License
Apache-2.0.