Downloads · 30 days
0
gnsepili/shakespeare-rnn
shakespeare-rnn is a text generation model from gnsepili. Use it when you need the model to write or continue text. The card lists the license as mit.
This project implements a character-level Recurrent Neural Network (RNN) trained on Shakespeare's works. The model can generate Shakespeare-like text based on a given prompt.
Downloads · 30 days
0
Access
Public
Updated Jun 26, 2024
Repo size
14.9 MB
Likes
0
Public
Click a slice to open those files.
.pth14.9 MB · 100%
From the Hugging Face model README
This project implements a character-level Recurrent Neural Network (RNN) trained on Shakespeare's works. The model can generate Shakespeare-like text based on a given prompt.
This project uses a Long Short-Term Memory (LSTM) network to generate text in the style of Shakespeare. The model is trained on a dataset of Shakespeare's works and can generate new text based on a given prompt.
Key features:
Clone the repository:
git clone https://github.com/your-username/shakespeare-rnn.git
cd shakespeare-rnn
Create a virtual environment:
python -m venv venv
source venv/bin/activate # On Windows, use `venv\Scripts\activate`
Install the required packages:
pip install -r requirements.txt
shakespeare-rnn/
│
├── data/
│ ├── __init__.py
│ └── dataset.py
│
├── model/
│ ├── __init__.py
│ └── rnn.py
│
├── utils/
│ ├── __init__.py
│ └── tokenizer.py
│
├── config.py
├── train.py
├── inference.py
├── requirements.txt
└── README.md
To train the model, run:
python train.py
This will start the training process and log the results to Weights & Biases. You can monitor the training progress in real-time through the W&B dashboard.
To generate text using the trained model, run:
python inference.py
This will load the trained model and allow you to enter prompts for text generation. The script will also generate text for a few predefined prompts.
The model uses a character-level LSTM network with the following architecture:
The exact architecture (number of layers, hidden dimensions, etc.) can be configured in the config.py file.
The model is trained on the Tiny Shakespeare dataset, which is a collection of Shakespeare's works. The dataset is automatically downloaded using the Hugging Face datasets library.
You can modify the model's hyperparameters and training settings in the config.py file. Key configurations include:
After training, you can find the training logs and performance metrics on the Weights & Biases dashboard. The trained model will be saved as shakespeare_model.pth, and the tokenizer will be saved as tokenizer.pkl.
Example generated text:
[Include some example outputs from your trained model here]
Contributions to this project are welcome! Please follow these steps:
git checkout -b feature/your-feature-name)git commit -am 'Add some feature')git push origin feature/your-feature-name)This project is licensed under the MIT License - see the LICENSE file for details.
This README provides a comprehensive overview of your project, including installation instructions, usage guidelines, project structure, and other relevant information. You may want to customize some parts, such as the repository URL, example outputs, and any specific instructions or results from your implementation.