IML | Week 3: ml5.js Project – Naive Doc2Vec Calculator – Yufeng

Introduction

A proper Doc2Vec is an unsupervised model that vectorize a paragraph. It is built upon sophisticated design to analyze the context of the given text.

On the contrary, the Naive Doc2Vec Calculator utilizes the sole Word2Vec model with ml5.js which is a naive but fun implementation with no contextual understanding at all. Getting excited? Try Naive Doc2Vec Calculator right now. (Model hosted on Github so it takes a while to load)

It is modified based on the official tutorial code for ml5 Word2Vec.

Implementation

The calculator allows you to add, subtract, average, and find approximation of blocks of texts. It is highly responsive due to its advanced real-time text-change detection, so say goodbye to buttons.

How will it deal with operations upon two blocks with different lengths? It does it naively with a simple loop through the second subject so that the length of the result will be based on the first subject. 

Demo

Problem

You might find out in the demo video that sometimes the result length does not line up with the source. That is because the error handling functionality under the Word2Vec methods is not implemented (yet). That is, if the model fails to add/subtract the subjects (when the input is invalid), it will not be returned.

Leave a Reply