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.

Metadata

Release files for abdoTheBest 0.7.8

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for abdoTheBest 0.7.8
File Size Uploaded
abdoTheBest-0.7.8.tar.gz 11.7 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for abdoTheBest 0.7.8
File Interpreter ABI Platform
abdoTheBest-0.7.8-py3-none-any.whl Python 3 none any Details

Total release size: 26.8 kB

Release files / abdoTheBest-0.7.8.tar.gz

Download URL abdoTheBest-0.7.8.tar.gz
Size 11.7 kB
Tags Source
SHA-256 checksum
How to use checksums
6de8f8f965e9a674430067166bd031a39e286cecd0465926cbbd53c4d82486e5
BLAKE2b-256 checksum
How to use checksums
6c0e355c0afa4b65ee9f1cd7f08863e99ca9c18ba135634243a9b1d9f106335f
Upload date
Uploaded using Trusted Publishing?
What is 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

Release files / abdoTheBest-0.7.8-py3-none-any.whl

Download URL abdoTheBest-0.7.8-py3-none-any.whl
Size 15.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
56649481e1443bba73ce2fe6dd8634bef03dd0fde893ae1fa41a0362dc88cb51
BLAKE2b-256 checksum
How to use checksums
6d1f054a366d863cdab95218fe160382d222f4c56fa47448466a851bbc9b98ad
Upload date
Uploaded using Trusted Publishing?
What is 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

Release history Release notifications | RSS feed

1.0.0

2 release files

0.9.9

2 release files

0.9.8

2 release files

0.9.7

2 release files

0.9.6

2 release files

0.9.5

2 release files

0.9.4

2 release files

0.9.3

2 release files

0.9.2

2 release files

0.9.1

1 release file

0.9

2 release files

0.8.9

2 release files

0.8.8

2 release files

0.8.7

2 release files

0.8.6

2 release files

0.8.5

2 release files

0.8.4

2 release files

0.8.3

2 release files

0.8.2

2 release files

0.8.1

2 release files

0.8

2 release files

0.7.9

2 release files

This release

0.7.8 This release

2 release files

0.7.7

2 release files

0.7.6

2 release files

0.7.5

2 release files

0.7.4

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page