jinmang2 / DOOLY

🦕 A library that handles everything with 🤗 and supports batching to models in PORORO
https://huggingface.co/jinmang2/dooly-hub
Apache License 2.0
36 stars 3 forks source link

dependency parsing error: ValueError and KeyError #2

Closed jinmang2 closed 2 years ago

jinmang2 commented 2 years ago

Issue raising

Analyze issue

Pororo에선 dictionary 객체가 out of index도 <unk>로 고쳐줘서 에러가 발생하지 않음

반대로 Dooly에서는 아래와 같이 label 범위 내에 있어야 하기 때문에 KeyError 발생

        heads = heads.argmax(dim=-1).detach().cpu().numpy()[:, 1:-1]
        labels = labels.argmax(dim=-1).detach().cpu().numpy()[:, 1:-1]

        labelmap0 = np.vectorize(lambda x: self._label0[x + self.tokenizer.nspecial])
        labelmap1 = np.vectorize(lambda x: self._label1[x + self.tokenizer.nspecial])

        return tokens, labelmap0(heads), labelmap1(labels), sent_lengths
C:\huggingface\DOOLY\dooly\tasks\base\sequence_tagging.py in <lambda>(x)
    277         labels = labels.argmax(dim=-1).detach().cpu().numpy()[:, 1:-1]
    278 
--> 279         labelmap0 = np.vectorize(lambda x: self._label0[x + self.tokenizer.nspecial])
    280         labelmap1 = np.vectorize(lambda x: self._label1[x + self.tokenizer.nspecial])
    281 

KeyError: 290

labeling의 결과값은 integer로 output이 나와야 함.

heads = [int(head) - 1 for head in heads]  # due to default <s> token

때문에 <unk> 토큰을 int로 바꾸는 과정에서 ValueError 발생

ValueError: invalid literal for int() with base 10: '<unk>'

Dooly에서 이를 fix하고 pororo에 PR날리기

jinmang2 commented 2 years ago
jinmang2 commented 2 years ago

Dooly에서의 Error는 Fix. issue closing