Skip to main content

GeNN

GitHub license

GeNN (generative neural networks) is a high-level interface for text applications using PyTorch RNN's.

Features

  1. Preprocessing:
    • Parsing txt, json, and csv files.
    • NLTK, regex and spacy tokenization support.
    • GloVe and fastText pretrained embeddings, with the ability to fine-tune for your data.
  2. Architectures and customization:
    • GPT-2 with small, medium, and large variants.
    • LSTM and GRU, with variable size.
    • Variable number of layers and batches.
    • Dropout.
  3. Text generation:
    • Random seed sampling from the n first tokens in all instances, or the most frequent token.
    • Top-K sampling for next token prediction with variable K.
    • Nucleus sampling for next token prediction with variable probability threshold.

Getting started

How to install

pip install genn

Prerequisites

  • PyTorch 1.4.0
pip install torch==1.4.0
  • Pytorch Transformers
pip install pytorch_transformers
  • NumPy
pip install numpy
  • fastText
pip install fasttext

Use the package manager pip to install genn.

Usage

from genn import Preprocessing, LSTMGenerator, GPT2
#LSTM example
ds = Preprocessing("data.txt")
gen = LSTMGenerator(ds, nLayers = 2,
                        batchSize = 16,
                        embSize = 64,
                        lstmSize = 16,
                        epochs = 20)

#Train the model
gen.run()

# Generate 5 new documents
print(gen.generate_document(5))

#GPT-2 example
gen = GPT2("data.txt",
 	    taskToken = "Movie:",
	    epochs = 7,
	    variant = "medium")
#Train the model
gen.run()

#Generate 10 new documents
print(gen.generate_document(10))

For more examples on how to use Preprocessing, please refer to this file.

For more examples on how to use LSTMGenerator and GRUGenerator, please refer to this file.

For more examples on how to use GPT2, please refer to this file

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

License

Distributed under the MIT License. See LICENSE for more information.

Download files

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

Source Distribution

abdoTheBest-0.7.9.tar.gz (11.8 kB view details)

Uploaded Source

Built Distribution

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

abdoTheBest-0.7.9-py3-none-any.whl (15.2 kB view details)

Uploaded Python 3

File details

Details for the file abdoTheBest-0.7.9.tar.gz.

File metadata

  • Download URL: abdoTheBest-0.7.9.tar.gz
  • Upload date:
  • Size: 11.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.23.0 setuptools/47.1.1 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.7.7

File hashes

Hashes for abdoTheBest-0.7.9.tar.gz
Algorithm Hash digest
SHA256 7feec9ef9f5224062375563c46d0bf9f177d3c3721b77f0ef6106803a898123a
MD5 5f15b0e4964b5d960e33bbea2fc960e2
BLAKE2b-256 dff8030f99a6e43a9bb9c0ff6aa698fa7c1b8877237da9ca95c412e64d6be8b0

See more details on using hashes here.

File details

Details for the file abdoTheBest-0.7.9-py3-none-any.whl.

File metadata

  • Download URL: abdoTheBest-0.7.9-py3-none-any.whl
  • Upload date:
  • Size: 15.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.23.0 setuptools/47.1.1 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.7.7

File hashes

Hashes for abdoTheBest-0.7.9-py3-none-any.whl
Algorithm Hash digest
SHA256 17b4c13f596ff3e7232b5e12964cd532ab2d80b9e886ae0d9cb13ee8b8f62515
MD5 bf2a6f54d00e1498c430f284e4ac9e00
BLAKE2b-256 15b5975d03f64aee4cb2adcbd2c6842a39612486bd7a220fdae65ba7f95cb47d

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