Thank you! In my case i will work locally with less than 100k vectors.
I will search similarities with this code in php, by loading all the vectors in a array.
function cosine_similarity($vector1, $vector2) {
$dot_product = 0.0;
$norm1 = 0.0;
$norm2 = 0.0;
// Check that the two vectors have the same size
if (count($vector1) !== count($vector2)) {
throw new Exception("vectors are different");
}
// Calculates the dot product, norm of the vectors
for ($i = 0; $i < count($vector1); $i++) {
$dot_product += $vector1[$i] * $vector2[$i];
$norm1 += pow($vector1[$i], 2);
$norm2 += pow($vector2[$i], 2);
}
// Calculate cosine similarity
$similarity = $dot_product / (sqrt($norm1) * sqrt($norm2));
return $similarity;
}
do you think it will work?