word_vec-rs

Crates.ioword_vec-rs
lib.rsword_vec-rs
version0.1.1
sourcesrc
created_at2023-05-11 21:00:00.787124
updated_at2023-05-11 21:12:00.770562
description Memory efficient library to work with word2vec vectors
homepage
repository
max_upload_size
id862448
size61,827
Jojii (JojiiOfficial)

documentation

README

word_vec-rs

Memory efficient library to work with word vectors

Example


let space = Word2VecParser::new()
    // Parse binary file
    .binary()
    // Index terms to find vectors faster.
    .index_terms(true)
    .parse_file("./GoogleNews-vectors-negative300.bin")
    .unwrap();
   
let hello = space.find_term("hello").unwrap();
let hi = space.find_term("hi").unwrap();
println!("{}", hello.cosine(&hi));

Convert file format

// Load a space
let space = Word2VecParser::new()
    .binary()
    .index_terms(true)
    .parse_file("./GoogleNews-vectors-negative300.bin")
    .unwrap();

// export space to .vec file
let out = BufWriter::new(File::create("GoogleNews-vectors-negative300.vec").unwrap());
Exporter::new(out).export_space(&space).unwrap();

Commit count: 0

cargo fmt