This repo contains all the code for the PyTorch demo conducted as part of CS F429: Natural Language Processing.
Contains the code for a very basic pytorch module. Meant to be a tutorial on how to build a neural network
Contains a full minimal training pipeline:
- dataset and dataloader initialization
- model creation
- training
- evaluation
Note that this is meant to be demo of PyTorch, so practices like validation aren't used. You should use them in all your projects.
NLP is a sequence processing problem, and sequence models like transformers and RNNs are more involved than regular feed forward networks. I wanted to use a simple model that trains and produces results fast.
Wanted to keep things simple. Moreover if I did use a CNN this might as well be a computer vision course demo :)
Contains code and illustrations that shed light into the inner workings of RNNs. Also shows how to implement manually in pytorch without using torch.nn.RNN
Finally, it shows how to use the torch.nn.LSTM module
After going through this, you should be able to train your own LSTM on whatever dataset you want.
Jk, out of scope for now. Coming soon maybe?
Colab link available here. Make a copy to your drive and play around.
If you want to run this code locally, follow these steps:
- Install anaconda/miniconda and set it up
- Clone this repository to your local
- In your anaconda/miniconda command prompt, run the following from the directory containing the cloned code:
$conda env create --name <preferred_env_name> --file=environment.yml - Run:
$conda activate <preferred_env_name> $jupyter notebook - A notebook should open on your browser and you'll be able to run everything.
You can use the same environment for your NLP course project as well.
If you have any doubts/suggestions please email me f20190040@hyderabad.bits-pilani.ac.in