This repository contains experimental code used for the KDL presentation, From Once Upon a Time, to Happily Ever After, via AI at the Creative AI: Theory and Practice symposium.
Install poetry and the requirements:
poetry install
poetry run python creativeai/gpt.py MODEL_PATH DATA_PATH
MODEL_PATH
can either be a Hugging Face path or a local path.DATA_PATH
should be a path to a text file with all the training data.
To see a list of all the available options for the text generation run the gpt.py
script with the --help
option:
poetry run python creativeai/gpt.py --help
usage: gpt.py [-h] [-n NAME] [-o OUTPUT] [-e EPOCHS] model data
Script to train a GPT model
positional arguments:
model Model path
data Text file with training data
optional arguments:
-h, --help show this help message and exit
-n NAME, --name NAME Model name
-o OUTPUT, --output OUTPUT
Path to save the trained model
-e EPOCHS, --epochs EPOCHS
Warning: Depending on the model being used, fine tunning a text generation model can be very time consuming without access to a GPU.
The repository also contains a notebook with an interface to generate text and imgages from the generated text. The story document contains an example of a story generated in the notebook for the prompt: There was a man made of clockwork who longed to become human so, with the settings top p set to 0.9, and ngrams set to 4.
Warning: The notebook is set up to use GPUs.
The models for the presentation were fine tuned using the Grimm's Fairy Tales.
- GPT-Neo 1.3B for text generation;
- Stable diffusion for image generation.