ludwig-ai / ludwig

Low-code framework for building custom LLMs, neural networks, and other AI models
http://ludwig.ai
Apache License 2.0
11.19k stars 1.19k forks source link

Upload to HF fails for non-LLM trained #3570

Closed thelinuxkid closed 3 weeks ago

thelinuxkid commented 1 year ago

Describe the bug When a model is trained for categories/classification, the model weights are saved a file called model/model_weights. If the model is trained with type llm instead, the weights are saved to the directory model/model_weights with contents README.md, adapter_config.json, adapter_model.bin.

To Reproduce Steps to reproduce the behavior:

  1. Train a model with name MODEL_NAME=bug-reprod-model and config
{
    "input_features": [
        {
            "name": "text",
            "type": "text",
            "encoder": {
                "trainable": true,
                "pretrained_model_name_or_path": "meta-llama/Llama-2-7b-hf",
                "adapter": {
                    "type": "lora"
                }
            }
        }
    ],

    "output_features": [
        {
            "name": "label",
            "type": "category"
        }
    ]
}
  1. Attempt to uploaded the trained model for hugging face account HF_ID=bug-reprod-hf-id
ludwig upload hf_hub -r $HF_ID/$MODEL_NAME -m $MODEL_NAME/api_experiment_$MODEL_NAME

You should see an error like this image

  1. Manually move the weights file to a directory

    pushd $MODEL_NAME/api_experiment_$MODEL_NAME/model && \
    mv model_weights adapter_model.bin && \
    mkdir model_weights && \
    mv adapter_model.bin model_weights && \
    cp ~/save/$MODEL_NAME/{adapter_config.json,README.md} model_weights && \
    popd
    1. The upload to HF should now be successful
    ludwig upload hf_hub -r $HF_ID/$MODEL_NAME -m $MODEL_NAME/api_experiment_$MODEL_NAME

    image

Expected behavior The model should upload to HF without having to manually create the directory

Environment (please complete the following information):

Additional context Add any other context about the problem here.

@arnavgarg1

tgaddair commented 1 year ago

Thanks for reporting this issue @thelinuxkid! @arnavgarg1 what do you think about modifying the upload utility to allow uploading ECD artifacts? Would this be useful?