# ---
# jupyter:
#   jupytext:
#     text_representation:
#       extension: .py
#       format_name: light
#       format_version: '1.5'
#       jupytext_version: 1.14.4
#   kernelspec:
#     display_name: Python 3
#     language: python
#     name: python3
# ---

from gensim.models import KeyedVectors

# We will load only first 1000 (top 1000) vectors from python fasttext (128) model

model = KeyedVectors.load_word2vec_format("../model.vec", binary=False, limit=1000)

# In case you are loading GloVe embeddings, you need to convert it first

tmpfile=get_tmpfile("source2vec")
glove2word2vec(datapath("../glove_model.txt"), tmpfile)
model = KeyedVectors.load_word2vec_format(tmpfile, binary=False, limit=1000)

# Now we can do fancy staff

model.most_similar("for")

model.most_similar_cosmul("for")

model.doesnt_match(["for", "i", "a"])

model.similarity("for", "i")

model.similar_by_word("for")

# Raw vector values

for word in model.vocab:
    print(word, ":", model[word])
    break # only first one now

StarcoderdataJupyterScriptsDedupFiltered