Skip to main content

BERT+ TF Keras For NLP Tasks

说明:本项目处于开发阶段,暂时不可用

简介:以Tensorflow的Keras和Tensorflow hub的Bert预训练模型开发NLP的各种任务。

项目特点

  • 下载稳定,较为典型的测试数据,附带详细介绍
  • 数据接口封装,减少数据的处理工作
  • 模型采用tf.keras完成,方便快捷不失灵活
  • 方便的保存模型和部署

环境

  • Tensorflow:1.13.1
  • Tensorflow-hub

TODO List

句子向量化

  • 但是存在一个重复加载计算图导致速度变慢的问题,体验不佳,后续将改进。 已解决,解决方法是直接使用BERT的分词器,不从hub重新加载,撒花!
  • 性能测试
  • Batch输入

文本分类

  • 二分类任务

已完成。数据量不大的情况下可以不使用微调,否则参数量增大可能会过拟合。

  • 多分类任务 BERT的多分类任务和二分类类似,只需要修改标签,然后sigmod换softmax,损失函数也换成多分类交叉熵即可。目前没有稳定的外链数据,所以没写example。
  • 多标签任务

序列标注

  • NER

开发中

阅读理解

  • 斯坦福SQUAD类似的中文检索式阅读理解

未完成

模型保存和部署

  • h5转saved_model。
  • 最好的方式是可以使用tf.keras.experimental.export_saved_model导出模型,然后直接使用TF serving部署。

TF Data输入

  • 多输入的TF Data写法
  • GPU利用率的比较

其他计划

  • Tensorflow hub加载本地路径
  • Windows测试

其他说明

  • 为什么用tf.keras而不是keras tf.keras成为TF2.0的主要模式,由TF团队开发,支持更多TF的特性包括tf.data以及tf serving,TF2.0出了之后项目会迁移到TF2.0,而keras已经较长时间没有重大更新了,所以tf.keras是更好的选择。
  • 由于网络原因,无法下载Tensorflow hub的BERT模型 这里有一份百度云的,链接, 提取码:4pcq,大小为364.1M,linux下载解压后拷贝到/tmp/,完成后的路径为/tmp/tfhub_modules

参考项目

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

bert-text-0.1.0.tar.gz (4.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

bert_text-0.1.0-py3-none-any.whl (2.6 kB view details)

Uploaded Python 3

File details

Details for the file bert-text-0.1.0.tar.gz.

File metadata

  • Download URL: bert-text-0.1.0.tar.gz
  • Upload date:
  • Size: 4.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.14.0 pkginfo/1.4.2 requests/2.18.4 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.35.0 CPython/3.6.5

File hashes

Hashes for bert-text-0.1.0.tar.gz
Algorithm Hash digest
SHA256 a294fc2f10974459006e5827bff9a122d0767ce66d36aa72789125d73342bd85
MD5 6fd34e47076067625d4e055f1233a0f6
BLAKE2b-256 cb170be97f9d254414f516c7b97a15542aa6c8be89964c69d9ba560147f80034

See more details on using hashes here.

File details

Details for the file bert_text-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: bert_text-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 2.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.14.0 pkginfo/1.4.2 requests/2.18.4 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.35.0 CPython/3.6.5

File hashes

Hashes for bert_text-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 4bab374cf3fd03cc58ec7f7f8330dbbce7f823c71f400656b6c5c0df683bc5fc
MD5 0954f0e7137b554cea55213124f3d103
BLAKE2b-256 0e90271a67bfa4940c5a7d763a5e2091076d476da6dcd2af89c38847b5933f5b

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 files

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page