Hacker News new | ask | show | jobs
by eismcc 908 days ago
Since NumPy is called out here, I wrote an example in KlongPy which is NumPy backed and got about 1ns/iter on my M2 Studio:

dot::{+/xy};mag::{(+/xx)^0.5};cossim::{dot(x;y)%mag(x)*mag(y)};cd::{1-cossim(x;y)}

https://github.com/briangu/klongpy/blob/main/examples/ml/cos...

1 comments

Interesting! Haven't heard of KlongPy before!

We currently support several techniques if you want to provide custom distance functions to USearch, instead of using the default SimSIMD variants. At this point its Numba, Cppyy, and PeachPy: https://unum-cloud.github.io/docs/usearch/python/index.html

Maybe KlongPy can be the next one ;)

I was mainly surprised how fast NumPy can be if you push it. KlongPy is effectively a NumPy DSL (array language). So vector thinking is natural.