Live Demo here: https://alextobias.me/sentiment-analysis-web/predict-sentiment.html
This is a basic demo of using fasttext's webassembly module to peform sentiment analysis. All work is done in the browser with webassembly, no requests to any external sentiment analysis API are made.
- The model is trained on the Sentiment140 tweet sentiment dataset.
- By using automatic hyperparameter optimization, I was able to shrink the 1.6 million tweet model from 250MB to just 2MB, which is why it's actually possible to load it here.
- It's still by no means perfect; and I'm looking into ways to both optimize for size and improve accuracy.
Issues I had to troubleshoot with fasttext webassembly (may help if you're trying to do something similar)
- If you're trying to do this yourself, I found these notes helpful to set up and build the webassembly binaries. (I'm on ubuntu 18.04)
When trying to compile fasttext wasm, I ran into issues with my version of emscripten; fixed by installing emscripten version 2.0.3 instead.
See facebookresearch/fastText#1166
After I was able to build the fasttext wasm files (fasttext_wasm.wasm
, fasttext_wasm.js
, fasttext.js
), I got this error after trying to the http server demo:
TypeError: fastTextModule.addOnPostRun is not a function
I was able to fix this by integrating these changes:
facebookresearch/fastText#1173 (initial discovery link)
facebookresearch/fastText#1116 (see 'changed files' for what needed to change)