文件最后提交记录最后更新时间
!1899 [Pytorch][built-in][nlp][BiLSTM-CRF]文件夹重命名并增加license文件 * 文件夹重命名并增加license 3 年前
!4721 [自研][PyTorch]BiLSTM-CRF_for_PyTorch模型脚本修复导包问题 * update PyTorch/built-in/nlp/BiLSTM-CRF_for_PyTorch/test/env_npu.sh. 2 年前
!1899 [Pytorch][built-in][nlp][BiLSTM-CRF]文件夹重命名并增加license文件 * 文件夹重命名并增加license 3 年前
fix link validity Co-authored-by: frozenleaves<914814442@qq.com> # message auto-generated for no-merge-commit merge: !7517 merge master into master fix link validity Created-by: frozenn Commit-by: frozenleaves Merged-by: ascend-robot Description: ## Motivation Please describe the motivation of this PR and the goal you want to achieve through this PR. ## Modification Please briefly describe what modification is made in this PR. ## Self-test (Optional) If modifications to this PR may cause/fix function/accuracy/performance DTSs/issues, a self-inspection record needs to be attached. ## BC-breaking (Optional) If there are compatibility issues, such as dependencies on cann/torch_npu versions, they need to be explained in the PR. ## Checklist **Before PR**: - [ ] The new code needs to comply with the Clean Code specification. - [ ] The PR content is self-checked, and the expression can be clear and the writing standardized **After PR**: - [ ] CLA has been signed and all committers have signed the CLA in this PR. - [ ] The ci-pipeline is passed, Code Check is passed. See merge request: Ascend/ModelZoo-PyTorch!75171 个月前
!5313 【PyTorch】【HRNet/InceptionV3/CenterNet/BiLSTM-CRF】修复适配auto prof引入的错误 * adapt auto prof 2 年前
fix link validity Co-authored-by: frozenleaves<914814442@qq.com> # message auto-generated for no-merge-commit merge: !7517 merge master into master fix link validity Created-by: frozenn Commit-by: frozenleaves Merged-by: ascend-robot Description: ## Motivation Please describe the motivation of this PR and the goal you want to achieve through this PR. ## Modification Please briefly describe what modification is made in this PR. ## Self-test (Optional) If modifications to this PR may cause/fix function/accuracy/performance DTSs/issues, a self-inspection record needs to be attached. ## BC-breaking (Optional) If there are compatibility issues, such as dependencies on cann/torch_npu versions, they need to be explained in the PR. ## Checklist **Before PR**: - [ ] The new code needs to comply with the Clean Code specification. - [ ] The PR content is self-checked, and the expression can be clear and the writing standardized **After PR**: - [ ] CLA has been signed and all committers have signed the CLA in this PR. - [ ] The ci-pipeline is passed, Code Check is passed. See merge request: Ascend/ModelZoo-PyTorch!75171 个月前
!1899 [Pytorch][built-in][nlp][BiLSTM-CRF]文件夹重命名并增加license文件 * 文件夹重命名并增加license 3 年前
ND开关适配修改 3 年前
README.md

BiLstm for PyTorch

概述

简述

LSTM常常被用来解决序列标注问题。LSTM依靠神经网络超强的非线性拟合能力,在训练时将样本通过高维空间中的复杂非线性变换,学习到从样本到标注的函数,之后使用这个函数为指定的样本预测每个token的标注。

  • 参考实现:

    url=https://github.com/luopeixiang/named_entity_recognition
    commit_id=acb18af835ecdaab353d8185a79d82031df4e828
    
  • 适配昇腾 AI 处理器的实现:

    url=https://gitcode.com/ascend/ModelZoo-PyTorch.git
    code_path=PyTorch/built-in/nlp
    

准备训练环境

该模型为不随版本演进模型(随版本演进模型范围可在此处查看),未在最新昇腾配套软件中适配验证,您可以:

  1. 根据下面提供PyTorch版本在软件版本配套表中选择匹配的CANN等软件下载使用。
  2. 查看软件版本配套表后确认对该模型有新版本PyTorch和CANN中的适配需求,请在modelzoo/issues中提出您的需求。自行适配不保证精度和性能达标。

准备环境

  • 当前模型支持的 PyTorch 历史版本和已知三方库依赖如下表所示。

    表 1 版本支持表

    Torch_Version 三方库依赖版本
    PyTorch 1.5 -
    PyTorch 1.8 -
    PyTorch 1.11 -
    PyTorch 2.1 -
  • 环境准备指导。

    请参考《Pytorch框架训练环境准备》。

  • 安装依赖。

    在模型源码包根目录下执行命令,安装模型需要的依赖。

    pip install -r requirements.txt
    

准备数据集

  1. 获取数据集。

    请用户自行获取数据集ResumeNER,并将获取好的数据集放在源码包根目录下新建的BiLstm/文件夹下,数据集目录结构如下所示:

    ├── BiLstm
       ├── ResumeNER
          ├── dev.char.bmes               
          ├── test.char.bmes
          ├── train.char.bmes
    

    说明: 该数据集的训练过程脚本只作为一种参考示例。

开始训练

训练模型

  1. 进入解压后的源码包根目录。

    cd /${模型文件夹名称} 
    
  2. 运行训练脚本。

    该模型支持单机单卡训练和单机8卡训练。

    • 单机单卡训练

      启动单卡训练。

      bash ./test/train_full_1p.sh  # 单卡精度
      
      bash ./test/train_performance_1p.sh  # 单卡性能
      
    • 单机8卡训练

      启动8卡训练。

      bash ./test/train_full_8p.sh  # 8卡精度
      
      bash ./test/train_performance_8p.sh  # 8卡性能
      

模型训练脚本参数说明如下。

公共参数:
--amp_opt_level                              //混合精度类型
--seed                                       //固定随机参数 
--distributed                                //是否使用多卡训练
--local_rank                                 //指定的训练用卡
--batch_size                                 //训练批次大小
--train_epochs                               //重复训练次数

训练结果展示

表 2 训练结果展示表

NAME Acc@f1 FPS AMP_Type Torch_Version
8p-竞品V 0.9513 16,457.14 O2 1.5
1p-竞品V 0.9592 2,021.05 O2 1.5
1p-NPU 0.9502 209 O2 1.8
8p-NPU 0.9643 1572 O2 1.8

说明: 该模型的性能评测需带cache或者开启二进制。

版本说明

变更

2023.02.14:更新readme,重新发布。

2022.09.16:首次发布。

FAQ

无。