github实验一 Bert-BiLSTM-CRF-pytorch

https://codechina.csdn.net/mirrors/chenxiaoyouyou/Bert-BiLSTM-CRF-pytorch

README.md
Bert-BiLSTM-CRF-pytorch
使用谷歌预训练bert做字嵌入的BiLSTM-CRF序列标注模型

本模型使用谷歌预训练bert模型(https://github.com/google-research/bert), 同时使用pytorch-pretrained-BERT(https://github.com/huggingface/pytorch-pretrained-BERT) 项目加载bert模型并转化为pytorch参数,CRF代码参考了SLTK(https://github.com/liu-nlper/SLTK)

准备数据格式参见data

模型参数可以在config中进行设置

运行代码

python main.py train --use_cuda=False --batch_size=10

pytorch.bin 百度网盘链接 链接:https://pan.baidu.com/s/160cvZXyR_qdAv801bDY2mQ 提取码:q67r

作者也是新手,很希望看到的大家能够提意见,共同学习

eval epoch: 0| loss: 13.609519958496094

当输出第一轮的结果后,开始报错

eval epoch: 0| loss: 13.609519958496094
Traceback (most recent call last):
File “main.py”, line 94, in
fire.Fire()
File “D:\tools\python\lib\site-packages\fire\core.py”, line 141, in Fire
component_trace = _Fire(component, args, parsed_flag_args, context, name)
File “D:\tools\python\lib\site-packages\fire\core.py”, line 471, in _Fire
target=component.name)
File “D:\tools\python\lib\site-packages\fire\core.py”, line 681, in _CallAndUpdateTrace
component = fn(*varargs, **kwargs)
File “main.py”, line 67, in train
save_model(model,epoch)
File “D:\1学习文档\nlp\代码\Bert-BiLSTM-CRF-pytorch-master\utils.py”, line 81, in save_model
torch.save(model.state_dict(), full_name)
File “D:\tools\python\lib\site-packages\torch\serialization.py”, line 369, in save
with _open_file_like(f, ‘wb’) as opened_file:
File “D:\tools\python\lib\site-packages\torch\serialization.py”, line 230, in _open_file_like
return _open_file(name_or_buffer, mode)
File “D:\tools\python\lib\site-packages\torch\serialization.py”, line 211, in init
super(_open_file, self).init(open(name, mode))
OSError: [Errno 22] Invalid argument: ‘result\2021-06-20#17:00:29–epoch:0’

指向了这里 File “D:\1学习文档\nlp\代码\Bert-BiLSTM-CRF-pytorch-master\utils.py”, line 81, in save_model
torch.save(model.state_dict(), full_name)

参数错误,未找出原因

实验了本机与实验室的机器都是一样的结果

  • 0
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 2
    评论
BERT-BiLSTM-CRF是一种用于命名实体识别任务的模型。它结合了Google的BERT模型和BiLSTM-CRF模型,通过在BERT模型上进行预训练,然后在BiLSTM-CRF模型中进行微调来实现中文命名实体识别。该模型的Tensorflow代码可以在GitHub上找到,由hemingkx编写。 该模型的具体实现细节可以参考知乎上的文章《用BERT做NER?教你用PyTorch轻松入门Roberta!》。在这篇文章中,主要对代码内容进行了讲解,而不深入研究训练参数的选择。 总之,BERT-BiLSTM-CRF模型是一种结合了BERT和BiLSTM-CRF的模型,用于中文命名实体识别任务。它能够通过预训练和微调来提高模型的准确性和性能。<span class="em">1</span><span class="em">2</span><span class="em">3</span> #### 引用[.reference_title] - *1* [BERT-BiLSTM-CRF-NER:NER任务的Tensorflow解决方案将BiLSTM-CRF模型与Google BERT微调和私有服务器服务结合...](https://download.csdn.net/download/weixin_42179184/18490050)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_1"}}] [.reference_item style="max-width: 50%"] - *2* *3* [使用BERT + Bi-LSTM + CRF 实现命名实体识别](https://blog.csdn.net/qq_52852138/article/details/123766574)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_1"}}] [.reference_item style="max-width: 50%"] [ .reference_list ]

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值