Skip to content

mahmudulhasanrabbidu/lstm_TextGenerator_from_scratch

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

4 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Custom-LSTM-TextGenerator From-Scratch

This repository contains a from-scratch implementation of a multi-layer LSTM character-level language model, built without using nn.LSTM.
Every gate, weight matrix, and update step is implemented manually to show how LSTM works internally.

The project trains on raw text and generates new text autoregressively (character by character).


πŸš€ Features

  • Complete CharDataset for character-level sequence modeling
  • Fully manual MULTILayerLSTM implementation (no PyTorch LSTM used)
  • Custom CharRNN wrapper
  • Clean training loop with single epoch progress bar
  • Proper loss tracking per batch
  • Autoregressive text generation
  • GPU support
  • From-scratch educational code structure

πŸ—οΈ Model Overview

Key parts implemented from scratch:

  • Input gate
  • Forget gate
  • Output gate
  • Candidate cell update
  • Multi-layer stacking
  • Full forward pass
  • Hidden state + Cell state flow

This ensures you learn how LSTM works internally rather than treating it as a black box.


πŸ§ͺ Goals of This Project

  • Understand LSTM internals
  • Learn how multi-layer RNNs pass hidden states
  • Train a working character-level model
  • No shortcuts, no magical PyTorch layers
  • 100% educational and transparent

πŸ”§ Technologies Used

  • Python
  • PyTorch
  • tqdm
  • NumPy

πŸ™Œ Contributing

Pull requests, issues, and suggestions are welcome.
This project is meant for learning β€” improvements benefit everyone.

About

A fully from-scratch multi-layer LSTM character-level text generator implemented without using nn.LSTM. Includes manual gate computations, custom dataset, training loop, and autoregressive generation.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors