{"id":22081598,"url":"https://github.com/vunb/node-fasttext","last_synced_at":"2025-07-24T14:32:52.111Z","repository":{"id":46594762,"uuid":"111757086","full_name":"vunb/node-fasttext","owner":"vunb","description":"Nodejs binding for fasttext representation and classification.","archived":false,"fork":false,"pushed_at":"2024-02-26T07:59:39.000Z","size":41981,"stargazers_count":43,"open_issues_count":5,"forks_count":14,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-06-25T06:09:48.096Z","etag":null,"topics":["classifier","facebook-fasttext","fasttext","node-fasttext","text-classification","vntk"],"latest_commit_sha":null,"homepage":null,"language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/vunb.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-11-23T03:08:06.000Z","updated_at":"2025-02-25T02:23:25.000Z","dependencies_parsed_at":"2024-06-18T18:16:15.172Z","dependency_job_id":"684754b7-9f61-4cfc-aa68-270de0c9a5ea","html_url":"https://github.com/vunb/node-fasttext","commit_stats":{"total_commits":74,"total_committers":4,"mean_commits":18.5,"dds":0.05405405405405406,"last_synced_commit":"0f0a929d5b65a38ad3416bb6087cec2b19a55581"},"previous_names":[],"tags_count":8,"template":false,"template_full_name":null,"purl":"pkg:github/vunb/node-fasttext","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vunb%2Fnode-fasttext","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vunb%2Fnode-fasttext/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vunb%2Fnode-fasttext/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vunb%2Fnode-fasttext/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/vunb","download_url":"https://codeload.github.com/vunb/node-fasttext/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vunb%2Fnode-fasttext/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":266855914,"owners_count":23995582,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-07-24T02:00:09.469Z","response_time":99,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["classifier","facebook-fasttext","fasttext","node-fasttext","text-classification","vntk"],"created_at":"2024-11-30T23:24:41.188Z","updated_at":"2025-07-24T14:32:47.090Z","avatar_url":"https://github.com/vunb.png","language":"C++","readme":"# node-fasttext\n\nNodejs binding for fasttext representation and classification.\n\n[![MIT License](https://img.shields.io/badge/license-MIT_License-green.svg?style=flat-square)](./LICENSE)\n[![npm version](https://img.shields.io/npm/v/fasttext.svg?style=flat)](https://www.npmjs.com/package/fasttext)\n[![downloads](https://img.shields.io/npm/dm/fasttext.svg)](https://www.npmjs.com/package/fasttext)\n[![Travis](https://travis-ci.org/vunb/node-fasttext.svg?branch=master)](https://travis-ci.org/vunb/node-fasttext)\n[![Appveyor](https://ci.appveyor.com/api/projects/status/9gd460vxd6jbel14/branch/master?svg=true)](https://ci.appveyor.com/project/vunb/node-fasttext/branch/master)\n\n\u003e This is a link to the Facebook [fastText](https://github.com/facebookresearch/fastText). A Library for efficient text classification and representation learning.\n\n* FASTTEXT_VERSION = 12;\n* FASTTEXT_FILEFORMAT_MAGIC_INT32 = 793712314;\n\n# Installation\n\nUsing npm:\n\n\u003e npm install fasttext --save\n\n# fastText Classifier\n\nAccording to [fasttext.cc](https://fasttext.cc/docs/en/supervised-tutorial.html). We have a simple classifier for executing prediction models about `cooking` from stackexchange questions:\n\n```js\nconst path = require('path');\nconst fastText = require('fasttext');\n\nconst model = path.resolve(__dirname, './model_cooking.bin');\nconst classifier = new fastText.Classifier(model);\n\nclassifier.predict('Why not put knives in the dishwasher?', 5)\n    .then((res) =\u003e {\n        if (res.length \u003e 0) {\n            let tag = res[0].label; // __label__knives\n            let confidence = res[0].value // 0.8787146210670471\n            console.log('classify', tag, confidence, res);\n        } else {\n            console.log('No matches');\n        }\n    });\n```\n\nThe model haved trained before with the followings params:\n\n```js\nconst path = require('path');\nconst fastText = require('fasttext');\n\nlet data = path.resolve(path.join(__dirname, '../data/cooking.train.txt'));\nlet model = path.resolve(path.join(__dirname, '../data/cooking.model'));\n\nlet classifier = new fastText.Classifier();\nlet options = {\n    input: data,\n    output: model,\n    loss: \"softmax\",\n    dim: 200,\n    bucket: 2000000\n}\n\nclassifier.train('supervised', options)\n    .then((res) =\u003e {\n        console.log('model info after training:', res)\n        // Input  \u003c\u003c\u003c\u003c\u003c C:\\projects\\node-fasttext\\test\\data\\cooking.train.txt\n        // Output \u003e\u003e\u003e\u003e\u003e C:\\projects\\node-fasttext\\test\\data\\cooking.model.bin\n        // Output \u003e\u003e\u003e\u003e\u003e C:\\projects\\node-fasttext\\test\\data\\cooking.model.vec\n    });\n```\n\nOr you can train directly from the command line with fasttext builded from official source:\n\n```bash\n# Training\n~/fastText/data$ ./fasttext supervised -input cooking.train -output model_cooking -lr 1.0 -epoch 25 -wordNgrams 2 -bucket 200000 -dim 50 -loss hs\nRead 0M words\nNumber of words:  8952\nNumber of labels: 735\nProgress: 100.0%  words/sec/thread: 1687554  lr: 0.000000  loss: 5.247591  eta: 0h0m 4m\n\n# Testing\n~/fastText/data$ ./fasttext test model_cooking.bin cooking.valid\nN       3000\nP@1     0.587\nR@1     0.254\nNumber of examples: 3000\n```\n\n# Nearest neighbor\n\nSimple class for searching nearest neighbors:\n\n```js\nconst path = require('path');\nconst fastText = require('fasttext');\n\nconst model = path.resolve(__dirname, './skipgram.bin');\nconst query = new fastText.Query(model);\n\nquery.nn('word', 5, (err, res) =\u003e {\n    if (err) {\n        console.error(err);\n    } else if (res.length \u003e 0) {\n        let tag = res[0].label; // letter\n        let confidence = res[0].value // 0.99992\n        console.log('Nearest neighbor', tag, confidence, res);\n    } else {\n        console.log('No matches');\n    }\n});\n```\n\n# Build from source\n\nSee [Installation Prerequisites](https://github.com/nodejs/node-gyp#installation).\n\n```bash\n# install dependencies and tools\nnpm install\n\n# build node-fasttext from source\nnpm run build\n\n# run unit-test\nnpm test\n```\n\n# Contributing\n\nPull requests and stars are highly welcome.\n\nFor bugs and feature requests, please [create an issue](https://github.com/vunb/node-fasttext/issues/new).\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvunb%2Fnode-fasttext","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fvunb%2Fnode-fasttext","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvunb%2Fnode-fasttext/lists"}