word2vec

Word2vec implemented in nim.

Pure Nim score 30/100 · tests present · docs generated

Summary

Latest Version Unknown
License MIT
CI Status Passing
Downloads 0
Last Indexed 2026-07-21 05:24

Installation

nimble install word2vec
choosenim install word2vec
git clone https://github.com/treeform/word2vec

OS Compatibility

Platform Linux macOS Windows FreeBSD OpenBSD NetBSD Android iOS WASM Embedded
word2vec - - - - - - -

Source

Repository https://github.com/treeform/word2vec
Homepage https://github.com/treeform/word2vec
Documentation View Documentation
Registry Source nimble_official

README

word2vec - for Nim

Word2vec Logo

nimble install word2vec

Github Actions

API reference

This library has no dependencies other than the Nim standard libarary.

About

Word2vec can be used to turn text into vectors that encode the meaning. You can use these vectors to compare similarities between texts.

Exmaple

import word2vec

load(300) # load huge binary file
let
    aVec = text2vec("Cat set on a red wall")
    bVec = text2vec("Dog set on a red fence")
# how different are they?
echo dist(aVec, bVec)

<!-- TODO:

From famous king - man + woman is queen; but why?

import word2vec

load(300) # load huge binary file
let vec = word2vec("king") - word2vec("man") + word2vec("woman")
echo vec2world(vec)
``` -->

## Getting started

This library uses alreayd created [GloVe](https://nlp.stanford.edu/projects/glove/) vectors. There is no need to train your own vectors.

Beforey you start you need to download and convert:
* Download the GloVe vectors: https://nlp.stanford.edu/projects/glove/
* Unzip the `glove.6B.zip`
* Run word2vecloader.nim to convert text files into faster to load binary files.

```sh
mkdir glovebin
cd glovebin
wget http://nlp.stanford.edu/data/glove.6B.zip
unzip glove.6B.zip
cd ..
nim c -r tools/word2vecloader.nim