generative-ai-docs icon indicating copy to clipboard operation
generative-ai-docs copied to clipboard

How to save fine tuned PaliGemma model?

Open SkalskiP opened this issue 1 month ago • 2 comments

Description of the feature request:

Hi 👋🏻

Thanks a lot for PaliGemma fine-tune example notebook. It worked without any issue. However, it lacks the last step - saving a fine-tuned model. (Or I'm just missing something.) I'd appreciate any help. Thank you. 🙏🏻

What problem are you trying to solve with this feature?

No response

Any other information you'd like to share?

No response

SkalskiP avatar May 16 '24 11:05 SkalskiP

+1 We need this

gokayfem avatar May 16 '24 16:05 gokayfem

Hi @SkalskiP,

Based on this conversation at X, you can use numpy.savez, a function that efficiently stores multiple arrays in a single, uncompressed .npz format.

import big_vision.utils as bv_utils
flat, _ = bv_utils.tree_flatten_with_names(flat)
with open("ckpt.npz", "wb") as f:
  np.savez(f, **{k: v for k, v in flat})

And then load:

bv_utils.load_checkpoint_np("ckpt.npz")

selamw1 avatar May 16 '24 22:05 selamw1

Thanks a lot! @gokayfem I really appreciate the help.

SkalskiP avatar May 17 '24 07:05 SkalskiP