shibing624 / pycorrector

pycorrector is a toolkit for text error correction. 文本纠错,实现了Kenlm,T5,MacBERT,ChatGLM3,LLaMA等模型应用在纠错场景,开箱即用。
https://www.mulanai.com/product/corrector/
Apache License 2.0
5.51k stars 1.09k forks source link

macbert预训练的时候报错 #350

Closed F-crystal closed 1 year ago

F-crystal commented 1 year ago

我在使用自己的数据集进行训练时出现了如下问题“ValueError: Expected input batch_size (7008) to match target batch_size (6976).”。我所训练的数据集格式如下,自认为和readme中的示例并无差异,因此想要询问我应当从哪方面入手修正这个问题?非常感谢! { "id": "5985", "original_text": "根据《中华人民共和国民事诉讼法》第十三条、第一百三十一条之规定,裁定如:", "wrong_ids": [ 34, 35 ], "correct_text": "根据《中华人民共和国民事诉讼法》第十三条、第一百三十一条之规定,裁定如下:" },

shibing624 commented 1 year ago

original_text需要和correct_text长度一样。

F-crystal commented 1 year ago

已经成功了,非常感谢!

Xf-Zhou commented 1 year ago

@shibing624 作者大佬你好,我在用自有数据训练macbert的时候,发现如下这条训练数据(original_text和correct_text长度一样)也会导致报错Expected input batch_size (60) to match target batch_size (58):

{
    "id": "video-96616",
    "original_text": "二零二一年gdb为二百二十点零零亿元排名第四十六位的是狼溪县二零二一年gdt为二百零八点五三亿元排名第四十七位的是太湖县",
    "wrong_ids": [
        7,
        27,
        37
    ],
    "correct_text": "二零二一年gdp为二百二十点零零亿元排名第四十六位的是郎溪县二零二一年gdp为二百零八点五三亿元排名第四十七位的是太湖县"
}

进一步拆分发现是gdb-gdp这对文本产生的报错,请问下这是什么原因呢?

shibing624 commented 1 year ago

把英文mask掉,或者删除,macbert4csc本身也不会纠正英文。

Xf-Zhou commented 1 year ago

好的,感谢解答!

stale[bot] commented 1 year ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.(由于长期不活动,机器人自动关闭此问题,如果需要欢迎提问)