"
],
"text/html": [
"\n",
" \n",
" \n",
"
\n",
" [10000/10000 2:00:23, Epoch 2/2]\n",
"
\n",
" \n",
" \n",
" \n",
" Step | \n",
" Training Loss | \n",
"
\n",
" \n",
" \n",
" \n",
" 100 | \n",
" 0.522000 | \n",
"
\n",
" \n",
" 200 | \n",
" 0.169400 | \n",
"
\n",
" \n",
" 300 | \n",
" 0.088900 | \n",
"
\n",
" \n",
" 400 | \n",
" 0.058000 | \n",
"
\n",
" \n",
" 500 | \n",
" 0.068900 | \n",
"
\n",
" \n",
" 600 | \n",
" 0.051600 | \n",
"
\n",
" \n",
" 700 | \n",
" 0.057400 | \n",
"
\n",
" \n",
" 800 | \n",
" 0.049300 | \n",
"
\n",
" \n",
" 900 | \n",
" 0.048100 | \n",
"
\n",
" \n",
" 1000 | \n",
" 0.062500 | \n",
"
\n",
" \n",
" 1100 | \n",
" 0.051300 | \n",
"
\n",
" \n",
" 1200 | \n",
" 0.050700 | \n",
"
\n",
" \n",
" 1300 | \n",
" 0.049000 | \n",
"
\n",
" \n",
" 1400 | \n",
" 0.047100 | \n",
"
\n",
" \n",
" 1500 | \n",
" 0.041500 | \n",
"
\n",
" \n",
" 1600 | \n",
" 0.049000 | \n",
"
\n",
" \n",
" 1700 | \n",
" 0.052800 | \n",
"
\n",
" \n",
" 1800 | \n",
" 0.049300 | \n",
"
\n",
" \n",
" 1900 | \n",
" 0.043500 | \n",
"
\n",
" \n",
" 2000 | \n",
" 0.047700 | \n",
"
\n",
" \n",
" 2100 | \n",
" 0.046600 | \n",
"
\n",
" \n",
" 2200 | \n",
" 0.045900 | \n",
"
\n",
" \n",
" 2300 | \n",
" 0.045900 | \n",
"
\n",
" \n",
" 2400 | \n",
" 0.042200 | \n",
"
\n",
" \n",
" 2500 | \n",
" 0.043100 | \n",
"
\n",
" \n",
" 2600 | \n",
" 0.044200 | \n",
"
\n",
" \n",
" 2700 | \n",
" 0.043900 | \n",
"
\n",
" \n",
" 2800 | \n",
" 0.042400 | \n",
"
\n",
" \n",
" 2900 | \n",
" 0.051700 | \n",
"
\n",
" \n",
" 3000 | \n",
" 0.049700 | \n",
"
\n",
" \n",
" 3100 | \n",
" 0.045700 | \n",
"
\n",
" \n",
" 3200 | \n",
" 0.047400 | \n",
"
\n",
" \n",
" 3300 | \n",
" 0.042800 | \n",
"
\n",
" \n",
" 3400 | \n",
" 0.042400 | \n",
"
\n",
" \n",
" 3500 | \n",
" 0.045200 | \n",
"
\n",
" \n",
" 3600 | \n",
" 0.047600 | \n",
"
\n",
" \n",
" 3700 | \n",
" 0.044800 | \n",
"
\n",
" \n",
" 3800 | \n",
" 0.045100 | \n",
"
\n",
" \n",
" 3900 | \n",
" 0.041900 | \n",
"
\n",
" \n",
" 4000 | \n",
" 0.039300 | \n",
"
\n",
" \n",
" 4100 | \n",
" 0.039500 | \n",
"
\n",
" \n",
" 4200 | \n",
" 0.044500 | \n",
"
\n",
" \n",
" 4300 | \n",
" 0.042700 | \n",
"
\n",
" \n",
" 4400 | \n",
" 0.039600 | \n",
"
\n",
" \n",
" 4500 | \n",
" 0.040300 | \n",
"
\n",
" \n",
" 4600 | \n",
" 0.044700 | \n",
"
\n",
" \n",
" 4700 | \n",
" 0.040700 | \n",
"
\n",
" \n",
" 4800 | \n",
" 0.036900 | \n",
"
\n",
" \n",
" 4900 | \n",
" 0.046200 | \n",
"
\n",
" \n",
" 5000 | \n",
" 0.040300 | \n",
"
\n",
" \n",
" 5100 | \n",
" 0.031600 | \n",
"
\n",
" \n",
" 5200 | \n",
" 0.029200 | \n",
"
\n",
" \n",
" 5300 | \n",
" 0.031900 | \n",
"
\n",
" \n",
" 5400 | \n",
" 0.030200 | \n",
"
\n",
" \n",
" 5500 | \n",
" 0.035700 | \n",
"
\n",
" \n",
" 5600 | \n",
" 0.028500 | \n",
"
\n",
" \n",
" 5700 | \n",
" 0.034600 | \n",
"
\n",
" \n",
" 5800 | \n",
" 0.027400 | \n",
"
\n",
" \n",
" 5900 | \n",
" 0.034700 | \n",
"
\n",
" \n",
" 6000 | \n",
" 0.038600 | \n",
"
\n",
" \n",
" 6100 | \n",
" 0.028500 | \n",
"
\n",
" \n",
" 6200 | \n",
" 0.030100 | \n",
"
\n",
" \n",
" 6300 | \n",
" 0.028300 | \n",
"
\n",
" \n",
" 6400 | \n",
" 0.029900 | \n",
"
\n",
" \n",
" 6500 | \n",
" 0.035500 | \n",
"
\n",
" \n",
" 6600 | \n",
" 0.031800 | \n",
"
\n",
" \n",
" 6700 | \n",
" 0.029200 | \n",
"
\n",
" \n",
" 6800 | \n",
" 0.031500 | \n",
"
\n",
" \n",
" 6900 | \n",
" 0.029700 | \n",
"
\n",
" \n",
" 7000 | \n",
" 0.030000 | \n",
"
\n",
" \n",
" 7100 | \n",
" 0.038800 | \n",
"
\n",
" \n",
" 7200 | \n",
" 0.030200 | \n",
"
\n",
" \n",
" 7300 | \n",
" 0.024700 | \n",
"
\n",
" \n",
" 7400 | \n",
" 0.034300 | \n",
"
\n",
" \n",
" 7500 | \n",
" 0.030400 | \n",
"
\n",
" \n",
" 7600 | \n",
" 0.029200 | \n",
"
\n",
" \n",
" 7700 | \n",
" 0.035600 | \n",
"
\n",
" \n",
" 7800 | \n",
" 0.033100 | \n",
"
\n",
" \n",
" 7900 | \n",
" 0.028300 | \n",
"
\n",
" \n",
" 8000 | \n",
" 0.027900 | \n",
"
\n",
" \n",
" 8100 | \n",
" 0.031400 | \n",
"
\n",
" \n",
" 8200 | \n",
" 0.038500 | \n",
"
\n",
" \n",
" 8300 | \n",
" 0.034400 | \n",
"
\n",
" \n",
" 8400 | \n",
" 0.030400 | \n",
"
\n",
" \n",
" 8500 | \n",
" 0.033000 | \n",
"
\n",
" \n",
" 8600 | \n",
" 0.034100 | \n",
"
\n",
" \n",
" 8700 | \n",
" 0.027100 | \n",
"
\n",
" \n",
" 8800 | \n",
" 0.029500 | \n",
"
\n",
" \n",
" 8900 | \n",
" 0.025700 | \n",
"
\n",
" \n",
" 9000 | \n",
" 0.029900 | \n",
"
\n",
" \n",
" 9100 | \n",
" 0.024000 | \n",
"
\n",
" \n",
" 9200 | \n",
" 0.028500 | \n",
"
\n",
" \n",
" 9300 | \n",
" 0.031400 | \n",
"
\n",
" \n",
" 9400 | \n",
" 0.028300 | \n",
"
\n",
" \n",
" 9500 | \n",
" 0.030500 | \n",
"
\n",
" \n",
" 9600 | \n",
" 0.025900 | \n",
"
\n",
" \n",
" 9700 | \n",
" 0.033600 | \n",
"
\n",
" \n",
" 9800 | \n",
" 0.030300 | \n",
"
\n",
" \n",
" 9900 | \n",
" 0.028700 | \n",
"
\n",
" \n",
" 10000 | \n",
" 0.022900 | \n",
"
\n",
" \n",
"
"
]
},
"metadata": {}
},
{
"output_type": "stream",
"name": "stderr",
"text": [
":21: UserWarning: To copy construct from a tensor, it is recommended to use sourceTensor.clone().detach() or sourceTensor.clone().detach().requires_grad_(True), rather than torch.tensor(sourceTensor).\n",
" item['labels'] = torch.tensor(self.labels[index])\n",
":21: UserWarning: To copy construct from a tensor, it is recommended to use sourceTensor.clone().detach() or sourceTensor.clone().detach().requires_grad_(True), rather than torch.tensor(sourceTensor).\n",
" item['labels'] = torch.tensor(self.labels[index])\n",
":21: UserWarning: To copy construct from a tensor, it is recommended to use sourceTensor.clone().detach() or sourceTensor.clone().detach().requires_grad_(True), rather than torch.tensor(sourceTensor).\n",
" item['labels'] = torch.tensor(self.labels[index])\n",
":21: UserWarning: To copy construct from a tensor, it is recommended to use sourceTensor.clone().detach() or sourceTensor.clone().detach().requires_grad_(True), rather than torch.tensor(sourceTensor).\n",
" item['labels'] = torch.tensor(self.labels[index])\n",
":21: UserWarning: To copy construct from a tensor, it is recommended to use sourceTensor.clone().detach() or sourceTensor.clone().detach().requires_grad_(True), rather than torch.tensor(sourceTensor).\n",
" item['labels'] = torch.tensor(self.labels[index])\n",
":21: UserWarning: To copy construct from a tensor, it is recommended to use sourceTensor.clone().detach() or sourceTensor.clone().detach().requires_grad_(True), rather than torch.tensor(sourceTensor).\n",
" item['labels'] = torch.tensor(self.labels[index])\n",
":21: UserWarning: To copy construct from a tensor, it is recommended to use sourceTensor.clone().detach() or sourceTensor.clone().detach().requires_grad_(True), rather than torch.tensor(sourceTensor).\n",
" item['labels'] = torch.tensor(self.labels[index])\n",
":21: UserWarning: To copy construct from a tensor, it is recommended to use sourceTensor.clone().detach() or sourceTensor.clone().detach().requires_grad_(True), rather than torch.tensor(sourceTensor).\n",
" item['labels'] = torch.tensor(self.labels[index])\n",
":21: UserWarning: To copy construct from a tensor, it is recommended to use sourceTensor.clone().detach() or sourceTensor.clone().detach().requires_grad_(True), rather than torch.tensor(sourceTensor).\n",
" item['labels'] = torch.tensor(self.labels[index])\n",
":21: UserWarning: To copy construct from a tensor, it is recommended to use sourceTensor.clone().detach() or sourceTensor.clone().detach().requires_grad_(True), rather than torch.tensor(sourceTensor).\n",
" item['labels'] = torch.tensor(self.labels[index])\n",
":21: UserWarning: To copy construct from a tensor, it is recommended to use sourceTensor.clone().detach() or sourceTensor.clone().detach().requires_grad_(True), rather than torch.tensor(sourceTensor).\n",
" item['labels'] = torch.tensor(self.labels[index])\n",
":21: UserWarning: To copy construct from a tensor, it is recommended to use sourceTensor.clone().detach() or sourceTensor.clone().detach().requires_grad_(True), rather than torch.tensor(sourceTensor).\n",
" item['labels'] = torch.tensor(self.labels[index])\n",
":21: UserWarning: To copy construct from a tensor, it is recommended to use sourceTensor.clone().detach() or sourceTensor.clone().detach().requires_grad_(True), rather than torch.tensor(sourceTensor).\n",
" item['labels'] = torch.tensor(self.labels[index])\n",
":21: UserWarning: To copy construct from a tensor, it is recommended to use sourceTensor.clone().detach() or sourceTensor.clone().detach().requires_grad_(True), rather than torch.tensor(sourceTensor).\n",
" item['labels'] = torch.tensor(self.labels[index])\n",
":21: UserWarning: To copy construct from a tensor, it is recommended to use sourceTensor.clone().detach() or sourceTensor.clone().detach().requires_grad_(True), rather than torch.tensor(sourceTensor).\n",
" item['labels'] = torch.tensor(self.labels[index])\n",
":21: UserWarning: To copy construct from a tensor, it is recommended to use sourceTensor.clone().detach() or sourceTensor.clone().detach().requires_grad_(True), rather than torch.tensor(sourceTensor).\n",
" item['labels'] = torch.tensor(self.labels[index])\n",
":21: UserWarning: To copy construct from a tensor, it is recommended to use sourceTensor.clone().detach() or sourceTensor.clone().detach().requires_grad_(True), rather than torch.tensor(sourceTensor).\n",
" item['labels'] = torch.tensor(self.labels[index])\n",
":21: UserWarning: To copy construct from a tensor, it is recommended to use sourceTensor.clone().detach() or sourceTensor.clone().detach().requires_grad_(True), rather than torch.tensor(sourceTensor).\n",
" item['labels'] = torch.tensor(self.labels[index])\n",
":21: UserWarning: To copy construct from a tensor, it is recommended to use sourceTensor.clone().detach() or sourceTensor.clone().detach().requires_grad_(True), rather than torch.tensor(sourceTensor).\n",
" item['labels'] = torch.tensor(self.labels[index])\n"
]
},
{
"output_type": "execute_result",
"data": {
"text/plain": [
"TrainOutput(global_step=10000, training_loss=0.045082428359985355, metrics={'train_runtime': 7226.7408, 'train_samples_per_second': 22.14, 'train_steps_per_second': 1.384, 'total_flos': 2.119629570048e+16, 'train_loss': 0.045082428359985355, 'epoch': 2.0})"
]
},
"metadata": {},
"execution_count": 5
}
],
"source": [
"trainer.train()"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "lowGDIRRV2Kk"
},
"outputs": [],
"source": [
"from transformers import AutoTokenizer, AutoModelForSequenceClassification\n",
"\n",
"save_directory = \"saved\"\n",
"tokenizer.save_pretrained(save_directory)\n",
"model.save_pretrained(save_directory)\n",
"\n",
"tokenizer = AutoTokenizer.from_pretrained(save_directory)\n",
"model = AutoModelForSequenceClassification.from_pretrained(save_directory)"
]
}
],
"metadata": {
"colab": {
"provenance": [],
"mount_file_id": "1SI5wXUWiK-4VnrwWn6Pq2r2e3pzK15mn",
"authorship_tag": "ABX9TyOWwkZmPEdojeBmja70X/+z",
"include_colab_link": true
},
"kernelspec": {
"display_name": "Python 3",
"name": "python3"
},
"language_info": {
"name": "python"
},
"accelerator": "GPU",
"gpuClass": "standard"
},
"nbformat": 4,
"nbformat_minor": 0
}