Giter VIP home page Giter VIP logo

character-level-recurrent-neural-network-language-model's Introduction

Character-Level Recurrent Neural Network Language Model

Comp 545 - Natural Language Processing

Description

This project involves the implementation of character-based RNN and LSTM language models that learn to predict the next character in a sequence, given the previous characters. The models were trained on Shakespeare and Sherlock texts, enabling them to generate text that mimics the style and context of the source material.

Objectives:

  • Implement a character sequence data loader to process text data into trainable sequences.
  • Develop a Character RNN and LSTM using PyTorch to learn and predict character sequences.
  • Explore the models' ability to generate coherent and contextually relevant text as they train, then compare their results.
  • Evaluate the impact of different parameters (like temperature and top_k filtering) on the diversity and quality of the generated text.

Technologies Used:

  • Programming Language: Python
  • Frameworks/Libraries: PyTorch, NumPy, Hugging Face Datasets, Matplotlib
  • Tools: Kaggle

Features:

  • Data Preprocessing: Custom data loader to convert raw text into sequences of characters for the RNN.
  • Model Architecture: Built and trained a character-level RNN from scratch.
  • Text Generation: Implemented functions to generate text by sampling the model's predictions, incorporating techniques like temperature scaling and top-K filtering to control diversity.
  • Parameter Tuning: Explored the effects of various hyperparameters on the model's text generation capabilities.

Results:

alt text

RNN Result Sample

Un I all the stain that that is side is I the slay as near the have the manded youm be in sear. It the but that 
the man ther the the but the blears and the dear the splen have brist the may be all hear

LSTM Result Sample

รƒ:
"Yound the fack me for a more his a will had be a chere away I conger."
"We colled the prom which a last the wore will be at dear and the brow and his me her and a pars, 
some your his the a look

Considering all the samples and loss curves, I observed that higher values for all parameters introduces some nonsense in a text that is already hard to understand. However, it did better on lower values, close to medium. Comparing RNN and LSTM, I can conclude that LSTM produced more coherent text that somehow made sense in some parts of the sequence as opposed to RNN.

How to Use:

  • Clone the repository.
  • Install required packages from requirements.txt.
  • Execute the script code.py locally or in notebook form on Kaggle to train the model and see text generation in action.

character-level-recurrent-neural-network-language-model's People

Contributors

lauralad avatar

Watchers

Kostas Georgiou avatar  avatar

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.