All Projects → vunb → node-fasttext

vunb / node-fasttext

Licence: MIT License
Nodejs binding for fasttext representation and classification.

Programming Languages

C++
36643 projects - #6 most used programming language
python
139335 projects - #7 most used programming language
javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to node-fasttext

Fasttext.py
A Python interface for Facebook fastText
Stars: ✭ 1,091 (+2697.44%)
Mutual labels:  classifier, text-classification, fasttext
Text Classification Demos
Neural models for Text Classification in Tensorflow, such as cnn, dpcnn, fasttext, bert ...
Stars: ✭ 144 (+269.23%)
Mutual labels:  text-classification, fasttext
Fasttext.js
FastText for Node.js
Stars: ✭ 127 (+225.64%)
Mutual labels:  text-classification, fasttext
Whatlang Rs
Natural language detection library for Rust. Try demo online: https://www.greyblake.com/whatlang/
Stars: ✭ 400 (+925.64%)
Mutual labels:  classifier, text-classification
support-tickets-classification
This case study shows how to create a model for text analysis and classification and deploy it as a web service in Azure cloud in order to automatically classify support tickets. This project is a proof of concept made by Microsoft (Commercial Software Engineering team) in collaboration with Endava http://endava.com/en
Stars: ✭ 142 (+264.1%)
Mutual labels:  classifier, text-classification
Keras Textclassification
中文长文本分类、短句子分类、多标签分类、两句子相似度(Chinese Text Classification of Keras NLP, multi-label classify, or sentence classify, long or short),字词句向量嵌入层(embeddings)和网络层(graph)构建基类,FastText,TextCNN,CharCNN,TextRNN, RCNN, DCNN, DPCNN, VDCNN, CRNN, Bert, Xlnet, Albert, Attention, DeepMoji, HAN, 胶囊网络-CapsuleNet, Transformer-encode, Seq2seq, SWEM, LEAM, TextGCN
Stars: ✭ 914 (+2243.59%)
Mutual labels:  text-classification, fasttext
Ai law
all kinds of baseline models for long text classificaiton( text categorization)
Stars: ✭ 243 (+523.08%)
Mutual labels:  text-classification, fasttext
Shallowlearn
An experiment about re-implementing supervised learning models based on shallow neural network approaches (e.g. fastText) with some additional exclusive features and nice API. Written in Python and fully compatible with Scikit-learn.
Stars: ✭ 196 (+402.56%)
Mutual labels:  text-classification, fasttext
Nepali-News-Classifier
Text Classification of Nepali Language Document. This Mini Project was done for the partial fulfillment of NLP Course : COMP 473.
Stars: ✭ 13 (-66.67%)
Mutual labels:  classifier, text-classification
ML4K-AI-Extension
Use machine learning in AppInventor, with easy training using text, images, or numbers through the Machine Learning for Kids website.
Stars: ✭ 18 (-53.85%)
Mutual labels:  classifier, text-classification
Text classification
all kinds of text classification models and more with deep learning
Stars: ✭ 7,179 (+18307.69%)
Mutual labels:  text-classification, fasttext
extremeText
Library for fast text representation and extreme classification.
Stars: ✭ 141 (+261.54%)
Mutual labels:  text-classification, fasttext
Bert language understanding
Pre-training of Deep Bidirectional Transformers for Language Understanding: pre-train TextCNN
Stars: ✭ 933 (+2292.31%)
Mutual labels:  text-classification, fasttext
Fastrtext
R wrapper for fastText
Stars: ✭ 103 (+164.1%)
Mutual labels:  text-classification, fasttext
Textclassification Keras
Text classification models implemented in Keras, including: FastText, TextCNN, TextRNN, TextBiRNN, TextAttBiRNN, HAN, RCNN, RCNNVariant, etc.
Stars: ✭ 621 (+1492.31%)
Mutual labels:  text-classification, fasttext
Ml Classify Text Js
Machine learning based text classification in JavaScript using n-grams and cosine similarity
Stars: ✭ 38 (-2.56%)
Mutual labels:  classifier, text-classification
nlpbuddy
A text analysis application for performing common NLP tasks through a web dashboard interface and an API
Stars: ✭ 115 (+194.87%)
Mutual labels:  text-classification, fasttext
text2class
Multi-class text categorization using state-of-the-art pre-trained contextualized language models, e.g. BERT
Stars: ✭ 15 (-61.54%)
Mutual labels:  classifier, text-classification
Computer-Vision-Project
The goal of this project was to develop a Face Recognition application using a Local Binary Pattern approach and, using the same approach, develop a real time Face Recognition application.
Stars: ✭ 20 (-48.72%)
Mutual labels:  classifier
text-classification-svm
The missing SVM-based text classification module implementing HanLP's interface
Stars: ✭ 46 (+17.95%)
Mutual labels:  text-classification

node-fasttext

Nodejs binding for fasttext representation and classification.

MIT License npm version downloads Travis Appveyor

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 = require('path');
const fastText = require('fasttext');

const model = path.resolve(__dirname, './model_cooking.bin');
const classifier = new fastText.Classifier(model);

classifier.predict('Why not put knives in the dishwasher?', 5)
    .then((res) => {
        if (res.length > 0) {
            let tag = res[0].label; // __label__knives
            let confidence = res[0].value // 0.8787146210670471
            console.log('classify', tag, confidence, res);
        } else {
            console.log('No matches');
        }
    });

The model haved trained before with the followings params:

const path = require('path');
const fastText = require('fasttext');

let data = path.resolve(path.join(__dirname, '../data/cooking.train.txt'));
let model = path.resolve(path.join(__dirname, '../data/cooking.model'));

let classifier = new fastText.Classifier();
let options = {
    input: data,
    output: model,
    loss: "softmax",
    dim: 200,
    bucket: 2000000
}

classifier.train('supervised', options)
    .then((res) => {
        console.log('model info after training:', res)
        // Input  <<<<< C:\projects\node-fasttext\test\data\cooking.train.txt
        // Output >>>>> C:\projects\node-fasttext\test\data\cooking.model.bin
        // Output >>>>> C:\projects\node-fasttext\test\data\cooking.model.vec
    });

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 hs
Read 0M words
Number of words:  8952
Number of labels: 735
Progress: 100.0%  words/sec/thread: 1687554  lr: 0.000000  loss: 5.247591  eta: 0h0m 4m

# Testing
~/fastText/data$ ./fasttext test model_cooking.bin cooking.valid
N       3000
P@1     0.587
R@1     0.254
Number of examples: 3000

Nearest neighbor

Simple class for searching nearest neighbors:

const path = require('path');
const fastText = require('fasttext');

const model = path.resolve(__dirname, './skipgram.bin');
const query = new fastText.Query(model);

query.nn('word', 5, (err, res) => {
    if (err) {
        console.error(err);
    } else if (res.length > 0) {
        let tag = res[0].label; // letter
        let confidence = res[0].value // 0.99992
        console.log('Nearest neighbor', tag, confidence, res);
    } else {
        console.log('No matches');
    }
});

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.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].