YogGoPoTh: learning Transformers with the Cthulhu Mythos!
Project description
YogGoPoTh - learning Transformers with the Cthulhu Mythos!
There it was the once I had disglard of that as a daper and cristantent, the tant me trurry that years tabs is deark from a small Noth-eyirly dub to that for the eyard both the land to himself horry bowledge the nolight.
— ygpt-0.1-32-64
My eyes of the infinite basement raised me for the distant corridor. When it could not have to retain, I saw it pass that the ship gave me several actions so even that the curse would never shudder. It seemed something in amused already inside and reality as in my training feet, and myself. That fiendish galley of the gods had burnt a paper of north American in the older trees of Arkham.
— ygpt-0.1-big
Intro
This is a simple implementation of a Transformer encoder model for text generation, based on Andrej Karpathy's "Let's build GPT" video https://www.youtube.com/watch?v=kCc8FmEb1nY&t=970s. While it can be trained on any text, I used the Lovecraft Cthulhu Mythos corpus for training, which made the not-quite-English outputs it produces very fitting (and a bit disturbing).
Usage
Installation
- Create a virtual environment and activate it
- Install the package into the environment with
make install
(ormake install-dev
to install in the editable mode)
Training
- Download the Cthulhu Mythos corpus from https://www.hplovecraft.com/writings/texts/. Cleaning and concatenating the texts is left as an exercise to the reader.
- Train the model with
python -m yoggopoth train path/to/corpus.txt -s path/to/save/model
The training produces two files: model.pth
with the saved model and model.vocab
with the vocabulary.
The hyperparameters can be adjusted by passing them as the -p
argument, e.g. python -m yoggopoth train path/to/corpus.txt -s path/to/save/model -p '{"n_layers": 4, "n_heads": 8}'
. The full list of parameters can be found in yoggopoth/settings.py
.
Full help available by running python -m yoggopoth train -h
.
Generation
- Generate text with
python -m yoggopoth gen path/to/model
Optional parameters: -f
to set the initial text, -t
to set the length of the generated text, --stream
to enable streaming output (default), --nostream
to disable.
Full help available by running python -m yoggopoth gen -h
.
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
Built Distribution
Hashes for yoggopoth-0.0.2-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | cca333d2c1a237447e8359c02e0d6a1791cef327012f871bbd51bcad2ab29c87 |
|
MD5 | 5062c13a543e2598868fffee8d16275b |
|
BLAKE2b-256 | 3070c33beb36289d824e61b29ec90fdffc9c8b2700982db6de60fb7094288cb0 |