Giter Club home page Giter Club logo

lstm-language-generator's Introduction

LSTM-Language-Generator

A Pytorch LSTM Language model trained on Penn Tree Bank Dataset.

Table of Contents

Introduction

This is a PyTorch Implementation for an LSTM-based language model. The model is trained on Penn Tree Bank dataset using Adam optimizer with a learning rate 0.001 and 10 epochs.

Setup

The code is using pipenv as a virtual environment and package manager. To run the code, all you need is to install the necessary dependencies. open the terminal and type:

  • git clone https://github.com/Khamies/LSTM-Language-Generator.git
  • cd LSTM-Language-Generator
  • pipenv install

And you should be ready to go to play with code and build upon it!

Run the code

  • To train the model, run: python main.py

  • To train the model with specific arguments, run: python main.py --batch_size=64. The following command-line arguments are available:

    • Batch size: --batch_size
    • bptt: --bptt
    • Learning rate: --lr
    • Embedding size: --embed_size
    • Hidden size: --hidden_size
    • Latent size: --latent_size

Training

The model is trained on 10 epochs using Adam as an optimizer with a learning rate = 0.001 and batch size = 32, you can find all the model settings in settings.py. Here is the loss curve for the training step:

  • Negative Likelihood Loss

Sample Generation

Here are some generated samples from the model:

he said <pad> is n't expected to be the first quarter of
the company said will be used to repay the company's

Play with the model

To play with the model, a jupyter notebook has been provided, you can find it here

Citation

@misc{Khamies2021LSTM-Language-Generator,
author = {Khamies, Waleed},
title = {A PyTorch Implementation for an LSTM-based language model},
year = {2021},
publisher = {GitHub},
journal = {GitHub repository},
howpublished = {\url{https://github.com/Khamies/LSTM-Language-Generator}},
}

Connect with me ๐Ÿ™‚

For any question or a collaboration, drop me a message here

Follow me on Linkedin!

Thank you โค๏ธ

License

lstm-language-generator's People

Contributors

khamies avatar

Stargazers

 avatar

Watchers

 avatar  avatar

Forkers

keer0919

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.