“chitchat”, “knowledge” and “recommend”. 闲聊,知识问答对话,任务是推荐对话
架子搭起来后就是,工作数据流,把数据的类型,具体数值从输入到输出跟踪好,整个模型额框架就请出了。
# Generate the sequence by using "greedy_search" strategy
ids, scores = model.generate(
input_ids=inputs['input_ids'],
token_type_ids=inputs['token_type_ids'],
position_ids=inputs['position_ids'],
attention_mask=inputs['attention_mask'],
decode_strategy="greedy_search")
print(ids.shape, scores.shape)
# [1, 3] [1, 1]
sequence_ids = ids.numpy().tolist()[0]
sequence_ids = sequence_ids[:sequence_ids.index(tokenizer.sep_token_id)]
response = tokenizer.convert_ids_to_string(sequence_ids, keep_space=False)
print(response)
# 是的
模型输入之前,文本转换成ID然后ID转换成tensor,然后胃如模型得到输出结果,还是tensor,转换成numpy,以numpy为中介,然后转换成python数据类型即可。