Git Product home page Git Product logo

bert4torch's Introduction

bert4torch

一款用pytorch来复现bert4keras的简洁训练框架

licence GitHub release PyPI PyPI - Downloads GitHub stars GitHub Issues contributions welcome

1. 下载安装

安装稳定版

pip install bert4torch

安装最新版

pip install git+https://www.github.com/Tongjilibo/bert4torch.git
  • 注意事项:pip包的发布慢于git上的开发版本,git clone注意引用路径,注意权重是否需要转换
  • 测试用例git clone https://github.com/Tongjilibo/bert4torch,修改example中的预训练模型文件路径和数据路径即可启动脚本
  • 自行训练:针对自己的数据,修改相应的数据处理代码块
  • 开发环境:使用torch==1.10版本进行开发,如其他版本遇到不适配,欢迎反馈

2. 功能

3. 快速上手

4. 版本说明

  • v0.2.2:修复t5的norm_mode问题,允许hidden_size不整除num_attention_heads,支持多个schedule(如同时ema+warmup)
  • v0.2.1:兼容torch<=1.7.1的torch.div无rounding_mode,增加自定义metrics,支持断点续训,增加默认Logger和Tensorboard日志
  • v0.2.0:兼容torch<1.9.0的缺失take_along_dim,修复bart中位置向量514的问题,修复Sptokenizer对符号不转换,打印Epoch开始的时间戳,增加parallel_apply
  • v0.1.9:增加mixup/manifold_mixup/temporal_ensembling策略,修复pgd策略param.grad为空的问题,修改tokenizer支持批量
  • v0.1.8:修复原来CRF训练中loss陡增的问题,修复xlnet的token_type_ids输入显存占用大的问题
  • v0.1.7:增加EarlyStop,CRF中自带转bool类型
  • v0.1.6:增加transformer_xl、xlnet、t5_pegasus模型,prompt、预训练等示例,支持增加embedding输入,EMA策略,修复tokenizer和sinusoid的bug
  • v0.1.5:增加GAU-alpha,混合梯度,梯度裁剪,单机多卡(DP、DDP)
  • v0.1.4:增加了VAT,修复了linux下apply_embedding返回项有问题的情况
  • v0.1.3:初始版本

5. 更新:

  • 2022年9月20更新:增加TensorRT示例,支持多个schedule(如同时ema+warmup),sanic+onnx部署,虚拟对抗VAT在多个ouput时支持指定
  • 2022年9月10更新:增加默认Logger和Tensorboard日志,ONNX推理,增加ERNIE模型,修复t5的norm_mode问题,允许hidden_size不整除num_attention_heads
  • 2022年8月28更新:增加nl2sql示例,增加自定义metrics,支持断点续训
  • 2022年8月21更新:增加W2NER和DiffCSE示例,打印Epoch开始的时间戳,增加parallel_apply,兼容torch<=1.7.1的torch.div无rounding_mode
  • 2022年8月14更新:增加有监督句向量、关系抽取、文本生成实验指标,兼容torch<1.9.0的缺失take_along_dim,修复bart中位置向量514的问题,修复Sptokenizer对符号不转换
  • 2022年7月27更新:增加mixup/manifold_mixup/temporal_ensembling策略,修复pgd策略param.grad为空的问题,修改tokenizer支持批量,增加uie示例
  • 2022年7月16更新:修复原来CRF训练中loss陡增的问题,修复xlnet的token_type_ids输入显存占用大的问题
  • 2022年7月10更新:增加金融中文FAQ示例,天池新闻分类top1案例,增加EarlyStop,CRF中自带转bool类型
  • 2022年6月29更新:增加ner的实验,测试crf不同初始化的效果,bert-whitening中文实验
  • 2022年6月13更新:增加seq2seq+前缀树,增加SimCSE/ESimCSE/PromptBert等无监督语义相似度的中文实验
  • 2022年6月05更新:增加PromptBert、PET、P-tuning示例,修改tokenizer对special_tokens分词错误的问题,增加t5_pegasus
  • 2022年5月29更新:transformer_xl、xlnet模型,修改sinusoid位置向量被init_weight的bug,EMA,sohu情感分类示例
  • 2022年5月17更新:增加预训练代码,支持增加embedding输入(如词性,word粒度embedding)
  • 2022年5月01更新:增加了混合梯度,梯度裁剪,单机多卡训练(DP、DDP)
  • 2022年4月25更新:增加了VAT、GAU-alpha等示例,增加了梯度累积,自定义fit()示例
  • 2022年4月15更新:增加了ner_mrc、ner_span、roformer_v2、roformer-sim等示例
  • 2022年4月05更新:增加了GPLinker、TPlinker、SimBERT等示例
  • 2022年3月29更新:增加了CoSENT、R-Drop、UDA等示例
  • 2022年3月22更新:添加GPT、GPT2、T5模型
  • 2022年3月12更新:初版提交

6. Todo List(欢迎建议):

  • elasticsearch和faiss在文本向量检索中的使用

7. 预训练权重

模型分类 权重来源 权重链接 备注(若有)
bert 谷歌原版bert(即bert-base-chinese) tfpytorch tf转pytorch命令转换脚本
bert 哈工大chinese-bert-wwm-ext tf/pytorchpytorch
robert 哈工大chinese-robert-wwm-ext tf/pytorchpytorch
xlnet 哈工大xlnet tf/pytorch config
electra 哈工大electra tfpytorch
macbert 哈工大macbert tfpytorch
albert brightmart tfpytorch
ernie 百度文心 paddlepytorch
roformer 追一科技 tfpytorch
roformer_v2 追一科技 tfpytorch
simbert 追一科技 tfpytorch
roformer-sim 追一科技 ftpytorch
gau-alpha 追一科技 tf 转换脚本
nezha 华为 tfpytorch
gpt CDial-GPT pytorch 转换脚本
gpt2 清华26亿 cmp_lm pytorch 转换脚本
gpt2 中文GPT2_ML模型 tfpytorch 转换脚本
t5 UER pytorch config
mt5 谷歌 pytorch config
t5_pegasus 追一科技 tf 转换脚本
bart 复旦 pytorch 转换脚本

bert4torch's People

Contributors

tongjilibo avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.