Crates.io | word_vec-rs |
lib.rs | word_vec-rs |
version | 0.1.1 |
source | src |
created_at | 2023-05-11 21:00:00.787124 |
updated_at | 2023-05-11 21:12:00.770562 |
description | Memory efficient library to work with word2vec vectors |
homepage | |
repository | |
max_upload_size | |
id | 862448 |
size | 61,827 |
Memory efficient library to work with word vectors
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));
// 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();