Sobes.tech
Middle

What is word2vec?

sobes.tech AI

Answer from AI

Word2Vec is a method of representing words as vectors of fixed dimensionality, which allows modeling semantic relationships between words.

The main idea is to train a neural network to predict the context of a word (or the word itself based on context), resulting in each word having a vector that reflects its semantic proximity to other words.

Example of using Word2Vec:

from gensim.models import Word2Vec

sentences = [['I', 'love', 'machine', 'learning'], ['machine', 'learning', 'is', 'useful']]
model = Word2Vec(sentences, vector_size=50, window=2, min_count=1, workers=4)

vector = model.wv['machine']  # Get vector for the word "machine"
similar_words = model.wv.most_similar('machine')  # Find similar words

Word2Vec is widely used in NLP for classification, clustering, and finding similar words.