We have developed a NLP(natural language processing) model which automatically generates a poem based on the initial/promt text given as input by the user.
The majority of ML/DL models result is usualy based on the training/validation accuracy and loss. And one of the models which does not depend on either on accuracy or loss is NLP text generating model. Irrespective of the accuracy the generated text may or maynot make sense. Sometimes the accuracy can be very high and not give satisfactory results or end up in a loop. So this can only be done by looking at the result after many trails and training.
- Can be used for creative and fun purposes.
- Can sometimes used for reproducing or generating the text for larger datasets.
- Literature purpose like understanding and analysing a certain poetric style.
- Unlike many poetry generation, we also built a hindi poetry text generation model.
- We provide an analysis for LSTM layers and transformers with an example for better understanding.
- Streamlit for frontend
- tensorflow keras for hindi poetry
- aitextgen for english poetry
The english poetry generation is developed with the help of an open-sourse library known as aitextgen. The famous GPT-2 transformer is used in this project, finetuned on Shakespeares poems and sonnets alone. The hindi poetry generation is built with tensorflow keras. The front-end is simply handled by streamlit.
Here is an example of how aitextgen is fine tuned. Here is an example on how to train your own model using tensorflow keras.
The app.py
file should be installed and download the model from this link. The trained_model folder
should specify the path to your downloaded model. And you have to install trained_model_hindi from this link and specify the path as above.
The trained_model_hindi forlder contains the trained model, tokenizer and etc. Similarly the trained_model folder for english also contains the model
and uses the default built in GPT-2 transformer.
Finally streamlit run app.py
in your terminal and enjoy
the app.
This is how Your code should look while running on local.
- Planning on including a translator to slide easily between languages.
- Introduce more poet based model in many languages.
- Paras Rawat
- Daketi Yatin