一、基于bert的分类任务识别intent
01 数据包含一段话和这段话所包含的intent+entity,然后从中识别出标注的intent+entity
(1)处理数据部分,将文本数据切分为token列表。
(2)将intent+entity构成的列表数据,然后为对应位置数字
(3)将token根据bert模型,将文本形式转化为数字
(4)将数据输入构建好的基于bert的预训练模型,并对结果进行finetinue,得到loss
(5) 设置500epochs,每100epoch记录一次loss,然后用验证的数据,预测loss和对应的f1,presion,recall指标值。并将每一次最优的模型记录。
02 遇到的问题:
(1) 对于 self.tokenizer.convert_tokens_to_ids(words)、self.bert.config.hidden_size这类型的参数还是比较不了解。
(2)对于代码部分,这部分代码还没有弄懂是什么意思。
no_decay = ["bias", "LayerNorm.weight"]
optimizer_grouped_parameters = [
{
"params": [
p
for n, p in model.named_parameters()
if not any(nd in n for nd in no_decay) and p.requires_grad
],
"weight_decay": config["model"]["weight_decay"],
},
{
"params": [
p
for n, p in model.named_parameters()
if any(nd in n for nd in no_decay) and p.requires_grad
],
"weight_decay": 0.0,
},
]
optimizer = AdamW(
optimizer_grouped_parameters,
lr=config["model"]["learning_rate"],
eps=config["model"]["adam_epsilon"],
)
scheduler = get_linear_schedule_with_warmup(
optimizer,
num_warmup_steps=config["model"]["warmup_steps"],
num_training_steps=config["model"]["max_step"],
)
(3)writer = SummaryWriter(log_dir)这个还没有弄懂是什么意思
二、基于bert的序列标注任务识别slot
这一部分,因为时间原因,只是跑通了代码。还没有时间看更多的细节。后续做为补充。