Giter Site home page Giter Site logo

albert-zh-for-pytorch-transformers's Introduction

原參考作者現已提供模型下載與測試結果

https://github.com/lonePatient/albert_pytorch/blob/master/README_zh.md

Albert-zh for pytorch-transformers

  • 停止更新
  • 僅僅是基於參考進行轉換,然後踩踩雷
  • Albert zh for pytorch-transformers
  • 測試支援繁體中文

可用模型

API

先將本repo中的albert_zh放置在你的專案底下

from albert_zh import ...

AlbertConfig
AlbertTokenizer
AlbertModel
AlbertForMaskedLM
AlbertForQuestionAnswering
AlbertForSequenceClassification

https://huggingface.co/transformers/v2.3.0/model_doc/albert.html

使用方法

  • 請參見usage_example.py

    或是參考p208p2002/taipei-QA-BERT的實際使用範例

  • 測試在 transformers 2.3.0 正常運作

常見問題

我想在jupyter、colab引入但是遇到問題

這個repo命名不符合python module命名慣例,並且jupyter本身對自訂的模組沒有很好的支援,請先參考下方的解決範例。後續考慮推上pypi

# 此段code僅適用於jupyter、colab
!git clone https://github.com/p208p2002/albert-zh-for-pytorch-transformers.git albert
import sys 
sys.path.append('.')
from albert.albert_zh import AlbertConfig, AlbertTokenizer, AlbertForSequenceClassification

loss 降不下來,訓練出來變垃圾

確保 model class 與 model config 由 albert_zh 引入,而非 transformers

lonePatient/albert_pytorch#35

AttributeError: 'BertConfig' object has no attribute 'share_type'

config.json增加"share_type":"all"

訓練時模型亂印東西

請用log()代替print(),並且在程式開始的時候先執行一次blockPrint()

import os,sys
def log(*logs):
    enablePrint()
    print(*logs)
    blockPrint()

# Disable
def blockPrint():
    sys.stdout = open(os.devnull, 'w')

# Restore
def enablePrint():
    sys.stdout = sys.__stdout__

測試環境

  • python 3.6.4
  • pyotrch 1.3 (with cuda 10)
  • transformers 2.3.0

參考

albert zh

albert tf to pytorch

albert-zh-for-pytorch-transformers's People

Contributors

p208p2002 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  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.