Downloads · 30 days
66
0% of all-time downloads
dvm1983/TinyBERT_General_4L_312D_de
TinyBERT_General_4L_312D_de is a fill-mask model from dvm1983. Use it when you need the model to fill a missing word. It is set up for transformers.
Here is represented tinybert model for German language (de). The model was created by distilling of bert base cased model(https://huggingface.co/dbmdz/bert-base-german-cased) in the way described in https://arxiv.org/…
Downloads · 30 days
66
0% of all-time downloads
All-time downloads
22.9K
Public
Repo size
194 MB
Likes
4
Public
Click a slice to open those files.
.bin97.1 MB · 100%
From the Hugging Face model README
Here is represented tinybert model for German language (de). The model was created by distilling of bert base cased model(https://huggingface.co/dbmdz/bert-base-german-cased) in the way described in https://arxiv.org/abs/1909.10351 (TinyBERT: Distilling BERT for Natural Language Understanding)
Dataset: German Wikipedia Text Corpus - https://github.com/t-systems-on-site-services-gmbh/german-wikipedia-text-corpus
Versions: torch==1.4.0 transformers==4.8.1
How to load model for LM(fill-mask) task:
tokenizer = transformers.BertTokenizer.from_pretrained(model_dir + '/vocab.txt', do_lower_case=False) config = transformers.BertConfig.from_json_file(model_dir+'config.json') model = transformers.BertModel(config=config) model.pooler = nn.Sequential(nn.Linear(in_features=model.config.hidden_size, out_features=model.config.hidden_size, bias=True), nn.LayerNorm((model.config.hidden_size,), eps=1e-12, elementwise_affine=True), nn.Linear(in_features=model.config.hidden_size, out_features=len(tokenizer), bias=True))
model.resize_token_embeddings(len(tokenizer))
checkpoint = torch.load(model_dir+'/pytorch_model.bin', map_location=torch.device('cuda')) model.load_state_dict(checkpoint)
In case of NER or Classification task we have to load model for LM task and change pooler:
model.pooler = nn.Sequential(nn.Dropout(p=config.hidden_dropout_prob, inplace=False), nn.Linear(in_features=config.hidden_size, out_features=n_classes, bias=True))