This project is a poem generator using Sequential Neural Network. It learns from existing poems and generates new ones based on the patterns it discovers.
- The collection of poems stored in a file called “poem.txt.”
- We read each line of the poems and create a list to store them.
- Create a Tokenizer to learn the words in the poems.
- The tokenizer assigns a unique number to each word (like giving each word a secret code).
- Then , slide a window over the words to create a small group of words (called an “n-gram”).
- These n-grams help our model understand the structure and flow of the poems.
- This model consist of three layers .
- Embedding Layer: Converts word indices to dense vectors (like translating words into a secret language).
- Bidirectional LSTM Layer : This layer remembers patterns in the poems (like remembering a song’s melody both forwards and backwards).
- Dense Layer : Predicts the next word in the poem (like guessing the next word in a sentence).
Then we can train our model using the input sequences (the n-grams) and their corresponding labels (the next words). After several rounds of practice (epochs of 40), our model gets better at creating new poems.
How this Model helps :
- Content Creation 📝 : Blogs and Websites , Social Media
- Personalized Marketing 📝: Marketers can send personalized poems to subscribers during special occasions or holidays.
- Creative Writing 📝: Students can use this tool to explore language nuances and improve their writing skills.
TO SET UP PROJECT 🚀:
# Example installation steps
git clone https://github.com/Madhusri02/Poem-Generator.git
pip install numpy tensorflow streamlit
to run the file :
streamlit run streamlit_app.py