然后我们需要使用具有GPU的服务器,来运行下面的代码:
<b>注意:</b>
<ul>
<li>以下的代码,都不要在Jupyter笔记上直接运行,会死机!!</li>
<li>请下载左边的脚本`experiments/tiny/train.py`,在实验服务器上运行。</li>
1. 导入相关库
```python
import datasets
from datasets import load_dataset
from transformers import AutoTokenizer, AutoModel
from transformers import AutoModelForCausalLM
from transformers import TrainingArguments, Seq2SeqTrainingArguments
from transformers import Trainer, Seq2SeqTrainer
import transformers
from transformers import DataCollatorWithPadding
from transformers import TextGenerationPipeline
import torch
import numpy as np
import os, re
from tqdm import tqdm
import torch.nn as nn
```
2. 加载**数据集**
通过 HuggingFace,可以指定数据集名称,运行时自动下载
```python
# 数据集名称
DATASET_NAME = "rotten_tomatoes"# 加载数据集
ra