--- library_name: keras tags: - keras --- ## Model description This model demonstrates the [Node2Vec](https://snap.stanford.edu/node2vec/) technique on the small version of the [Movielens dataset](https://files.grouplens.org/datasets/movielens/ml-latest-small-README.html) to learn movie embeddings. ### Node2Vec Technique [Node2Vec](https://arxiv.org/abs/1607.00653) is a simple, yet scalable and effective technique for learning low-dimensional embeddings for nodes in a graph by optimising a neighbourhood-preserving objective. The aim is to learn similar embeddings for neighbouring nodes, with respect to the graph structure. Given your data items structured as a graph (where the items are represented as nodes and the relationship between items are represented as edges), node2vec works as follows: - Generate item sequences using (biased) random walk. - Create positive and negative training examples from these sequences. - Train a [word2vec](https://www.tensorflow.org/tutorials/text/word2vec) model (skip-gram) to learn embeddings for the items. This model is an example of applying [Node2Vec](https://arxiv.org/abs/1607.00653) technique on the small version of the [Movielens dataset](https://files.grouplens.org/datasets/movielens/ml-latest-small-README.html) to learn movie embeddings. Such a dataset can be represented as a graph by treating the movies as nodes, and creating edges between movies that have similar ratings by the users. The learnt movie embeddings can be used for tasks such as movie recommendation, or movie genres prediction. For more information on Node2Vec, please refer to its [host page](https://snap.stanford.edu/node2vec/) ### Skip-Gram Model Our skip-gram is a simple binary classification model that works as follows: - An embedding is looked up for the target movie. - An embedding is looked up for the context movie. - The dot product is computed between these two embeddings. - The result (after a sigmoid activation) is compared to the label. - A binary crossentropy loss is used. ### Model Plot
View Model Plot ![Model Image](./model.png)
## Credits Author: [Khalid Salama](https://www.linkedin.com/in/khalid-salama-24403144/). Based on the following Keras example [Graph representation learning with node2vec](https://keras.io/examples/graph/node2vec_movielens/) by Khalid Salama Check out the demo space [here](https://huggingface.co/spaces/keras-io/Node2Vec_MovieLens)