Interface for using the canonical C GloVe embedding implementation in Python
Project description
glovpy
Package for interfacing Stanford's C GloVe implementation from Python.
Installation
Install glovpy from PyPI:
pip install glovpy
Additionally the first time you import glopy it will build GloVe from scratch on your system.
Requirements
We highly recommend that you use a Unix-based system, preferably a variant of Debian.
The package needs git
, make
and a C compiler (clang
or gcc
) installed.
Example Usage
Here's a quick example of how to train GloVe on 20newsgroups using Gensim's tokenizer.
from gensim.utils import tokenize
from sklearn.datasets import fetch_20newsgroups
from glovpy import GloVe
texts = fetch_20newsgroups().data
corpus = [list(tokenize(text, lowercase=True, deacc=True)) for text in texts]
model = GloVe(vector_size=25)
model.train(corpus)
for word, similarity in model.wv.most_similar("god"):
print(f"{word}, sim: {similarity}")
word | similarity |
---|---|
existence | 0.9156746864 |
jesus | 0.8746870756 |
lord | 0.8555182219 |
christ | 0.8517201543 |
bless | 0.8298447728 |
faith | 0.8237065077 |
saying | 0.8204566240 |
therefore | 0.8177698255 |
desires | 0.8094088435 |
telling | 0.8083973527 |
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
glovpy-0.1.0.tar.gz
(5.8 kB
view hashes)
Built Distribution
glovpy-0.1.0-py3-none-any.whl
(6.4 kB
view hashes)