Downloads · 30 days
0
girichan/NLP_Midterm_Giri_Chandragiri
NLP_Midterm_Giri_Chandragiri is a machine learning model from girichan. Use it for the machine learning task on the model card, and read the license before you ship it in a product.
This README file provides an overview of the content, steps, and code execution for the project described in the accompanying document.
Downloads · 30 days
0
Access
Public
Updated Oct 12, 2024
Repo size
905 MB
Likes
0
Public
Click a slice to open those files.
.pth815 MB · 90%
From the Hugging Face model README
This README file provides an overview of the content, steps, and code execution for the project described in the accompanying document.
The project demonstrates various machine learning tasks using PyTorch for language processing tasks. The document explains the process of training an RNN model for text generation, evaluation, and result visualization.
Data Handling:
Hyperparameter Setup:
Model Definition:
Training and Evaluation:
Text Generation:
Plotting and Saving Results:
Import Required Libraries:
import torch
import pandas as pd
import matplotlib.pyplot as plt
Data Preprocessing:
with open('/content/eng_basque.txt', 'r', encoding='utf-8') as f:
text = f.read()
encoded_data = torch.tensor(encode(text), dtype=torch.long)
Model Training:
model = SimpleRNNModel().to(device)
optimizer = torch.optim.AdamW(model.parameters(), lr=learning_rate)
Model Evaluation:
def estimate_loss():
# Function to estimate train/val losses
Text Generation:
start_text = "Once upon a time"
generated_text = generate_text(loaded_model, start_text, max_new_tokens=500)
print(generated_text)
English Text Example:
Once upon a time...
Basque Text Example:
Gaur egun...
pip install torch pandas matplotlib
This project provides an end-to-end example of how to build, train, and evaluate a simple RNN for text generation in both English and Basque. The notebook includes code for data preprocessing, model training, checkpoint saving, and result visualization.