Download scripts/convert-to-safensors.py from Qdrant/constella-zero: direct link, hf CLI and curl.
- Browser
- Download file 621 Bytes
-
https://huggingface.co/Qdrant/constella-zero/resolve/main/scripts/convert-to-safensors.py
- Command line
-
hf download hf://Qdrant/constella-zero/scripts/convert-to-safensors.py
-
curl -L -o convert-to-safensors.py https://huggingface.co/Qdrant/constella-zero/resolve/main/scripts/convert-to-safensors.py
621 Bytes
| #!/usr/bin/env -S uv run --script | |
| # | |
| # /// script | |
| # requires-python = ">=3.12" | |
| # dependencies = ["safetensors", "numpy"] | |
| # /// | |
| import numpy as np | |
| from safetensors.numpy import save_file | |
| d = np.load("model.npz") | |
| W = np.ascontiguousarray(d["rows_int8"]) # (30522, 1024) int8, the released table | |
| scale = d["int8_scale"].astype(np.float32) # (30522,) per-row dequantization scale | |
| assert W.shape == (30522, 1024) and W.dtype == np.int8 and scale.shape == (30522,) | |
| # FastEmbed's static models multiply each token's row by `weights`, which dequantizes it. | |
| save_file({"embeddings": W, "weights": scale}, "model.safetensors") | |