This repository contains a Streamlit web application for generating text using a pre-trained character-level recurrent neural network (CharRNN) model and fine-tuning the model based on the generated text.
- Text Generation: Generate text based on a provided starting text, controlling the number of characters to generate and the temperature parameter for controlling randomness.
- Model Fine-tuning: Fine-tune the pre-trained CharRNN model based on the generated text to adapt it to specific tasks or styles.
- Model Management: Upload, download, and delete model files via HTTP requests to a specified API endpoint.
- Visualization: Plot gradients and weight histograms to provide insights into the model training process.
- Clone this repository to your local machine.
- Install the required dependencies using
pip install -r req.txt
. - Make sure to have the pre-trained model file (
language_model.pth
) and the dataset file (dataset.txt
) in the repository directory.
Remember to replace the api url
# API endpoints
BASE_URL = "https://your_domain.com/api/"
UPLOAD_URL = BASE_URL + "upload.php"
DOWNLOAD_URL = BASE_URL + "download.php"
DELETE_URL = BASE_URL + "delete.php"
DOWNLOAD_URL = "https://your_domain.com/api/uploads/server_model.pth"
Run server:
cd server
python3 server.py
Run the Streamlit app using the following command:
cd client
streamlit run client.py
Access the app through the provided URL.
- Enter the starting text for text generation in the provided input field.
- Adjust the sliders to control the number of characters to generate and the temperature parameter.
- Click the "Generate Text" button to generate text based on the input.
- Optionally, click the "Train Model with Generated Text" button to fine-tune the model based on the generated text.
- Click the "Pull New Version" button to download a new version of the model from the server.
app.py
: Main Streamlit application script.README.md
: This file, providing information about the project.requirements.txt
: List of Python dependencies required for running the application.dataset.txt
: Text dataset used for training the CharRNN model.language_model.pth
: Pre-trained CharRNN model parameters file.server_model.pth
: Model file to be uploaded to the server.downloaded_model.pth
: Downloaded model file from the server.