赞
踩
- from transformers import AutoTokenizer, AutoModelForSequenceClassification
-
- # 加载 ERNIE tokenizer
- tokenizer = AutoTokenizer.from_pretrained("nghuyong/ernie-1.0")
-
- # 加载 ERNIE 预训练模型,用于分类任务
- model = AutoModelForSequenceClassification.from_pretrained("nghuyong/ernie-1.0", num_labels=15)
-
- # 对输入文本进行编码
- text = "这是一段待分类的中文文本。"
- encoded_input = tokenizer(text, truncation=True, padding=True, return_tensors='pt')
-
- # 获取模型输出
- output = model(**encoded_input)
这段代码使用 AutoTokenizer
类从 "nghuyong/ernie-1.0"
checkpoint 加载 tokenizer,并使用 AutoModelForSequenceClassification
类从相同的 checkpoint 加载预训练模型。在这个例子中,该模型用于中文文本分类任务,因此 num_labels
参数被设置为 15,这是数据集中的类别数目。
- ------------Epoch: 0 ----------------
- epoch: 0, iter_num: 100, loss: 1.7696, 15.38%
- epoch: 0, iter_num: 200, loss: 0.6329, 30.77%
- epoch: 0, iter_num: 300, loss: 0.5543, 46.15%
- epoch: 0, iter_num: 400, loss: 1.2803, 61.54%
- epoch: 0, iter_num: 500, loss: 0.4909, 76.92%
- epoch: 0, iter_num: 600, loss: 0.7790, 92.31%
- Epoch: 0, Average training loss: 0.9317
- Accuracy: 0.8409
- Average testing loss: 0.5869
- -------------------------------
- ------------Epoch: 1 ----------------
- epoch: 1, iter_num: 100, loss: 0.4217, 15.38%
- epoch: 1, iter_num: 200, loss: 0.1333, 30.77%
- epoch: 1, iter_num: 300, loss: 0.5391, 46.15%
- epoch: 1, iter_num: 400, loss: 0.4612, 61.54%
- epoch: 1, iter_num: 500, loss: 0.3900, 76.92%
- epoch: 1, iter_num: 600, loss: 0.4132, 92.31%
- Epoch: 1, Average training loss: 0.4501
- Accuracy: 0.8466
- Average testing loss: 0.5791
- -------------------------------
- ------------Epoch: 2 ----------------
- epoch: 2, iter_num: 100, loss: 0.6343, 15.38%
- epoch: 2, iter_num: 200, loss: 0.4136, 30.77%
- epoch: 2, iter_num: 300, loss: 0.2595, 46.15%
- epoch: 2, iter_num: 400, loss: 0.4415, 61.54%
- epoch: 2, iter_num: 500, loss: 0.1030, 76.92%
- epoch: 2, iter_num: 600, loss: 0.0143, 92.31%
- Epoch: 2, Average training loss: 0.3240
- Accuracy: 0.8443
- Average testing loss: 0.6346
- -------------------------------
- ------------Epoch: 3 ----------------
- epoch: 3, iter_num: 100, loss: 0.3799, 15.38%
- epoch: 3, iter_num: 200, loss: 0.6112, 30.77%
- epoch: 3, iter_num: 300, loss: 0.1612, 46.15%
- epoch: 3, iter_num: 400, loss: 0.1312, 61.54%
- epoch: 3, iter_num: 500, loss: 0.4110, 76.92%
- epoch: 3, iter_num: 600, loss: 0.0074, 92.31%
- Epoch: 3, Average training loss: 0.2366
- Accuracy: 0.8501
- Average testing loss: 0.7379
- -------------------------------
- ------------Epoch: 4 ----------------
- epoch: 4, iter_num: 100, loss: 0.1996, 15.38%
- epoch: 4, iter_num: 200, loss: 0.3158, 30.77%
- epoch: 4, iter_num: 300, loss: 0.0271, 46.15%
- epoch: 4, iter_num: 400, loss: 0.0166, 61.54%
- epoch: 4, iter_num: 500, loss: 0.2053, 76.92%
- epoch: 4, iter_num: 600, loss: 0.4321, 92.31%
- Epoch: 4, Average training loss: 0.1704
- Accuracy: 0.8459
- Average testing loss: 0.7492
- -------------------------------
- from transformers import AutoTokenizer, AutoModelForSequenceClassification
-
- # 加载分类15类 tokenizer
- tokenizer = AutoTokenizer.from_pretrained("bert-base-chinese")
-
- # 加载分类15类预训练模型,用于分类任务
- model = AutoModelForSequenceClassification.from_pretrained("ckiplab/bert-base-chinese-15cls", num_labels=15)
这段代码使用 AutoTokenizer
类从 "bert-base-chinese"
checkpoint 加载 tokenizer,并使用 AutoModelForSequenceClassification
类从 "ckiplab/bert-base-chinese-15cls"
checkpoint 加载分类15类预训练模型。在这个例子中,该模型用于中文文本分类任务,因此 num_labels
参数被设置为 15,这是数据集中的类别数目。
准备好文本分类的数据集,将其分成训练集、验证集和测试集,并进行标注。
下载ALBERT的预训练模型权重,通常来自于Hugging Face提供的Transformers库,或Google Research发布的官方源码。
使用相应的深度学习框架,例如PyTorch或TensorFlow,加载ALBERT模型,并根据需要对模型进行微调或者冻结预训练模型的权重进行fine-tuning。
对训练集进行训练,使用验证集进行模型调优,最终在测试集上进行模型评估。
以下是一个ALBERT+PyTorch的分类模型示例代码,用于15类文本分类
- import torch
- from transformers import AlbertTokenizer, AlbertForSequenceClassification
-
- # 加载预训练模型和tokenizer
- tokenizer = AlbertTokenizer.from_pretrained('albert-base-v2')
- model = AlbertForSequenceClassification.from_pretrained('albert-base-v2', num_labels=15)
-
- # 准备数据集
- train_texts = [...] # 训练集文本
- train_labels = [...] # 训练集标签
- val_texts = [...] # 验证集文本
- val_labels = [...] # 验证集标签
- test_texts = [...] # 测试集文本
- test_labels = [...] # 测试集标签
-
- def encode_text(texts):
- return tokenizer.batch_encode_plus(texts, padding=True, truncation=True, return_tensors='pt')
-
- train_encodings = encode_text(train_texts)
- val_encodings = encode_text(val_texts)
- test_encodings = encode_text(test_texts)
-
- # 将训练集和验证集的标签作为Tensor传入
- train_labels = torch.tensor(train_labels)
- val_labels = torch.tensor(val_labels)
-
- # 将预处理好的数据输入模型中进行微调
- optimizer = torch.optim.AdamW(model.parameters(), lr=1e-5)
- train_dataset = torch.utils.data.TensorDataset(train_encodings['input_ids'], train_encodings['attention_mask'], train_labels)
- val_dataset = torch.utils.data.TensorDataset(val_encodings['input_ids'], val_encodings['attention_mask'], val_labels)
-
- # 定义训练函数
- def train_epoch(model, dataloader, optimizer):
- model.train()
- for batch in dataloader:
- optimizer.zero_grad()
- input_ids, attention_mask, labels = batch
- outputs = model(input_ids, attention_mask=attention_mask, labels=labels)
- loss = outputs[0]
- loss.backward()
- optimizer.step()
- return loss.item()
-
- # 开始训练
- train_dataloader = torch.utils.data.DataLoader(train_dataset, batch_size=16, shuffle=True)
- val_dataloader = torch.utils.data.DataLoader(val_dataset, batch_size=16, shuffle=False)
-
- for epoch in range(3):
- train_loss = train_epoch(model, train_dataloader, optimizer)
- print(f'training loss: {train_loss}')
-
- # 在验证集上评估模型
- model.eval()
- with torch.no_grad():
- val_preds = []
- for batch in val_dataloader:
- input_ids, attention_mask, labels = batch
- outputs = model(input_ids, attention_mask=attention_mask)
- val_preds += outputs[0].argmax(axis=-1).tolist()
- acc = sum([1 if p == l else 0 for p, l in zip(val_preds, val_labels)]) / len(val_labels)
- print(f'validation accuracy: {acc}')
-
- # 在测试集上进行测试
- test_dataset = torch.utils.data.TensorDataset(test_encodings['input_ids'], test_encodings['attention_mask'])
- test_dataloader = torch.utils.data.DataLoader(test_dataset, batch_size=16, shuffle=False)
-
- model.eval()
- with torch.no_grad():
- test_preds = []
- for batch in test_dataloader:
- input_ids, attention_mask = batch
- outputs = model(input_ids, attention_mask=attention_mask)
- test_preds += outputs[0].argmax(axis=-1).tolist()
- acc = sum([1 if p == l else 0 for p, l in zip(test_preds, test_labels)]) / len(test_labels)
- print(f'test accuracy: {acc}')
其中,ALBERT的预训练模型可以通过AlbertTokenizer.from_pretrained()
和AlbertForSequenceClassification.from_pretrained()
方法直接加载,并在调用forward()
方法时传递文本的input_ids和attention_mask。在实际应用中,常常需要根据具体情况进行微调,例如调整batch_size、学习率、优化器等参数,或者在模型中添加额外的层和损失函数,以获取更好的效果。
首先,确保您已经安装了huggingface transformers这个Python库。
接下来,从Hugging Face的模型存储库中获取ALBERT预训练模型。例如,您可以选择ALBERT-base或ALBERT-large模型。您可以使用下面的代码之一:
- from transformers import AlbertTokenizer, AlbertForSequenceClassification
-
- # 加载预训练ALBERT-base模型
- tokenizer = AlbertTokenizer.from_pretrained('voidful/albert_chinese_base')
- model = AlbertForSequenceClassification.from_pretrained('voidful/albert_chinese_base', num_labels=15)
-
- # 加载预训练ALBERT-large模型
- tokenizer = AlbertTokenizer.from_pretrained('voidful/albert_chinese_large')
- model = AlbertForSequenceClassification.from_pretrained('voidful/albert_chinese_large', num_labels=15)
- from transformers import RobertaTokenizer, RobertaForSequenceClassification
-
- # 加载RoBERTa tokenizer
- tokenizer = RobertaTokenizer.from_pretrained('hfl/chinese-roberta-wwm-ext')
-
- # 加载RoBERTa分类模型
- model = RobertaForSequenceClassification.from_pretrained('hfl/chinese-roberta-wwm-ext', num_labels=15)
-
- #————————————————————————————————————————————————————————————————————————————————
-
- from transformers import RobertaTokenizerFast, RobertaForSequenceClassification
-
- # Load the RoBERTa tokenizer
- tokenizer = RobertaTokenizerFast.from_pretrained('hfl/chinese-roberta-wwm-ext')
-
- # Load the pre-trained RoBERTa model for sequence classification
- model = RobertaForSequenceClassification.from_pretrained('hfl/chinese-roberta-wwm-ext', num_labels=15)
这个代码示例使用’Hugging Face’ Transformers库中的RobertaTokenizer
和RobertaForSequenceClassification
类来加载预训练的RoBERTa模型和tokenizer。from_pretrained
方法用于从预训练模型加载tokenizer和模型参数。
请注意, RobertaForSequenceClassification
需要指定num_labels
参数,以指定文本分类的数量。在这个例子中,共有15个分类。您可以根据您的分类任务修改此数字。
同时,基于该预训练模型训练的分类任务使用了中文文本,因此所加载的预训练模型也应为中文预训练模型。在这个例子中,使用的是’chinese-roberta-wwm-ext’模型。如果需要使用其他预训练模型,可以在’Hugging Face’ transformers文档中查找可用的模型列表。
RoBERTa(中文版):RoBERTa 是由 Facebook AI 团队提出的 BERT 变种,其训练过程使用了更多的数据和更长的训练时间。RoBERTa 的中文版也已经发布,并取得了比同等条件下 BERT 更好的效果。你可以通过 Hugging Face 的 Transformers 库来使用 RoBERTa。
- # 导入必要的库
- import torch
- from transformers import XLNetTokenizer, XLNetForSequenceClassification
-
- # 定义分类类别数
- num_labels = 15
-
- # 加载预训练模型和tokenizer
- model_name = 'hfl/chinese-xlnet-base'
- tokenizer = XLNetTokenizer.from_pretrained(model_name)
- model = XLNetForSequenceClassification.from_pretrained(model_name, num_labels=num_labels)
在上面的代码中,我们首先定义了分类类别数 num_labels
,然后通过 XLNetForSequenceClassification
类来加载预训练模型,设置 num_labels
参数为分类类别数。
接着使用 XLNetTokenizer
类来加载对应的tokenizer,然后对样本进行编码,生成输入张量,最后将输入张量传入XLNetForSequenceClassification
模型中获取分类结果。
需要注意的是,本例中我们使用了padding和截断技术来规范输入的文本长度,使之适配模型的输入要求,这里我们将长度限制为64。实际上,长度的限制需要根据具体的应用场景和任务来进行调整。
XLNet:XLNet 是 CMU 和 Google 提出的第一个非自回归的预训练模型。它采用 Transformer-XL 的结构来解决 BERT 中存在的顺序建模的限制,从而更好地捕捉文本中的上下文信息,对中文文本分类也大有帮助。
- # XLNet
- # ——max=64
- # Epoch: 4, Average training loss: 0.1858
- # Accuracy: 0.8409
-
- ------------Epoch: 0 ----------------
- epoch: 0, iter_num: 100, loss: 1.0723, 15.38%
- epoch: 0, iter_num: 200, loss: 0.9870, 30.77%
- epoch: 0, iter_num: 300, loss: 0.2781, 46.15%
- epoch: 0, iter_num: 400, loss: 0.5312, 61.54%
- epoch: 0, iter_num: 500, loss: 0.2781, 76.92%
- epoch: 0, iter_num: 600, loss: 0.5329, 92.31%
- Epoch: 0, Average training loss: 0.9603
- Accuracy: 0.8183
- Average testing loss: 0.6233
- -------------------------------
- ------------Epoch: 1 ----------------
- epoch: 1, iter_num: 100, loss: 0.9092, 15.38%
- epoch: 1, iter_num: 200, loss: 0.4809, 30.77%
- epoch: 1, iter_num: 300, loss: 0.2143, 46.15%
- epoch: 1, iter_num: 400, loss: 0.7193, 61.54%
- epoch: 1, iter_num: 500, loss: 0.2858, 76.92%
- epoch: 1, iter_num: 600, loss: 0.3786, 92.31%
- Epoch: 1, Average training loss: 0.5122
- Accuracy: 0.8290
- Average testing loss: 0.6355
- -------------------------------
- ------------Epoch: 2 ----------------
- epoch: 2, iter_num: 100, loss: 0.2993, 15.38%
- epoch: 2, iter_num: 200, loss: 0.4890, 30.77%
- epoch: 2, iter_num: 300, loss: 0.2096, 46.15%
- epoch: 2, iter_num: 400, loss: 0.2015, 61.54%
- epoch: 2, iter_num: 500, loss: 0.4490, 76.92%
- epoch: 2, iter_num: 600, loss: 0.2591, 92.31%
- Epoch: 2, Average training loss: 0.3701
- Accuracy: 0.8336
- Average testing loss: 0.6460
- -------------------------------
- ------------Epoch: 3 ----------------
- epoch: 3, iter_num: 100, loss: 0.0596, 15.38%
- epoch: 3, iter_num: 200, loss: 0.2204, 30.77%
- epoch: 3, iter_num: 300, loss: 0.0602, 46.15%
- epoch: 3, iter_num: 400, loss: 0.2729, 61.54%
- epoch: 3, iter_num: 500, loss: 0.2173, 76.92%
- epoch: 3, iter_num: 600, loss: 0.6965, 92.31%
- Epoch: 3, Average training loss: 0.2579
- Accuracy: 0.8401
- Average testing loss: 0.7422
- -------------------------------
- ------------Epoch: 4 ----------------
- epoch: 4, iter_num: 100, loss: 0.4096, 15.38%
- epoch: 4, iter_num: 200, loss: 0.4123, 30.77%
- epoch: 4, iter_num: 300, loss: 0.3764, 46.15%
- epoch: 4, iter_num: 400, loss: 0.7553, 61.54%
- epoch: 4, iter_num: 500, loss: 0.1620, 76.92%
- epoch: 4, iter_num: 600, loss: 0.9384, 92.31%
- Epoch: 4, Average training loss: 0.1858
- Accuracy: 0.8409
- Average testing loss: 0.8066
- -------------------------------
- # max_length=64
- ------------Epoch: 0 ----------------
- epoch: 0, iter_num: 100, loss: 1.5357, 15.38%
- epoch: 0, iter_num: 200, loss: 0.9866, 30.77%
- epoch: 0, iter_num: 300, loss: 1.2628, 46.15%
- epoch: 0, iter_num: 400, loss: 0.6299, 61.54%
- epoch: 0, iter_num: 500, loss: 1.0743, 76.92%
- epoch: 0, iter_num: 600, loss: 0.4764, 92.31%
- Epoch: 0, Average training loss: 0.9521
- Accuracy: 0.8213
- Average testing loss: 0.6333
- -------------------------------
- ------------Epoch: 1 ----------------
- epoch: 1, iter_num: 100, loss: 0.2546, 15.38%
- epoch: 1, iter_num: 200, loss: 1.0636, 30.77%
- epoch: 1, iter_num: 300, loss: 0.9060, 46.15%
- epoch: 1, iter_num: 400, loss: 0.2629, 61.54%
- epoch: 1, iter_num: 500, loss: 0.5542, 76.92%
- epoch: 1, iter_num: 600, loss: 0.8182, 92.31%
- Epoch: 1, Average training loss: 0.5034
- Accuracy: 0.8282
- Average testing loss: 0.6348
- -------------------------------
- ------------Epoch: 2 ----------------
- epoch: 2, iter_num: 100, loss: 0.3969, 15.38%
- epoch: 2, iter_num: 200, loss: 0.4862, 30.77%
- epoch: 2, iter_num: 300, loss: 0.1850, 46.15%
- epoch: 2, iter_num: 400, loss: 0.0726, 61.54%
- epoch: 2, iter_num: 500, loss: 0.0423, 76.92%
- epoch: 2, iter_num: 600, loss: 0.3782, 92.31%
- Epoch: 2, Average training loss: 0.3632
- Accuracy: 0.8351
- Average testing loss: 0.6708
- -------------------------------
- ------------Epoch: 3 ----------------
- epoch: 3, iter_num: 100, loss: 0.2537, 15.38%
- epoch: 3, iter_num: 200, loss: 0.0146, 30.77%
- epoch: 3, iter_num: 300, loss: 0.0781, 46.15%
- epoch: 3, iter_num: 400, loss: 0.0059, 61.54%
- epoch: 3, iter_num: 500, loss: 0.4188, 76.92%
- epoch: 3, iter_num: 600, loss: 0.2212, 92.31%
- Epoch: 3, Average training loss: 0.2607
- Accuracy: 0.8382
- Average testing loss: 0.7442
- -------------------------------
- ------------Epoch: 4 ----------------
- epoch: 4, iter_num: 100, loss: 0.0064, 15.38%
- epoch: 4, iter_num: 200, loss: 0.3630, 30.77%
- epoch: 4, iter_num: 300, loss: 0.0475, 46.15%
- epoch: 4, iter_num: 400, loss: 0.1398, 61.54%
- epoch: 4, iter_num: 500, loss: 0.0512, 76.92%
- epoch: 4, iter_num: 600, loss: 0.3366, 92.31%
- Epoch: 4, Average training loss: 0.1803
- Accuracy: 0.8294
- Average testing loss: 0.8796
- -------------------------------
- ------------Epoch: 5 ----------------
- epoch: 5, iter_num: 100, loss: 0.0128, 15.38%
- epoch: 5, iter_num: 200, loss: 0.0030, 30.77%
- epoch: 5, iter_num: 300, loss: 0.2542, 46.15%
- epoch: 5, iter_num: 400, loss: 0.0501, 61.54%
- epoch: 5, iter_num: 500, loss: 0.6167, 76.92%
- epoch: 5, iter_num: 600, loss: 0.2372, 92.31%
- Epoch: 5, Average training loss: 0.1330
- Accuracy: 0.8294
- Average testing loss: 0.9589
- -------------------------------
- ------------Epoch: 6 ----------------
- epoch: 6, iter_num: 100, loss: 0.0014, 15.38%
- epoch: 6, iter_num: 200, loss: 0.0029, 30.77%
- epoch: 6, iter_num: 300, loss: 0.0016, 46.15%
- epoch: 6, iter_num: 400, loss: 0.0014, 61.54%
- epoch: 6, iter_num: 500, loss: 0.0013, 76.92%
- epoch: 6, iter_num: 600, loss: 0.0021, 92.31%
- Epoch: 6, Average training loss: 0.0902
- Accuracy: 0.8363
- Average testing loss: 1.0954
- -------------------------------
- ------------Epoch: 7 ----------------
- epoch: 7, iter_num: 100, loss: 0.0009, 15.38%
- epoch: 7, iter_num: 200, loss: 0.0130, 30.77%
- epoch: 7, iter_num: 300, loss: 0.0011, 46.15%
- epoch: 7, iter_num: 400, loss: 0.0229, 61.54%
- epoch: 7, iter_num: 500, loss: 0.0024, 76.92%
- epoch: 7, iter_num: 600, loss: 0.0031, 92.31%
- Epoch: 7, Average training loss: 0.0690
- Accuracy: 0.8386
- Average testing loss: 1.1462
- -------------------------------
- ------------Epoch: 8 ----------------
- epoch: 8, iter_num: 100, loss: 0.0585, 15.38%
- epoch: 8, iter_num: 200, loss: 0.0040, 30.77%
- epoch: 8, iter_num: 300, loss: 0.0029, 46.15%
- epoch: 8, iter_num: 400, loss: 0.0013, 61.54%
- epoch: 8, iter_num: 500, loss: 0.1690, 76.92%
- epoch: 8, iter_num: 600, loss: 0.0010, 92.31%
- Epoch: 8, Average training loss: 0.0476
- Accuracy: 0.8278
- Average testing loss: 1.2720
- -------------------------------
- ------------Epoch: 9 ----------------
- epoch: 9, iter_num: 100, loss: 0.0019, 15.38%
- epoch: 9, iter_num: 200, loss: 0.0007, 30.77%
- epoch: 9, iter_num: 300, loss: 0.3333, 46.15%
- epoch: 9, iter_num: 400, loss: 0.0404, 61.54%
- epoch: 9, iter_num: 500, loss: 0.2406, 76.92%
- epoch: 9, iter_num: 600, loss: 0.0005, 92.31%
- Epoch: 9, Average training loss: 0.0434
- Accuracy: 0.8286
- Average testing loss: 1.3437
- -------------------------------
- from transformers import ElectraTokenizerFast, ElectraForSequenceClassification
-
- # 加载 ELECTRA tokenizer
- tokenizer = ElectraTokenizerFast.from_pretrained('hfl/chinese-electra-180g-base-discriminator')
-
- # 加载 ELECTRA 预训练模型
- model = ElectraForSequenceClassification.from_pretrained('hfl/chinese-electra-180g-base-discriminator', num_labels=15)
这段代码使用 ElectraTokenizerFast
类从 "hfl/chinese-electra-180g-base-discriminator"
checkpoint 加载 tokenizer,并使用 ElectraForSequenceClassification
类从相同的 checkpoint 加载预训练模型。在这个例子中,该模型用于中文文本分类任务,因此 num_labels
参数被设置为 15,这是数据集中的类别数目。
ELECTRA(中文版):ELECTRA 是由斯坦福大学提出的新型预训练模型,其训练方法使用了替换和重构两种策略,相较于 BERT 而言,其训练速度较快,且在相同的数据分布下能够获得更好的效果。ELECTRA 的中文版目前也已经发布,你可以通过 Hugging Face 的 Transformers 库来使用。
- from transformers import AutoTokenizer, AutoModelForSequenceClassification
-
- # 加载 SpanBERT tokenizer
- tokenizer = AutoTokenizer.from_pretrained("SpanBert/spanbert-base-cased")
-
- # 加载 SpanBERT 预训练模型,用于分类任务
- model = AutoModelForSequenceClassification.from_pretrained("SpanBert/spanbert-base-cased", num_labels=15)
-
- #——————————————————————————————————————————————————————————————————————————————
-
- from transformers import AutoTokenizer, AutoModelForSequenceClassification
-
- # 加载分类15类 tokenizer
- tokenizer = AutoTokenizer.from_pretrained("bert-base-chinese")
-
- # 加载分类15类 SpanBERT 预训练模型,用于分类任务
- model = AutoModelForSequenceClassification.from_pretrained("microsoft/SpanBERT-Base-CHinese-15cls", num_labels=15)
这段代码使用 AutoTokenizer
类从 "SpanBert/spanbert-base-cased"
checkpoint 加载 tokenizer,并使用 AutoModelForSequenceClassification
类从相同的 checkpoint 加载预训练模型。在这个例子中,该模型用于中文文本分类任务,因此 num_labels
参数被设置为 15,这是数据集中的类别数目。
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。