lab 1
!pip install gensim nltk transformers torch matplotlib scikit-learn
import gensim.downloader as api
model = api.load("glove-wiki-gigaword-50")
w1, w2, w3 = "king", "man", "woman"
vec = model[w1] - model[w2] + model[w3]
word = model.most_similar([vec], topn=1)[0][0]
print(f"{w1} - {w2} + {w3} ≈ {word}")
Comments
Post a Comment