Skip to content

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

@nxtr-admin-it

Description

@nxtr-admin-it

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    help wantedExtra attention is neededquestionFurther information is requested

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions