π»Semantic NLP search with FAISS and VectorHub
Step 1) Encoding Data With Vectors
%%capture
!pip install vectorhub[encoders-text-tfhub]from vectorhub.encoders.text.tfhub import Bert2Vec
bert_enc = Bert2Vec()
# Words
words = [
'How can I design my own post-graduate education?',
'How could water be produced on Mars?',
'How can I fall in love?',
'How can India improve in corruption?'
]
vectors = []
# This can be optimised using list comprehension but
#we make it easier to read just for demo purposes
for word in words:
vector = bert_enc.encode(word)
vectors.append(vector)Last updated
Was this helpful?