Skip to content

Fine tuning GPT2 to generate stories from text prompts, Deep Daze library integration to generate images from stories and MLOps based continuous monitoring, deployment and serving of trained model on cloud.

Notifications You must be signed in to change notification settings

surabhigovil/cmpe-297-project

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

33 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Comic Generator using GPT2

Directory Structure:

Application: Contains Story Gneration notebook deployed on Vertex AI using custom pipeline.

Notebooks: Story generation colab and colab with image generation on top of story generation.

Documentation: Project video presnetation, Project Paper

Fine Tuning GPT2

GPT-2 is a language model comes from OpenAI’s paper “Language Models are Unsupervised Multitask Learners”. GPT was a variation of the famous Transformer architecture proposed by the Google Brain team in their paper “Attention is all You Need” . Fine tuning it can enable us to write long and engaging stories.

We using this projet tried to achieve just that. WritingPrompts is a dataset published by Facebook AI Research intending to make machines able to compose a long and consistent story we used that to generate long form text or stories usoing GPT2.

Perplexity score before fine tuning the model:

image

Perplexity score after fine tuning the model: image

The perfromance of the fine tuned network W B Chart 12_11_2021, 5_43_42 PM

W B Chart 12_11_2021, 5_43_53 PM

Image Generation using Deep Daze library

Simple command line tool for text to image generation using OpenAI's CLIP and Siren. Helped us achieve good results for image generation from paragraphs of text.

image

MLOps using Vertex AI

In google cloud platform create a project and enable vertexAI API, Google cloud storage API, container registry API and notebook API.

In google cloud platform create a pytorch notebook using the command below.

gcloud notebooks instances create story-generation     --vm-image-project=deeplearning-platform-release     --vm-image-family=pytorch-1-9-cu110-notebooks     --machine-type=n1-standard-4     --location=us-central1-a     --boot-disk-size=100 --network=default

Create a bucket in your project and upload the dataset.

create a package with structure below run below command to create tar file and upload to the bucket in google storage.

python setup.py sdist --formats=gztar 
-python_package
	-trainer
		-__init__.py
		-experiment.py
		-metadata.py
		-model.py
		-task.py
		-utils.py
	-steup.py
-predictor
	-custom_text_handler.py
	-Dockerfile

Initialise the aiplatform with project id and location.

Initialise and run the job with CustomPythonPackageTrainingJob method with providing the container image and location to the package in the bucket. Training object saves the model artifacts in the output bucket in storage bucket.

Load the model artifacts to the local director in notebook and to create the custom predictor image using the Dockerfile. After building the package push it to the container registry.

Upload the trained model artifacts using the custom predictor image.

Create endpoint on vertex AI platform.

Deploy the model to the created enpoint and predict using the endpoint.

FLASK APPLICATION:

Requirements : pip3 install torch

git clone https://github.com/huggingface/transformers

pip3 install transformers/

pip3 install flask

run python3 deploy.py

application is served at localhost:5000/

About

Fine tuning GPT2 to generate stories from text prompts, Deep Daze library integration to generate images from stories and MLOps based continuous monitoring, deployment and serving of trained model on cloud.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published