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

Trouble to load a litpgt trained model using transformers library #1910

Open
nxtr-admin-it opened this issue Jan 20, 2025 · 0 comments
Open
Labels
question Further information is requested

Comments

@nxtr-admin-it
Copy link

Hey, I fine-tuned a LLM using lit got (llama 3.1 being my base model) and uploaded it to HuggingFace Hub.

  1. I noticed that I was not able to download this model using Transformers library, the reason being that "model.safetensors" or a ".bin" file was not found to download. This occurs because litgpt stores the model in a .pth format which is not recognized by the Transformers library.
  2. So I thought of using litgpt to load the model directly:
     from litgpt import LLM
     model = LLM.load(model_name).to(device)

Issues here: "model_name" only supports models which are supported by litgpt (you'll get a list of models supported if you do litgpt download list.
a. How do I add my fine tuned model to this list?
b. If a model is not available locally, it has to go to Hugging Face Hub and download the model, which isn't happening.

  1. I refer to this documentation to convert the weights of the model to a different format:
    https://github.com/Lightning-AI/litgpt/blob/main/tutorials/convert_lit_models.md

    I end up getting this error: OSError: Error no file named pytorch_model.bin, model.safetensors, tf_model.h5, model.ckpt.index or flax_model.msgpack found in directory /Users/nxtr-admin-it/Desktop/nextoar/nxtr-models/manufacturing-llm/.
    (the whole point of me doing this was to convert my model to a .safetnsors or a .bin file so I can load it using Transformers library)

  2. litgpt convert_from_litgpt $finetuned_dir/final/ out/hf-tinyllama/converted Not able to make this script work too..

Can someone help me out with this?

  1. When I manually converted the model to a .bin file using a script, I was able to load the model using Transformers library, but the accuracy dropped significantly. So I think there was some issue while converting the file from .pth to .bin due to which there was a drop In the accuracy. Because the same model when loaded using litgpt gives really good results
@nxtr-admin-it nxtr-admin-it added the question Further information is requested label Jan 20, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

1 participant