From 5eaa914e1bad03747b9982bfb3ad15cb02e0a7d5 Mon Sep 17 00:00:00 2001 From: oobabooga <112222186+oobabooga@users.noreply.github.com> Date: Fri, 12 May 2023 06:09:45 -0300 Subject: [PATCH] Fix settings.json being ignored because of config.yaml --- models/config.yaml | 10 +--------- modules/shared.py | 5 ++++- server.py | 14 ++++++++++++++ 3 files changed, 19 insertions(+), 10 deletions(-) diff --git a/models/config.yaml b/models/config.yaml index 2bef3ce5..cb40d65a 100644 --- a/models/config.yaml +++ b/models/config.yaml @@ -1,11 +1,3 @@ -.*: - wbits: 'None' - model_type: 'None' - groupsize: 'None' - pre_layer: 0 - mode: 'chat' - skip_special_tokens: true - custom_stopping_strings: '' .*(llama|alpac|vicuna|guanaco|koala|llava|wizardlm|metharme|pygmalion-7b): model_type: 'llama' .*(opt-|opt_|opt1|opt3|optfor|galactica|galpaca|pygmalion-350m): @@ -28,7 +20,7 @@ wbits: 6 .*(-5bit|_5bit|int5-): wbits: 5 -.*(-gr32-|-32g-|groupsize32): +.*(-gr32-|-32g-|groupsize32|-32g$): groupsize: 32 .*(-gr64-|-64g-|groupsize64): groupsize: 64 diff --git a/modules/shared.py b/modules/shared.py index fdec1d9b..97ed9719 100644 --- a/modules/shared.py +++ b/modules/shared.py @@ -1,5 +1,6 @@ import argparse import logging +from collections import OrderedDict from pathlib import Path import yaml @@ -200,7 +201,7 @@ def is_chat(): return args.chat -# Loading model-specific settings (default) +# Loading model-specific settings with Path(f'{args.model_dir}/config.yaml') as p: if p.exists(): model_config = yaml.safe_load(open(p, 'r').read()) @@ -216,3 +217,5 @@ with Path(f'{args.model_dir}/config-user.yaml') as p: model_config[k].update(user_config[k]) else: model_config[k] = user_config[k] + +model_config = OrderedDict(model_config) diff --git a/server.py b/server.py index 0332f160..6b89fff5 100644 --- a/server.py +++ b/server.py @@ -878,12 +878,26 @@ if __name__ == "__main__": settings_file = Path(shared.args.settings) elif Path('settings.json').exists(): settings_file = Path('settings.json') + if settings_file is not None: logging.info(f"Loading settings from {settings_file}...") new_settings = json.loads(open(settings_file, 'r').read()) for item in new_settings: shared.settings[item] = new_settings[item] + # Set default model settings based on settings.json + shared.model_config['.*'] = { + 'wbits': 'None', + 'model_type': 'None', + 'groupsize': 'None', + 'pre_layer': 0, + 'mode': shared.settings['mode'], + 'skip_special_tokens': shared.settings['skip_special_tokens'], + 'custom_stopping_strings': shared.settings['custom_stopping_strings'], + } + + shared.model_config.move_to_end('.*', last=False) # Move to the beginning + # Default extensions extensions_module.available_extensions = utils.get_available_extensions() if shared.is_chat():