mirror of
https://github.com/asg017/sqlite-vec.git
synced 2026-04-25 08:46:49 +02:00
Add approximate nearest neighbor infrastructure to vec0: shared distance dispatch (vec0_distance_full), flat index type with parser, NEON-optimized cosine/Hamming for float32/int8, amalgamation script, and benchmark suite (benchmarks-ann/) with ground-truth generation and profiling tools. Remove unused vec_npy_each/vec_static_blobs code, fix missing stdint.h include.
14 lines
419 B
Python
14 lines
419 B
Python
from typing import List
|
|
from struct import pack
|
|
|
|
|
|
def serialize_float32(vector: List[float]) -> bytes:
|
|
"""Serializes a list of floats into the "raw bytes" format sqlite-vec expects"""
|
|
return pack("%sf" % len(vector), *vector)
|
|
|
|
|
|
def serialize_int8(vector: List[int]) -> bytes:
|
|
"""Serializes a list of integers into the "raw bytes" format sqlite-vec expects"""
|
|
return pack("%sb" % len(vector), *vector)
|
|
|
|
|