地址链接:https://www.flyai.com/m/nezha_gpt_dialog.zip
查看来源:https://github.com/bojone/nezha_gpt_dialog
确定自己使用的框架并导入对应的库。导入库实现样例代码可参考 文档中心-预训练模型使用教程
在代码中实现加载预训练模型地址
import numpy as np
from bert4keras.backend import keras, K
from bert4keras.models import build_transformer_model
from bert4keras.tokenizers import Tokenizer
from bert4keras.snippets import AutoRegressiveDecoder
# nezha配置
config_path = './nezha_gpt_dialog/config.json'
checkpoint_path = './nezha_gpt_dialog/model.ckpt'
dict_path = './nezha_gpt_dialog/vocab.txt'
# 建立分词器
tokenizer = Tokenizer(dict_path, do_lower_case=True)
# 建立并加载模型
model = build_transformer_model(
config_path,
checkpoint_path,
model='nezha',
application='lm',)
model.summary()