Computer scienceData scienceNLPLanguage representationEmbeddings

Sentence embeddings

DBOW use

Report a typo

Write a Python program that creates embeddings for two sentences and finds their cosine similarity.

Train a Doc2Vec model using the Distributed Bag of Words (DBOW) approach by setting the dm parameter appropriately and get embeddings for these sentences:

  • Development of the system was hampered by a failure in the database

  • System development paused due to pending tasks

When training the model, ensure that you only use the following parameters:

  • documents: a list of sentences

  • vector_size: set to 10

  • min_count: set to 1

  • dm: set to the right value to use the DBOW approach

Calculate the cosine similarity between the embeddings of the two sentences and save the received value to the variable:

cosine_similarity = ... 

You don't need to print anything.

Write a program in Python 3
from gensim.test.utils import common_texts
from gensim.models.doc2vec import Doc2Vec, TaggedDocument

Create a free account to access the full topic