Lightning-AI / Lightning-AI/litgpt
Trouble to load a litpgt trained model using transformers library
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 13.7k
- Forks
- 1.5k
- Avg merge
- 15h 37m
- Merged PRs (30d)
- 1
Description
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.
3. 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)
4. ```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?
5. 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
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with tutorials/convert_lit_models.md and reproduce litgpt convert_from_litgpt against the reported finetuned_dir/final/ checkpoint. Check which checkpoint files and configuration the conversion command expects, then compare the converted model's loading and results with the LitGPT version. Done means the conversion workflow is clear and preserves expected model behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- huggingface, python, pytorch
- Domain
- ai, machine-learning
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100