Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

想使用中间的checkpoint看效果,但最终效果和未训练时一样 #208

Open
tzzzzzzzx opened this issue May 1, 2023 · 2 comments

Comments

@tzzzzzzzx
Copy link

如题,在使用训练完成的adapter_model.bin和adapter_config.json的时候一切正常,但当我把训练过程中checkpoint的adapter_model.bin放到output文件夹,并使用之前已经存在的adapter_config.json时,实际问答过程中模型的表现和没有LoRA的时候完全一样;最关键的是当我撤销上述操作让模型和adapter_config.json用回原来训练完成的版本时,问答过程的表现依然和没有LoRA的时候完全一样
现在直接用ipynb写代码预测,有一些条目有LoRA的效果,另一些则完全没有效果。这是正常现象吗?

@wilson9x1
Copy link

wilson9x1 commented May 2, 2023

+1 文件md5都不一样了。感觉保存时候哪里出问题了。

@yp20000921
Copy link

我也遇到了这样的问题,修改一下代码就好了。
`class ModifiedTrainer(Trainer):
def compute_loss(self, model, inputs, return_outputs=False):
return model(
input_ids=inputs["input_ids"],
labels=inputs["labels"],
).loss

def save_model(self, output_dir=None, _internal_call=False):
    # from transformers.trainer import TRAINING_ARGS_NAME

    os.makedirs(output_dir, exist_ok=True)
    # torch.save(self.args, os.path.join(output_dir, TRAINING_ARGS_NAME))
    # saved_params = {
    #     k: v.to("cpu") for k, v in self.model.named_parameters() if v.requires_grad
    # }
    # torch.save(saved_params, os.path.join(output_dir, "adapter_model.bin"))
    self.model.save_pretrained(output_dir)`

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants