3 ms·
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};cossi
by eismcc 3y 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/cosine_similarity.kg https://github.com/briangu/klongpy/blob/main/examples/ml/cos...
- ashvardanian 3y agoInteresting! 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 https://unum-cloud.github.io/docs/usearch/python/index.html Maybe KlongPy can be the next one ;)
- eismcc 3y agoI 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.