将 Llama3.1 7B 微调模型推送到 Huggingface 时出错

问题描述 投票:0回答:1

我在将经过微调的 Llama 3.1 模型推送到 Huggingface 时遇到问题,出现以下错误。 我读过的所有文献都表明我用来推送的下面的代码是正确的,并且模型存在于我的页面上,只是没有与之关联的文件或模型卡。

model.push_to_hub(NEW_MODEL, token=token, max_shard_size="10GB")

模型代码的加载如下,在model.push之前完成:

tokenizer = AutoTokenizer.from_pretrained(NEW_MODEL)

model = AutoModelForCausalLM.from_pretrained(
    MODEL_NAME,
    torch_dtype=torch.float16,
    device_map="auto",
)

model.resize_token_embeddings(len(tokenizer), pad_to_multiple_of=8)
model = PeftModel.from_pretrained(model, NEW_MODEL)
model = model.merge_and_unload()


  

这里有人有建议吗?

干杯!

---------------------------------------------------------------------------
IsADirectoryError                         Traceback (most recent call last)
<ipython-input-86-cac150fe4ba1> in <cell line: 1>()
----> 1 model.push_to_hub(NEW_MODEL, token=token, max_shard_size="10GB")

3 frames
/usr/local/lib/python3.10/dist-packages/transformers/utils/hub.py in push_to_hub(self, repo_id, use_temp_dir, commit_message, private, token, max_shard_size, create_pr, safe_serialization, revision, commit_description, tags, **deprecated_kwargs)
    917 
    918         # Create a new empty model card and eventually tag it
--> 919         model_card = create_and_tag_model_card(
    920             repo_id, tags, token=token, ignore_metadata_errors=ignore_metadata_errors
    921         )

/usr/local/lib/python3.10/dist-packages/transformers/utils/hub.py in create_and_tag_model_card(repo_id, tags, token, ignore_metadata_errors)
   1172     try:
   1173         # Check if the model card is present on the remote repo
-> 1174         model_card = ModelCard.load(repo_id, token=token, ignore_metadata_errors=ignore_metadata_errors)
   1175     except EntryNotFoundError:
   1176         # Otherwise create a simple model card from template

/usr/local/lib/python3.10/dist-packages/huggingface_hub/repocard.py in load(cls, repo_id_or_path, repo_type, token, ignore_metadata_errors)
    185 
    186         # Preserve newlines in the existing file.
--> 187         with card_path.open(mode="r", newline="", encoding="utf-8") as f:
    188             return cls(f.read(), ignore_metadata_errors=ignore_metadata_errors)
    189 

/usr/lib/python3.10/pathlib.py in open(self, mode, buffering, encoding, errors, newline)
   1117         if "b" not in mode:
   1118             encoding = io.text_encoding(encoding)
-> 1119         return self._accessor.open(self, mode, buffering, encoding, errors,
   1120                                    newline)
   1121 

IsADirectoryError: [Errno 21] Is a directory: 'Mottzerella/Llama-3-8B-Instruct-Finance-RAG'

尝试在登录 Google Colab 时将保存的模型推送到 Huggingface。 尝试了不同版本的推送,包括 use_temp_dir=True,均具有相同的结果。 该模型本身列在我的 Huggingface 中,但没有任何文件与其关联。 预计模型会被推送,但出现了上述错误。

huggingface llama fine-tuning huggingface-hub llama3.1
1个回答
0
投票

根据https://github.com/huggingface/transformers/issues/28543 该问题源于具有与

NEW_MODEL
相同名称的本地路径和具有 id
NEW_MODEL
且没有模型卡的远程存储库。 解决这个问题:

  • 将本地路径重命名为其他路径
  • push_to_hub
    到具有新 ID 的存储库,例如
    NEW_MODEL_2
© www.soinside.com 2019 - 2024. All rights reserved.