Thytu / SMIT

SMIT: A Simple Modality Integration Tool
MIT License
15 stars 3 forks source link

feat: SLAM.from_pretrained classmethod #9

Closed Thytu closed 5 months ago

Thytu commented 5 months ago

This PR adds two things:

SMITTrainer

A new trainer replace the default one. SMITTrainer overrides Trainer.save_model (while still relying on it) to add the model's config to safetensors' metadata.

Thanks to that change, safetensors will act as a single input file containing everything needed to load a trained file.

SLAM.from_pretrained

SLAM now provides the SLAM.from_pretrained classmethod to load a trained file. It can be used either by directly taking a safetensors generated by SMITTrainer as input, or safetensors plus a cfg as Dict (i.e in case the safetensors doesn't contain the cfg as metadata.

Closes #3