File size: 428 Bytes
0f35f83
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
import numpy as np
from sklearn.metrics.pairwise import cosine_similarity

class CosineSimilarity:
    def __init__(self):
        pass

    def name(self):
        return "cosine"

    def score(self,embedding_1, embedding_2):
        embedding_1 = np.array([embedding_1])
        embedding_2 = np.array([embedding_2])
        similarity_score = cosine_similarity(embedding_1, embedding_2)
        return similarity_score[0][0]