CoolFace
Apppublic

KeerthiSaiKasaraneni/NeuralNetworkLanguageModel

sourceHugging Facemitupdated 2y agoView on Hugging Face
0likes
App README

LSTM-Based Language Model for Next Token Prediction 🧠

This repository hosts an LSTM-based neural network model designed for next token prediction in both English and Danish languages. The model employs a non-transformer-based LSTM architecture, enabling it to capture temporal dependencies within text data effectively.

🌟 Key Features

  • β€”Multilingual Support: Capable of generating text in English and Danish.
  • β€”LSTM Architecture: Utilizes Long Short-Term Memory layers to learn from the sequence of words.
  • β€”Custom Tokenization: Features a word-level tokenizer to process text into tokens.
  • β€”Checkpointing: Includes functionality to save training checkpoints, aiding in model evaluation and training resumption.
  • β€”Perplexity Evaluation: Employs perplexity scores to measure prediction capabilities, aiming for lower scores to indicate better performance.

πŸš€ Quick Start

This model is equipped with a Gradio web interface, allowing users to interactively generate text sequences by providing a starting phrase in either language.

Text Generation Examples

  • β€”English Input: "Once upon a time"
  • β€”Generated Text: "Once upon a time as the argument is prime straight panel of water and plot..."
  • β€”Danish Input: "En gang"
  • β€”Generated Text: "En gang variable og cytokines stΓ¦rke follow netflix skove elefant formΓ₯ede..."

πŸ“Š Model Performance

The final validation perplexity of the model stands at 2409.41, reflecting its ability to predict the next token in a sequence.

πŸ— Model Architecture

  1. 1.Embedding Layer: Converts words into dense vectors of a fixed size.
  2. 2.LSTM Layers: Two layers that capture the word dependencies in sequences.
  3. 3.Fully Connected Layer: Outputs probabilities over the vocabulary for next word prediction.

Parameters

  • β€”Embedding Dimension: 128
  • β€”Hidden Units: 256
  • β€”LSTM Layers: 2
  • β€”Dropout Rate: 0.3
  • β€”Learning Rate: 0.002
  • β€”Batch Size: 32
  • β€”Context Window: 10

πŸ”§ Training

Training involved 2000 iterations with checkpoints at every 100 steps. The model uses datasets in English and Danish, structured to facilitate efficient learning.

πŸ“ Repository Contents

  • β€”finallstmmodel.pth: The trained model in PyTorch format.
  • β€”English.json: Training dataset in English.
  • β€”Danish.json: Training dataset in Danish.
  • β€”app.py: Gradio application script for model interaction.
  • β€”README.md: Detailed project documentation.

License

This project is available under the MIT license.

Feel free to clone this repository to train the model further or to develop it according to your specific needs!