node-fasttext
Nodejs binding for fasttext representation and classification.
This is a link to the Facebook fastText. A Library for efficient text classification and representation learning.
- FASTTEXT_VERSION = 12;
- FASTTEXT_FILEFORMAT_MAGIC_INT32 = 793712314;
Installation
Using npm:
npm install fasttext --save
fastText Classifier
According to fasttext.cc. We have a simple classifier for executing prediction models about cooking
from stackexchange questions:
const path = ;const fastText = ; const model = path;const classifier = model; classifier ;
The model haved trained before with the followings params:
const path = ;const fastText = ; let data = path;let model = path; let classifier = ;let options = input: data output: model loss: "softmax" dim: 200 bucket: 2000000 classifier ;
Or you can train directly from the command line with fasttext builded from official source:
# Training ~/fastText/data$ ./fasttext supervised -input cooking.train -output model_cooking -lr 1.0 -epoch 25 -wordNgrams 2 -bucket 200000 -dim 50 -loss hsRead 0M wordsNumber of words: 8952Number of labels: 735Progress: 100.0% words/sec/thread: 1687554 lr: 0.000000 loss: 5.247591 eta: 0h0m 4m # Testing ~/fastText/data$ ./fasttext test model_cooking.bin cooking.validN 3000P@1 0.587R@1 0.254Number of examples: 3000
Nearest neighbor
Simple class for searching nearest neighbors:
const path = ;const fastText = ; const model = path;const query = model; query;
Build from source
See Installation Prerequisites.
# install dependencies and tools npm install # build node-fasttext from source npm run build # run unit-test npm test
Contributing
Pull requests and stars are highly welcome.
For bugs and feature requests, please create an issue.