CRF IndexError: index -9223372036854775808 is out of bounds for dimension 1 with size 46

username: RaeWen_Chiang
cooked: <p>Hello,<br>
I am trying to train a Bert + CRF model in order to do a NER task.<br>
I trained with the old data without this error.<br>
After I train with more new data, I got this error.</p>
<pre><code class="lang-auto">--------Start Training!--------
  0%|                                                               | 0/34 [00:27&lt;?, ?it/s]
Traceback (most recent call last):
  File "/home/aibox/vscode_venv/Bert/Bert_NER/Bert_CRF/run.py", line 140, in &lt;module&gt;
    run()
  File "/home/aibox/vscode_venv/Bert/Bert_NER/Bert_CRF/run.py", line 137, in run
    train(train_loader, dev_loader, model, optimizer, scheduler, config.roberta_model)
  File "/home/aibox/vscode_venv/Bert/Bert_NER/Bert_CRF/train.py", line 52, in train
    train_epoch(train_loader, model, optimizer, scheduler, epoch)
  File "/home/aibox/vscode_venv/Bert/Bert_NER/Bert_CRF/train.py", line 24, in train_epoch
    loss = model((batch_data, batch_token_starts),
  File "/home/aibox/miniconda3/lib/python3.8/site-packages/torch/nn/modules/module.py", line 1110, in _call_impl
    return forward_call(*input, **kwargs)
  File "/home/aibox/vscode_venv/Bert/Bert_NER/Bert_CRF/model.py", line 45, in forward
    loss = self.crf(logits, labels, loss_mask) * (-1)
  File "/home/aibox/miniconda3/lib/python3.8/site-packages/torch/nn/modules/module.py", line 1110, in _call_impl
    return forward_call(*input, **kwargs)
  File "/home/aibox/vscode_venv/Bert/Bert_NER/Bert_CRF/torchcrf.py", line 102, in forward
    numerator = self._compute_score(emissions, tags, mask)
  File "/home/aibox/vscode_venv/Bert/Bert_NER/Bert_CRF/torchcrf.py", line 192, in _compute_score
    score += self.transitions[tags[i - 1], tags[i]] * mask[i]
IndexError: index -9223372036854775808 is out of bounds for dimension 1 with size 46
</code></pre>
<pre><code class="lang-auto"># my data is a json with text and label,there are some of the data:
{"text":"CURRYTAIWAN灣物運股份有限公司電子發票證明聯補印105年07-08月XX-999047922016-08-3016:25:59格式25隨機碼:9124總計:96賣方:875543買方:1234567零售額96TX","label":{"seller":{"CURRYTAIWAN灣物運股份有限公司":[[0,19]]},"rec_type":{"電子發票證明聯補印":[[20,28]]},"rec_from_date":{"105年07-08月":[[29,38]]},"rec_no":{"XX-99904792":[[39,49]]},"rec_date":{"2016-08-30":[[50,59]]},"rec_time":{"16:25:59":[[60,67]]},"totle_price":{"總計:96":[[80,84]],"零售額96TX":[[104,110]]},"seller_tax_no":{"賣方:875543":[[85,93]]},"buyer":{"買方:1234567":[[94,103]]}}}
{"text":"MKI慶財有限公司電子發票證明聯2013-05-10發票號碼:DB16589502格式:25買方:何益行隨機碼:1744統一編號:61832269地址第1頁/共1頁品名數量單價金額備註第2年年費服務費1000300MIL-P0119-Cew:1銷售額合計1000營業人蓋統一發票專用營業稅應稅:V零稅率免稅50總計1500慶財有限公司總計新台幣壹仟伍佰元整統一編號:62315380龜山區中興里自強西路364巷發票備註:","label":{"seller":{"MKI慶財有限公司":[[0,8]],"慶財有限公司":[[161,166]]},"rec_type":{"電子發票證明聯":[[9,15]]},"rec_date":{"2013-05-10":[[16,25]]},"rec_no":{"發票號碼:DB16589502":[[26,40]]},"buyer":{"買方:何益行":[[46,51]]},"buyer_tax_no":{"統一編號:61832269":[[60,72]]},"items":{"品名數量單價金額備註第2年年費服務費1000300MIL-P0119-Cew:1":[[82,121]]},"totle_price":{"銷售額合計1000":[[122,130]]},"tax":{"營業稅應稅:V零稅率免稅50":[[141,154]]},"price_with_tax":{"總計1500":[[155,160]],"總計新台幣壹仟伍佰元整":[[167,177]]},"seller_tax_no":{"統一編號:62315380":[[178,190]]},"seller_add":{"龜山區中興里自強西路364巷":[[191,204]]}}}
...
</code></pre>
<p>Please help me with possible solution.<br>
I have no idea which part of code need to show, if you need some infotmation, pleas let me know.Thanks!</p>

username: venti07
cooked: <p>Hello I have the same error. How did you fix your problem?</p>

username: Ijazul_Haq
cooked: <p>I have the same error</p>

username: Eagle104fred
cooked: <p>This phenomenon is caused by the absence of label tags in the dataset. Check the tags in the dataset</p>