https://github.com/lonePatient/albert_pytorch/blob/master/README_zh.md
First place albert_zh in this repo under your project
from albert_zh import ...
AlbertConfig
AlbertTokenizer
AlbertModel
AlbertForMaskedLM
AlbertForQuestionAnswering
AlbertForSequenceClassification
https://huggingface.co/transformers/v2.3.0/model_doc/albert.html
usage_example.pyOr refer to the actual usage example of p208p2002/taipei-QA-BERT
This repo naming does not comply with the python module naming convention, and jupyter itself does not have good support for customized modules. Please refer to the solution example below. Consider pushing pypi later
# 此段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
Make sure model class and model config are introduced by albert_zh, not transformers
lonePatient/albert_pytorch#35
config.json adds "share_type":"all"
Please use log() instead of print() , and execute blockPrint() once at the beginning of the program
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__