This folder contains an educational implementation of LSH using random hyperplanes (sign hashing) to bucketize vectors for approximate nearest neighbor search.
Key Points
Generates numBits random hyperplanes to encode vectors into binary signatures
Buckets are addressed by the signature; nearby buckets are explored by flipping bits within a radius
Query expands radius until it gathers at least k candidates, then ranks by cosine distance
API (Unified)
NewLSHIndex(d, numBits, seed) *LSHIndex
Insert(vector []float64) error
Search(query []float64, k int) ([]SearchResult, error)
GetStats() map[string]interface{}
GetNode(id int) interface{}
Usage
See examples/lsh_example.go and the repository root README for a quick start.
Notes
Distance metric for ranking is cosine distance (1 - cosine similarity)