User config precedence over GGUF metadata
This commit is contained in:
parent
8250d0149d
commit
3d1c0f173d
2 changed files with 13 additions and 11 deletions
|
@ -52,7 +52,14 @@ def get_model_metadata(model):
|
||||||
if 'llama.rope.scale_linear' in metadata:
|
if 'llama.rope.scale_linear' in metadata:
|
||||||
model_settings['compress_pos_emb'] = metadata['llama.rope.scale_linear']
|
model_settings['compress_pos_emb'] = metadata['llama.rope.scale_linear']
|
||||||
if 'llama.rope.freq_base' in metadata:
|
if 'llama.rope.freq_base' in metadata:
|
||||||
model_settings['rope_freq_base'] = metadata['llama.rope.freq_base']
|
model_settings['rope_freq_base'] = metadata['llama.rope.freq_base']
|
||||||
|
|
||||||
|
# Apply user settings from models/config-user.yaml
|
||||||
|
settings = shared.user_config
|
||||||
|
for pat in settings:
|
||||||
|
if re.match(pat.lower(), model.lower()):
|
||||||
|
for k in settings[pat]:
|
||||||
|
model_settings[k] = settings[pat][k]
|
||||||
|
|
||||||
return model_settings
|
return model_settings
|
||||||
|
|
||||||
|
@ -155,17 +162,14 @@ def save_model_settings(model, state):
|
||||||
user_config = {}
|
user_config = {}
|
||||||
|
|
||||||
model_regex = model + '$' # For exact matches
|
model_regex = model + '$' # For exact matches
|
||||||
for _dict in [user_config, shared.model_config]:
|
|
||||||
if model_regex not in _dict:
|
|
||||||
_dict[model_regex] = {}
|
|
||||||
|
|
||||||
if model_regex not in user_config:
|
if model_regex not in user_config:
|
||||||
user_config[model_regex] = {}
|
user_config[model_regex] = {}
|
||||||
|
|
||||||
for k in ui.list_model_elements():
|
for k in ui.list_model_elements():
|
||||||
if k == 'loader' or k in loaders.loaders_and_params[state['loader']]:
|
if k == 'loader' or k in loaders.loaders_and_params[state['loader']]:
|
||||||
user_config[model_regex][k] = state[k]
|
user_config[model_regex][k] = state[k]
|
||||||
shared.model_config[model_regex][k] = state[k]
|
|
||||||
|
shared.user_config = user_config
|
||||||
|
|
||||||
output = yaml.dump(user_config, sort_keys=False)
|
output = yaml.dump(user_config, sort_keys=False)
|
||||||
with open(p, 'w') as f:
|
with open(p, 'w') as f:
|
||||||
|
|
|
@ -259,10 +259,8 @@ with Path(f'{args.model_dir}/config.yaml') as p:
|
||||||
with Path(f'{args.model_dir}/config-user.yaml') as p:
|
with Path(f'{args.model_dir}/config-user.yaml') as p:
|
||||||
if p.exists():
|
if p.exists():
|
||||||
user_config = yaml.safe_load(open(p, 'r').read())
|
user_config = yaml.safe_load(open(p, 'r').read())
|
||||||
for k in user_config:
|
else:
|
||||||
if k in model_config:
|
user_config = {}
|
||||||
model_config[k].update(user_config[k])
|
|
||||||
else:
|
|
||||||
model_config[k] = user_config[k]
|
|
||||||
|
|
||||||
model_config = OrderedDict(model_config)
|
model_config = OrderedDict(model_config)
|
||||||
|
user_config = OrderedDict(user_config)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue