Model.save_pretrained is not saving .bin files! model.push_to_hub is not pushing my model in my HuggingFace directory! What am I missing? Help
Hello everyone,I am trying to save my model after fine tuning and I would like to get a .bin file. Unfortunately, even using this command:trainer.model.save_pretrained(save_directory = “path/to/directory/trained”)base_model = AutoModelForCausalLM.from_pretrained(model_name,low_cpu_mem_usage=True,return_dict=True,torch_dtype=torch.float16,device_map=device_map,)model = PeftModel.from_pretrained(base_model, new_model)model = model.merge_and_unload()model.save_pretrained(save_directory = “path/to/directory/merged”)it gives me back .json and .safetensors files:Finally, when I try to push the model in my HF directory, using the following command:model.push_to_hub(“TeoR95/my_project_dir”, use_temp_dir=False)tokenizer.push_to_hub(“TeoR95/my_project_dir/”, use_temp_dir=False)it returns this error:return {f: os.path.getmtime(os.path.join(working_dir, f)) for f in os.listdir(working_dir)}FileNotFoundError: [Errno 2] No such file or directory: ‘my_project_dir’Obviously, I did the login in HF at the beginning of the script with:from huggingface_hub import loginlogin(“my_token”)What am I missing? Can you help me please? Any suggestion would be super appreciated!Thank you so much in advance!
2024-03-21T09:12:46Z
Anyone?
2024-03-25T07:19:55Z
Have you tried trainer.push_to_hub() ?
2024-03-25T11:48:10Z
setsafe_serialization=Falsewhen you save your modelmodel.save_pretrained(save_directory = “path/to/directory/merged”, safe_serialization=False)
2024-03-25T12:38:48Z
Thank you for your reply!As soon as I test it, I will let you know if it works
2024-03-25T12:39:34Z
Thank you for your reply!Yes, but it again does not give me back a .bin file
2024-03-25T17:56:13Z
that’s weird, is it possible to send your code in Google Colab?
2024-03-26T08:38:25Z
I encountered a similar issue and resolved it by downgrading the Transformer library to version 4.16.2.
2024-03-29T12:30:16Z
Hello everyone,Thank you so much for your kind replies. I am sorry if I could not reply faster, but I tried to login in “discuss.huggingface” many times, but it did not allow me for several days (I still do not know the reason).Anyway, I found out that FastChat (the reason why I tried to have the .bin) can accept also the file types you can see in the image of my first post.In any case,@Mit1208and@mufseeraanswers could be the solution to the issue and I will give it a try for sure.For now, I thank you all from the bottom of my heart for your support!
2024-03-29T13:06:26Z
@TeoR95no problem. As I mentioned just one argument is required, I showed in colab for your reference.You can see output in below image:image2638×1110 367 KBcolab:Google Colab