Views
No views yet
1pip install torch torchvision transformers pandas matplotlib huggingface-hub
2
3### Data Preparation
4The datasets used in this project are:
5
6- English Dataset: Alpaca Cleaned Dataset
7- Aymara Dataset: Aymara text data in JSON format stored in Google Drive.
8### Training the Model
9To train the model, simply run the main training script. The model's hyperparameters can be modified in the script as needed.
10
11```bash
12# Start training
13python train.py # Adjust to your script's name
14Generated Text
15After training, you can generate text using the trained model. Here’s an example of generating text with a context:
16
17
18context = "Once upon a time"
19generated_text = model.generate(context, max_new_tokens=200)
20print(generated_text)
21Performance Metrics
22Training Loss: Logged every 300 iterations.
23Validation Loss: Also logged every 300 iterations.
24Perplexity: Calculated from validation loss to assess model performance.
25Results Visualization
26Training and validation losses are plotted for better understanding and visualization of the training process.
27
28python
29Copy code
30import matplotlib.pyplot as plt
31
32# Read and plot the loss data
33plt.plot(loss_data['epoch/step'], loss_data['training_loss'], label='Training Loss')
34plt.plot(loss_data['epoch/step'], loss_data['val_loss'], label='Validation Loss')
35plt.xscale('log')
36plt.title('Training and Validation Loss Over Iterations')
37plt.xlabel('Epoch/Step')
38plt.ylabel('Loss')
39plt.legend()
40plt.grid()
41plt.show()
42Checkpoints
43The trained model checkpoints are saved periodically during training. You can load them to continue training or for inference.