Add base_model
tyty
Is there any chance this attribute could be changed to something like "original_model" ? just because I know "base_model" is used to describe merges like here:
https://huggingface.co/mlabonne/Meta-Llama-3-120B-Instruct/blob/main/README.md?code=true#L7
so it makes it trickier to pull in the original model's metadata and then also add a link to the original model as base_model
so, for now we've opted to use base_model
for everything ie finetunes, merges, and quants.
see doc here:
https://huggingface.co/docs/hub/en/model-cards#specifying-a-base-model
We've thought about encoding more finely a taxonomy of operations but i was lazy to do it at the time 🤣
That being said, as that doc shows, we auto-detect whether a model is a finetune, merge, or quant of its base_model(s). And so we have a "tree" of dependency that you can walk back.
my only concern is from the example above of a merged model
In it, there's this already:
base_model:
- meta-llama/Meta-Llama-3-70B-Instruct
- meta-llama/Meta-Llama-3-70B-Instruct
- meta-llama/Meta-Llama-3-70B-Instruct
- meta-llama/Meta-Llama-3-70B-Instruct
- meta-llama/Meta-Llama-3-70B-Instruct
- meta-llama/Meta-Llama-3-70B-Instruct
- meta-llama/Meta-Llama-3-70B-Instruct
if I were to just automatically add on:
base_model: mlabonne/Meta-Llama-3-120B-Instruct
it'll complain that I have base_model twice, so I'd have to presumably parse through the existing metadata yaml, find if base_model exists, find if it's multi-line, remove them all, and then add my own
not that that's so terrible, I'll survive LOL but it is a weird feeling edge case. Also it makes it so that for a model that's a quant of a merge, it can't list both that it's a merge of a certain model AND that it's a quant of another model, which might be interesting information to have readily available
For me in your use case you would replace the base_model that's in the source model, with your own (pointing to that parent model)
Are you using Python? bc you can use huggingface_hub
to programatically replace base_model (or any YAML) in a model card.
cc @Wauplin who leads https://github.com/huggingface/huggingface_hub
To overwrite base_model
in the ModelCard metadata, you can use metadata_update
:
from huggingface_hub import metadata_update
metadata_update("bartowski/Codestral-22B-v0.1-GGUF", metadata={"base_model": "mistralai/Codestral-22B-v0.1"}, overwrite=True)
If you want to append base_model
to an existing list without overwriting any value, you can use ModelCard
:
from huggingface_hub import ModelCard
new_model = "bartowski/Codestral-22B-v0.1-GGUF"
base_model = "mistralai/Codestral-22B-v0.1"
# Load existing
card = ModelCard.load(new_model)
# Update field
if card.data.base_model is None:
card.data.base_model = base_model
elif isinstance(card.data.base_model, str):
card.data.base_model = [card.data.base_model, base_model]
else:
card.data.base_model.append(base_model)
# Save
card.push_to_hub(new_model)
Hope this proves useful :)
in fact base_model
should be seen as parent model
i.e. the most immediate parent in the evolution tree of models.
So you would overwrite rather than append
yeah makes sense :) still think would be cool but that works
I'll look at implementing that python code, probably a more appropriate way to update the README and metadata in general than basic bash scripting...