OpenMOSS / MOSS

An open-source tool-augmented conversational language model from Fudan University
https://txsun1997.github.io/blogs/moss.html
Apache License 2.0
11.9k stars 1.14k forks source link

扩展文本长度失败 #322

Open JaheimLee opened 1 year ago

JaheimLee commented 1 year ago

在config配置中更新相关参数

config = AutoConfig.from_pretrained(model_path, trust_remote_code=True)
config.update({"n_positions": 4000})
config.update({"max_position_embeddings": 4000})
model = AutoModelForCausalLM.from_pretrained(
    model_path, 
    trust_remote_code=True, 
    load_in_8bit=True, 
    device_map='auto',
    torch_dtype=torch.float16,
    config=config
)

可以发现self.causal_mask成功初始化为[1, 1, 4000, 4000]. 然而在_att中再次打印self.causal_mask,shape会重新变为[1, 1, 2048, 2048] 导致尺寸不匹配问题。 为什么register_buffer后矩阵尺寸会变?哪里还存在修改self.causal_mask的逻辑吗?

JaheimLee commented 1 year ago

把register_buffer的persistent改为False好像就可以了

mafamily2496 commented 1 year ago

修改了哪里?

JaheimLee commented 1 year ago

修改了哪里?

https://huggingface.co/fnlp/moss-moon-003-sft/blob/7119d446173035561f40977fb9cb999995bb7517/modeling_moss.py#L63

Cocoalate commented 11 months ago

修改了哪里?

https://huggingface.co/fnlp/moss-moon-003-sft/blob/7119d446173035561f40977fb9cb999995bb7517/modeling_moss.py#L63

请问这个怎么改成False啊。。