Skip to main content

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

  1. Create a virtual environment and activate it
  2. Install the package into the environment with make install (or make install-dev to install in the editable mode)

Training

  1. 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.
  2. 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

  1. 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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

yoggopoth-0.0.2.tar.gz (9.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

yoggopoth-0.0.2-py3-none-any.whl (8.6 kB view details)

Uploaded Python 3

File details

Details for the file yoggopoth-0.0.2.tar.gz.

File metadata

  • Download URL: yoggopoth-0.0.2.tar.gz
  • Upload date:
  • Size: 9.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.9.5

File hashes

Hashes for yoggopoth-0.0.2.tar.gz
Algorithm Hash digest
SHA256 ae28a6fa2aad7220483370f402acac52fb7506db2b0237e310005133b2e43ec0
MD5 f8e8ab93f4a9f1a41680193cb6bb3ed2
BLAKE2b-256 e200b9533a5724dfa58419d3787c6aa667e18f0c6173af9114179dbd4c9d6035

See more details on using hashes here.

File details

Details for the file yoggopoth-0.0.2-py3-none-any.whl.

File metadata

  • Download URL: yoggopoth-0.0.2-py3-none-any.whl
  • Upload date:
  • Size: 8.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.9.5

File hashes

Hashes for yoggopoth-0.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 cca333d2c1a237447e8359c02e0d6a1791cef327012f871bbd51bcad2ab29c87
MD5 5062c13a543e2598868fffee8d16275b
BLAKE2b-256 3070c33beb36289d824e61b29ec90fdffc9c8b2700982db6de60fb7094288cb0

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page