Hi i have a situation where i have a mongodb from which im getting sentences and saving into list.
After that i have a sentence which exists in the list. but when i create vectors different vectors seemed to be created and cosine distance also changes as the vectors are different where the cosine value should be 0 but getting 0.22
from scipy import spatial
from sent2vec.vectorizer import Vectorizer
from pymongo import MongoClient
# Connecting to local mongo
client = MongoClient('localhost', 27017)
database = client['test']
collection = database['test']
cursor = collection.find({})
#empty list to append the data from mongo
info = []
#test data
info1 = ['hello im john',]
info2 = ['hello im john',]
for document in cursor:
info.append(str(document["title"]))
# break
print(info) #check the data
print(info1)
vectorizer = Vectorizer()
vectorizer.run(info)
vectors_info = vectorizer.vectors #mongo data vectors
vectorizer = Vectorizer()
vectorizer.run(info1)
vectors_info1 = vectorizer.vectors #test data vectors
#comparing the vectors
print(vectors_info[0]==vectors_info1[0])
vectorizer = Vectorizer()
vectorizer.run(info2)
vectors_info2 = vectorizer.vectors
#comparing same text again
print(vectors_info1[0]==vectors_info2[0])
Hi i have a situation where i have a mongodb from which im getting sentences and saving into list. After that i have a sentence which exists in the list. but when i create vectors different vectors seemed to be created and cosine distance also changes as the vectors are different where the cosine value should be 0 but getting 0.22
output :