Skip to content

An NLP character-level Recurrent Neural Network (RNN) model developed with machine learning (ML) project architecture best practices in mind built with Python, PyTorch, Makefile, and Shell.

License

Notifications You must be signed in to change notification settings

pjnalls/nlp_from_scratch

Repository files navigation

metallic Earth with 'NLP' letters

Natural Language Processing
(NLP) From Scratch

A walkthrough of an NLP character-level Recurrent Neural Network (RNN) and translation with a sequence-to-sequence network and attention provided by the PyTorch community that is available here: https://docs.pytorch.org/tutorials/intermediate/char_rnn_classification_tutorial.

Prerequisites

Quickrun Pretrained RNN Model

If you'd like to quickly see the results from a pretrained RNN model, run the following command with a first or last name as the argument the RNN model already "pretrained", replacing "<First or Last Name>".

python main.py <First or Last Name> pretrained=true

Setup Option A: Quickstart

If you have Python installed and are using a macOS or Linux machine, you can run the following script to create a .venv folder for your local virtual environment with the following command:

source scripts/setup.sh

Setup Option B: Manual Project Setup

via venv

Once you create a venv virtual environment with the guide, available here, inside a clone of this repo, run the following command:

pip install -r requirements.txt

via conda

The requirements.txt file may be used to create an environment using the following command:

conda create --name your_env_name_here --file requirements.txt

Running the Project

I'm using a Makefile to defined all of my CI commands at every step of the pipeline of the neural network model created for this project.

Here are some useful commands you can run at different stages of the pipeline:

Download the data

make download

Run the pipeline after the download step

make run

Run the entire pipeline

source scripts/make.sh

Note: A Shell script is needed since new files are added to the system on the make download step and the process will only detect these changes during make run with a script like Shell not Make.

Delete compiled Python files

make clean

Delete all data

make clean-data

Delete all cached and external data

make clean-all

⚠️ NOTE FOR WINDOWS USERS ⚠️

Make is more challenging to install on Windows. I recommend using Chocolately guide here: https://earthly.dev/blog/makefiles-on-windows/

About

An NLP character-level Recurrent Neural Network (RNN) model developed with machine learning (ML) project architecture best practices in mind built with Python, PyTorch, Makefile, and Shell.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published