Downloads · 30 days
6
6% of all-time downloads
yablokolabs/romanticGPT
romanticGPT is a machine learning model from yablokolabs. Use it for the machine learning task on the model card, and read the license before you ship it in a product. It is set up for keras.
A small Keras LSTM text generator trained on public-domain romantic literature.
Downloads · 30 days
6
6% of all-time downloads
All-time downloads
93
Public
Repo size
73.1 MB
Likes
1
Public
Click a slice to open those files.
.keras24.4 MB · 97%
From the Hugging Face model README
A small Keras LSTM text generator trained on public-domain romantic literature.
RomanticGPT is a word-level language model built with TensorFlow/Keras:
| File | Description |
|---|---|
romantic_gpt.keras | Trained Keras model (full model, not just weights) |
tokenizer_config.json | Vocabulary and sequence length metadata |
train.py | Training script |
generate.py | Inference / text generation script |
sample_prompts.txt | Example prompts to try |
import tensorflow as tf
model = tf.keras.models.load_model("romantic_gpt.keras")
pip install tensorflow numpy
python generate.py --prompt "she looked into his eyes" --words 50 --temperature 0.8
# 1. Download public-domain texts into data/
cd data
curl -o pride_and_prejudice.txt https://www.gutenberg.org/cache/epub/1342/pg1342.txt
curl -o sense_and_sensibility.txt https://www.gutenberg.org/cache/epub/161/pg161.txt
curl -o jane_eyre.txt https://www.gutenberg.org/cache/epub/1260/pg1260.txt
cd ..
# 2. Train
python train.py
# 3. Generate
python generate.py --prompt "her heart beat faster"
import json
import tensorflow as tf
import numpy as np
from tensorflow.keras.preprocessing.sequence import pad_sequences
model = tf.keras.models.load_model("romantic_gpt.keras")
with open("tokenizer_config.json") as f:
config = json.load(f)
word_index = config["word_index"]
index_word = config["index_word"]
seq_length = config["max_seq_length"]
prompt = "she looked into his eyes"
words = prompt.lower().split()
for _ in range(50):
token_ids = [word_index.get(w, 1) for w in words]
padded = pad_sequences([token_ids], maxlen=seq_length, padding="pre")
probs = model.predict(padded, verbose=0)[0]
next_id = int(np.argmax(probs))
next_word = index_word.get(str(next_id), "")
if next_word:
words.append(next_word)
print(" ".join(words))
All training texts are sourced from Project Gutenberg
and are in the public domain in the United States. See data/README.md for
download instructions and recommended titles.
The code in this repository is provided as-is for educational purposes. Training data is public domain (Project Gutenberg).