[Python] How to upload local LLM to private JFrog huggingface-ml repository?

Discussão em 'Python' iniciado por Stack, Março 17, 2025.

  1. Stack

    Stack Membro Participativo

    I want to upload a local LLM to a private Jfrog "huggingface-ml" repository.

    First I have installed the HF python client:

    python3 -m pip install "huggingface_hub[cli]"


    With this client in place, I have created a simple download script to get unsloth/Phi-4-mini-instruct-GGUF:

    from huggingface_hub import snapshot_download

    # Define model repository ID
    model_id = "unsloth/Phi-4-mini-instruct-GGUF"

    # Define local directory to store the model
    local_dir = "./phi3_mini_instruct"

    # Download the model
    print(f" Downloading model: {model_id} ...")
    snapshot_download(repo_id=model_id, local_dir=local_dir, repo_type="model")

    print(f"✅ Model downloaded successfully to: {local_dir}")


    The downlopad worked fine. All files had been in place:

    ls phi3_mini_instruct/
    Phi-4-mini-instruct-Q2_K.gguf Phi-4-mini-instruct-Q4_K_M.gguf Phi-4-mini-instruct.BF16.gguf config.json
    Phi-4-mini-instruct-Q2_K_L.gguf Phi-4-mini-instruct-Q5_K_M.gguf Phi-4-mini-instruct.Q8_0.gguf
    Phi-4-mini-instruct-Q3_K_M.gguf Phi-4-mini-instruct-Q6_K.gguf README.md


    Then, I have used the deploy instructions by jfrog to setup "HF SDK". Then I created an upload routine:

    from huggingface_hub import HfApi

    # Initialize API (make sure you're authenticated)
    api = HfApi()

    # Define model path and repo details
    local_model_path = "/home/fixcybj/phi3_mini_instruct" # Local folder containing model files
    repo_id = "unsloth/Phi-4-mini-instruct-GGUF" # Hugging Face repository ID

    # Upload the folder to the Hugging Face model repository
    api.upload_folder(
    folder_path=local_model_path, # Path to the model folder
    repo_id=repo_id, # The Hugging Face model repository ID
    repo_type="model" # Type of repository (model)
    )

    print(f"✅ Upload complete: {repo_id}")


    When executing this script, I receive following error message:


    python3 upload_hf.py
    Traceback (most recent call last):
    File "/usr/lib/python3/dist-packages/requests/models.py", line 971, in json
    return complexjson.loads(self.text, **kwargs)
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    File "/usr/lib/python3.12/json/__init__.py", line 346, in loads
    return _default_decoder.decode(s)
    ^^^^^^^^^^^^^^^^^^^^^^^^^^
    File "/usr/lib/python3.12/json/decoder.py", line 337, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    File "/usr/lib/python3.12/json/decoder.py", line 355, in raw_decode
    raise JSONDecodeError("Expecting value", s, err.value) from None
    json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

    During handling of the above exception, another exception occurred:

    Traceback (most recent call last):
    File "/home/fixcybj/upload_hf.py", line 11, in <module>
    api.upload_folder(
    File "/home/fixcybj/.local/lib/python3.12/site-packages/huggingface_hub/utils/_validators.py", line 114, in _inner_fn
    return fn(*args, **kwargs)
    ^^^^^^^^^^^^^^^^^^^
    File "/home/fixcybj/.local/lib/python3.12/site-packages/huggingface_hub/hf_api.py", line 1551, in _inner
    return fn(self, *args, **kwargs)
    ^^^^^^^^^^^^^^^^^^^^^^^^^
    File "/home/fixcybj/.local/lib/python3.12/site-packages/huggingface_hub/hf_api.py", line 4688, in upload_folder
    add_operations = self._prepare_upload_folder_additions(
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    File "/home/fixcybj/.local/lib/python3.12/site-packages/huggingface_hub/hf_api.py", line 9189, in _prepare_upload_folder_additions
    self._validate_yaml(
    File "/home/fixcybj/.local/lib/python3.12/site-packages/huggingface_hub/hf_api.py", line 9243, in _validate_yaml
    response_content = response.json()
    ^^^^^^^^^^^^^^^
    File "/usr/lib/python3/dist-packages/requests/models.py", line 975, in json
    raise RequestsJSONDecodeError(e.msg, e.doc, e.pos)
    requests.exceptions.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

    What do I need to change?!

    Continue reading...

Compartilhe esta Página