fasttext-rs
Pure Rust implementation of fastText
Installation
Add it to your Cargo.toml:
[]
= "0.8"
Usage
Training a model
use FastText;
use ;
let mut args = default;
args.input = "data.txt".into;
args.model = Supervised;
args.epoch = 25;
args.lr = 1.0;
let model = train.unwrap;
model.save_model.unwrap;
Loading and predicting
use FastText;
let model = load_model.unwrap;
let predictions = model.predict;
for pred in &predictions
Nearest neighbors
use FastText;
let model = load_model.unwrap;
let neighbors = model.get_nn;
for in &neighbors
CLI
A command-line tool compatible with the C++ fastText CLI is available behind the cli feature:
It supports C++-style single-dash flags (e.g. -epoch 25) as well as standard double-dash flags (--epoch 25):
License
This work is released under the MIT license. A copy of the license is provided in the LICENSE file.