Downloads · 30 days
0
SiriK0310/Neural_Network_Based_Language_Model_for_Next_Token_Prediction
Neural_Network_Based_Language_Model_for_Next_Token_Prediction is a machine learning model from SiriK0310. Use it for the machine learning task on the model card, and read the license before you ship it in a product.
This project implements a Neural Network-based language model designed for next token prediction in English and Divehi. The model uses an LSTM architecture to predict the next word in a sequence. The dataset consists…
Downloads · 30 days
0
Access
Public
Updated Oct 11, 2024
Repo size
148 MB
Likes
0
Public
Click a slice to open those files.
.json148 MB · 100%
From the Hugging Face model README
This project implements a Neural Network-based language model designed for next token prediction in English and Divehi. The model uses an LSTM architecture to predict the next word in a sequence. The dataset consists of 20,000 samples including English and Divehi texts.
The model is trained using checkpointing and generates text for both languages.
Datasets: Datasets for the modelcheckpoint.pth: Checkpoint saved during trainingmain.py: Script used for training and inferenceREADME.md: This fileThe model was trained for 20 epochs, and the training and validation losses were monitored. Checkpoints were saved to ensure the model can be resumed at any point.
You can load the model and generate text using the following code:
import torch
from model import LSTMLanguageModel # Import your model class
# Load the model
model = LSTMLanguageModel(vocab_size, embedding_dim, hidden_dim, num_layers)
model.load_state_dict(torch.load('model.pth'))
model.eval()
# Generate text
start_text = "Once upon a time"
generated_text = generate_text(model, tokenizer, start_text)
print(generated_text)