A character level language model for generating random Sci-Fi text.
What if I tell you, we can teach an AI to be a writer?
At first glance, this question sounds something straight out of a SciFi movie, but surprisingly it isn’t.
This project is an approach to implement that, to put it another way, this project is an approach to “teach an AI how to write” one character at a time, using the state of the art character level language models or sometimes also termed as Char RNNs.
For training the model, the SciFi Stories Text Corpus was used. The dataset consists of a large collection of Science Fiction stories with a total of around
150 Million
characters.
This model takes it as input and trains a Recurrent Neural Network that learns to predict the next character. The RNN can then be used to generate text, character by character, that will look like the original training data.
git clone "https://github.com/priyavrat-misra/scifi-lorem.git" && cd "scifi-lorem/"
pip install -r requirements.txt # install dependencies
python generate.py --help
usage: SciFi Lorem [-h] [-S] [-s ] [-p ] [-k ] [-v ] [-c ]
generate random *meaningful* sci-fi text
optional arguments:
-h, --help show this help message and exit
-S , --save_path saves the text to a file with given name
-s [], --size [] generates given no of characters (default 512)
-p [], --prime [] sets the starter/prime text (default "The")
-k [], --topk [] randomly choose one from top-k probable chars
-v [], --verbose [] prints the text to console
-c [], --copyclip [] copies the text to clipboard
```
python generate.py -s=2048 -p="A long time ago in a galaxy far, far away..." -k=2 -S="./out.txt" -c -v
generated text saved to ./out.txt
generated text copied to clipboard
```