Skip to main content

An customized pytorch version of pre-trained model. Support hierarchical position encoding.

Project description

torchKbert

  • Our customized version of bert for pytorch

说明

这是笔者基于 Meelfy 的 pytorch_pretrained_BERT 库进行部分定制化修改的模型库。

本项目的初衷是为了满足个人实验的方便,因此不会经常更新。

功能

使用

  • 安装:

    pip install torchKbert
    
  • 典型的使用例子请参考官方 examples 目录。

  • 若想使用层次分解位置编码,使 BERT 可以处理长文本,在 model 中传入参数 is_hierarchical=True 即可。示例如下:

    model = BertModel(config)
    
    encoder_outputs, _ = model(input_ids, token_ids, input_mask, is_hierarchical=True)
    

背景

之前一直在用 Meelfy 编写的 pytorch_pretrained_BERT,调用预训练模型或进行微调已经十分方便。后来因个人的需求,所以就想改写一个支持层次分解位置编码的版本。

苏神的 bert4keras 已经实现了这样的功能。但因个人惯于使用 pytorch,已经很久不用 keras 了,所以才打算自己改写一个。

鸣谢

Project details


Download files

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

Source Distribution

torchKbert-1.0.tar.gz (70.0 kB view details)

Uploaded Source

Built Distribution

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

torchKbert-1.0-py3-none-any.whl (87.6 kB view details)

Uploaded Python 3

File details

Details for the file torchKbert-1.0.tar.gz.

File metadata

  • Download URL: torchKbert-1.0.tar.gz
  • Upload date:
  • Size: 70.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.7.3

File hashes

Hashes for torchKbert-1.0.tar.gz
Algorithm Hash digest
SHA256 a61306dc1d23ad53936d55fa5d3959c6de9f301e54104715dc1de008f29aa27f
MD5 e4e62427c7167f359986180817624f05
BLAKE2b-256 4b976b8916dbf1ccb48556892922d4909772b2ce5e0578d138d2bcab64e88999

See more details on using hashes here.

File details

Details for the file torchKbert-1.0-py3-none-any.whl.

File metadata

  • Download URL: torchKbert-1.0-py3-none-any.whl
  • Upload date:
  • Size: 87.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.7.3

File hashes

Hashes for torchKbert-1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 278faea0580111bdd197070e7395f59ff14c6d5b898358166c27f54444d3a634
MD5 b0bdebb4fce78af0d22ce5922a684c0b
BLAKE2b-256 f87308f4004a5c0b37bc05ca9588a37b1f757925eb8cdff5528e4f2b180af480

See more details on using hashes here.

Supported by

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