utterworks / fast-bert

Super easy library for BERT based NLP models
Apache License 2.0
1.85k stars 342 forks source link

Some errors about multilabel classification in Chinese #106

Open lpl22-github opened 4 years ago

lpl22-github commented 4 years ago

I run the example called 'new-toxic-multilabel.ipynb' in English and that's all right. After changing the file in Chinese with the same format , I got such errors :(

learner.fit(args.num_train_epochs, args.learning_rate, validate=True)

./models/output/tensorboard Selected optimization level O1: Insert automatic casts around Pytorch functions and Tensor methods.

Defaults for this optimization level are: enabled : True opt_level : O1 cast_model_type : None patch_torch_functions : True keep_batchnorm_fp32 : None master_weights : None loss_scale : dynamic Processing user overrides (additional kwargs that are not None)... After processing overrides, optimization options are: enabled : True opt_level : O1 cast_model_type : None patch_torch_functions : True keep_batchnorm_fp32 : None master_weights : None loss_scale : dynamic 10/25/2019 22:46:36 - INFO - root - Running training 10/25/2019 22:46:36 - INFO - root - Num examples = 1001 10/25/2019 22:46:36 - INFO - root - Num Epochs = 6 10/25/2019 22:46:36 - INFO - root - Total train batch size (w. parallel, distributed & accumulation) = 8 10/25/2019 22:46:36 - INFO - root - Gradient Accumulation steps = 1 10/25/2019 22:46:36 - INFO - root - Total optimization steps = 756 0.00% [0/6 00:00<00:00]

Interrupted

RuntimeError Traceback (most recent call last)

in () ----> 1 learner.fit(args.num_train_epochs, args.learning_rate, validate=True) 2 frames /usr/local/lib/python3.6/dist-packages/fast_bert/modeling.py in forward(self, input_ids, token_type_ids, attention_mask, labels, position_ids, head_mask) 165 166 loss = loss_fct(logits.view(-1, self.num_labels), --> 167 labels.view(-1, self.num_labels)) 168 outputs = (loss,) + outputs 169 RuntimeError: shape '[-1, 82]' is invalid for input of size 648
patronum08 commented 4 years ago

delete the cache

mohammedayub44 commented 4 years ago

@lpl22-github I'm getting the same error on Urdu dataset, did you happen to resolve this ?

@charon0808 you mean use clear_cache=True in the BertDataBunch ?

patronum08 commented 4 years ago

@lpl22-github I'm getting the same error on Urdu dataset, did you happen to resolve this ?

@charon0808 you mean use clear_cache=True in the BertDataBunch ?

I mean delete the cache file in your project

mohammedayub44 commented 4 years ago

Thanks. @charon0808 Also, it was a mismatch of classes.. the sample notebook file in sample_notebooks folder was helpful. Although i get some errors in saving the model which i posted another issue for.