twnlp/ChineseErrorCorrector3-4B 调用出错

作者: njfanxun创建于 2025年12月18日更新于 2025年12月18日
标签question

Describe the Question

The code is as follows: m3 = GptCorrector(model_name_or_path=model_path) corrected_dict = m3.correct_batch(error_sentences, prefix_prompt='你是一个文本纠错专家,纠正输入句子中的语法错误,并输出正确的句子,输入句子为:') The output is as follows: Generating outputs: 0% | | 0/1 [00:00<?, ?it/s] The attention mask is not set and cannot be inferred from input because the pad token is the same as the eos token. As a consequence, you may observe unexpected behavior. Please pass your input's attention_mask to obtain reliable results. Then the program stops, causing the server to crash and restart. Is it because the model has not finished generating, and is it constantly retrying? Is it consuming up the server resources? In https://huggingface.co/twnlp/ChineseErrorCorrector3-4B, the method used is as follows: text = tokenizer.apply_chat_template(messages, tokenize=False, add_generation_prompt=True, enable_thinking=False # Switches between thinking and non-thinking modes. Default is True.) The parameters in gpt_model.py are different, is there a problem with this?

内容来源: shibing624/pycorrector