Decode a binary blob back to a float vector.
(blob: bytes)
| 758 | |
| 759 | |
| 760 | def _decode_vector(blob: bytes) -> list[float]: |
| 761 | """Decode a binary blob back to a float vector.""" |
| 762 | n = len(blob) // 4 # 4 bytes per float32 |
| 763 | return list(struct.unpack(f"{n}f", blob)) |
| 764 | |
| 765 | |
| 766 | def _cosine_similarity(a: list[float], b: list[float]) -> float: |
no outgoing calls