Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

extract_lora.py improvements and fixes #333

Merged
merged 9 commits into from
Aug 5, 2024
10 changes: 9 additions & 1 deletion mergekit/card.py
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,8 @@ def generate_card_lora(
base_model_ref: ModelReference,
finetuned_model_ref: ModelReference,
invocation: str,
extended: bool,
vocab_size: int,
name: str,
) -> str:
"""
Expand All @@ -218,7 +220,13 @@ def generate_card_lora(
hf_bases = list(extract_hf_paths([base_model_ref, finetuned_model_ref]))
tags = ["mergekit", "peft"]

details = f"This LoRA adapter was extracted from {modelref_md(finetuned_model_ref)} and uses {modelref_md(base_model_ref)} as a base."
finetuned_ref_md = modelref_md(finetuned_model_ref)
basemodel_ref_md = modelref_md(base_model_ref)

details = f"This LoRA adapter was extracted from {finetuned_ref_md} and uses {basemodel_ref_md} as a base."

if extended:
details += f"\n\n> [!WARNING]\n> This LoRA adapter has an extended vocabulary. Make sure to call `model.resize_token_embeddings({vocab_size})` before applying the adapter to {basemodel_ref_md}"

if os.path.isdir(base_model_ref.model.path) or os.path.isdir(
finetuned_model_ref.model.path
Expand Down
Loading
Loading