<jupyter_start><jupyter_text>Interactive exploration of word2vec models<jupyter_code>import os
os.chdir("../") # set working directory to the code's root directory
from gensim.models import KeyedVectors

corpusPath = "news.2007.de.shuffled" # enter your corpus here. model has to be trained first using the training notebook
modelPath = 'models/word2vec/'+corpusPath
# Load model. This may take around 10 minutes, depending on the size of the model. 
model = KeyedVectors.load_word2vec_format(modelPath)
# Get most similar words
model.most_similar(positive=['doktor'])
# Get the closest vectors to 'king - man + woman'
# Both positive and negative sets can be empty or contain an arbitrary number of words
model.most_similar(positive=['koenig', 'frau'], negative=['mann'])
# Find the odd one out
# List can have abritrary length
model.doesnt_match(["fruehstueck","muesli","abendessen", "mittagessen"])<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.09989258861439312, 'fraction_numerical': 0.00966702470461869, 'mean_word_length': 6.1692307692307695, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '247850', 'license': 'MIT', 'n_tokens_mistral': 297, 'n_tokens_neox': 282, 'n_words': 97, 'path': 'notebook/interactiveExploration.ipynb', 'repo_name': 'SebastianGer/biases-in-word-embeddings', 'size': '931'}