mirror of
https://github.com/hiyouga/LLaMA-Factory.git
synced 2025-08-04 04:32:50 +08:00
auto match template when change model_name
Former-commit-id: 0bf892ff1a4b9253ee569a7b0dc5270762af13d3
This commit is contained in:
parent
ee7da14f81
commit
4a4623cf2d
@ -49,11 +49,8 @@ def get_model_path(model_name: str) -> str:
|
||||
|
||||
|
||||
def get_template(
|
||||
template: str,
|
||||
model_name: str,
|
||||
) -> str:
|
||||
if template and template != "default":
|
||||
return template
|
||||
if model_name == "Custom":
|
||||
model_name_or_path = get_model_path(model_name)
|
||||
# get last dir
|
||||
|
@ -4,7 +4,7 @@ import gradio as gr
|
||||
|
||||
from llmtuner.extras.constants import METHODS, SUPPORTED_MODELS
|
||||
from llmtuner.extras.template import templates
|
||||
from llmtuner.webui.common import list_checkpoint, get_model_path, save_config
|
||||
from llmtuner.webui.common import list_checkpoint, get_model_path, save_config, get_template
|
||||
from llmtuner.webui.utils import can_quantize
|
||||
|
||||
if TYPE_CHECKING:
|
||||
@ -39,6 +39,7 @@ def create_top() -> Dict[str, "Component"]:
|
||||
) # do not save config since the below line will save
|
||||
|
||||
model_path.change(save_config, [lang, model_name, model_path])
|
||||
model_path.change(get_template, [model_name], [template])
|
||||
|
||||
finetuning_type.change(
|
||||
list_checkpoint, [model_name, finetuning_type], [checkpoints]
|
||||
|
@ -113,7 +113,7 @@ class Runner:
|
||||
checkpoint_dir=checkpoint_dir,
|
||||
finetuning_type=finetuning_type,
|
||||
quantization_bit=int(quantization_bit) if quantization_bit != "None" else None,
|
||||
template=get_template(template, model_name),
|
||||
template=template,
|
||||
source_prefix=source_prefix,
|
||||
dataset_dir=dataset_dir,
|
||||
dataset=",".join(dataset),
|
||||
@ -197,7 +197,7 @@ class Runner:
|
||||
checkpoint_dir=checkpoint_dir,
|
||||
finetuning_type=finetuning_type,
|
||||
quantization_bit=int(quantization_bit) if quantization_bit != "None" else None,
|
||||
template=get_template(template, model_name),
|
||||
template=template,
|
||||
source_prefix=source_prefix,
|
||||
dataset_dir=dataset_dir,
|
||||
dataset=",".join(dataset),
|
||||
|
Loading…
x
Reference in New Issue
Block a user