def predict(self, seq1, seq2): seq1 = seq1 + 1e-8 seq2 = seq2 + 1e-8 #smooth to avoid NaN score = 1 - cosine(seq1, seq2) return score