Do not impose instruct mode while loading models

This commit is contained in:
oobabooga 2023-09-02 11:29:12 -07:00
parent 0576691538
commit 4affa08821
3 changed files with 11 additions and 77 deletions

View file

@ -49,200 +49,142 @@ llama-65b-gptq-3bit:
.*(gr1024|1024g|groupsize1024): .*(gr1024|1024g|groupsize1024):
groupsize: 1024 groupsize: 1024
.*(oasst|openassistant-|stablelm-7b-sft-v7-epoch-3): .*(oasst|openassistant-|stablelm-7b-sft-v7-epoch-3):
mode: 'instruct'
instruction_template: 'Open Assistant' instruction_template: 'Open Assistant'
skip_special_tokens: false skip_special_tokens: false
(?!.*galactica)(?!.*reward).*openassistant: (?!.*galactica)(?!.*reward).*openassistant:
mode: 'instruct'
instruction_template: 'Open Assistant' instruction_template: 'Open Assistant'
skip_special_tokens: false skip_special_tokens: false
(?!.*v0)(?!.*1.1)(?!.*1_1)(?!.*stable)(?!.*chinese).*vicuna: (?!.*v0)(?!.*1.1)(?!.*1_1)(?!.*stable)(?!.*chinese).*vicuna:
mode: 'instruct'
instruction_template: 'Vicuna-v0' instruction_template: 'Vicuna-v0'
.*vicuna.*v0: .*vicuna.*v0:
mode: 'instruct'
instruction_template: 'Vicuna-v0' instruction_template: 'Vicuna-v0'
.*vicuna.*(1.1|1_1|1.3|1_3): .*vicuna.*(1.1|1_1|1.3|1_3):
mode: 'instruct'
instruction_template: 'Vicuna-v1.1' instruction_template: 'Vicuna-v1.1'
.*vicuna.*(1.5|1_5): .*vicuna.*(1.5|1_5):
mode: 'instruct'
instruction_template: 'Vicuna-v1.1' instruction_template: 'Vicuna-v1.1'
truncation_length: 4096 truncation_length: 4096
rms_norm_eps: 5.0e-6 rms_norm_eps: 5.0e-6
.*stable.*vicuna: .*stable.*vicuna:
mode: 'instruct'
instruction_template: 'StableVicuna' instruction_template: 'StableVicuna'
(?!.*chat).*chinese-vicuna: (?!.*chat).*chinese-vicuna:
mode: 'instruct'
instruction_template: 'Alpaca' instruction_template: 'Alpaca'
.*chinese-vicuna.*chat: .*chinese-vicuna.*chat:
mode: 'instruct'
instruction_template: 'Chinese-Vicuna-Chat' instruction_template: 'Chinese-Vicuna-Chat'
.*alpaca: .*alpaca:
mode: 'instruct'
instruction_template: 'Alpaca' instruction_template: 'Alpaca'
.*alpaca-native-4bit: .*alpaca-native-4bit:
mode: 'instruct'
instruction_template: 'Alpaca' instruction_template: 'Alpaca'
wbits: 4 wbits: 4
groupsize: 128 groupsize: 128
.*galactica: .*galactica:
skip_special_tokens: false skip_special_tokens: false
.*dolly-v[0-9]-[0-9]*b: .*dolly-v[0-9]-[0-9]*b:
mode: 'instruct'
instruction_template: 'Alpaca' instruction_template: 'Alpaca'
skip_special_tokens: false skip_special_tokens: false
custom_stopping_strings: '"### End"' custom_stopping_strings: '"### End"'
.*koala: .*koala:
mode: 'instruct'
instruction_template: 'Koala' instruction_template: 'Koala'
.*chatglm: .*chatglm:
mode: 'instruct'
instruction_template: 'ChatGLM' instruction_template: 'ChatGLM'
.*metharme: .*metharme:
mode: 'instruct'
instruction_template: 'Metharme' instruction_template: 'Metharme'
.*llava: .*llava:
mode: 'instruct'
model_type: 'llama' model_type: 'llama'
instruction_template: 'LLaVA' instruction_template: 'LLaVA'
custom_stopping_strings: '"\n###"' custom_stopping_strings: '"\n###"'
.*raven: .*raven:
mode: 'instruct'
instruction_template: 'RWKV-Raven' instruction_template: 'RWKV-Raven'
.*ctx8192: .*ctx8192:
truncation_length: 8192 truncation_length: 8192
.*moss-moon.*sft: .*moss-moon.*sft:
mode: 'instruct'
instruction_template: 'MOSS' instruction_template: 'MOSS'
.*stablelm-tuned: .*stablelm-tuned:
mode: 'instruct'
instruction_template: 'StableLM' instruction_template: 'StableLM'
truncation_length: 4096 truncation_length: 4096
.*stablelm-base: .*stablelm-base:
truncation_length: 4096 truncation_length: 4096
.*galactica.*finetuned: .*galactica.*finetuned:
mode: 'instruct'
instruction_template: 'Galactica Finetuned' instruction_template: 'Galactica Finetuned'
.*galactica.*-v2: .*galactica.*-v2:
mode: 'instruct'
instruction_template: 'Galactica v2' instruction_template: 'Galactica v2'
(?!.*finetuned)(?!.*-v2).*galactica: (?!.*finetuned)(?!.*-v2).*galactica:
mode: 'instruct'
instruction_template: 'Galactica' instruction_template: 'Galactica'
.*guanaco: .*guanaco:
mode: 'instruct'
instruction_template: 'Guanaco non-chat' instruction_template: 'Guanaco non-chat'
.*baize: .*baize:
mode: 'instruct'
instruction_template: 'Baize' instruction_template: 'Baize'
.*mpt-.*instruct: .*mpt-.*instruct:
mode: 'instruct'
instruction_template: 'Alpaca' instruction_template: 'Alpaca'
.*mpt-.*chat: .*mpt-.*chat:
mode: 'instruct'
instruction_template: 'MPT-Chat' instruction_template: 'MPT-Chat'
(?!.*-flan-)(?!.*-t5-).*lamini-: (?!.*-flan-)(?!.*-t5-).*lamini-:
mode: 'instruct'
instruction_template: 'Alpaca' instruction_template: 'Alpaca'
.*incite.*chat: .*incite.*chat:
mode: 'instruct'
instruction_template: 'INCITE-Chat' instruction_template: 'INCITE-Chat'
.*incite.*instruct: .*incite.*instruct:
mode: 'instruct'
instruction_template: 'INCITE-Instruct' instruction_template: 'INCITE-Instruct'
.*wizard.*mega: .*wizard.*mega:
mode: 'instruct'
instruction_template: 'Wizard-Mega' instruction_template: 'Wizard-Mega'
custom_stopping_strings: '"</s>"' custom_stopping_strings: '"</s>"'
.*ziya-: .*ziya-:
mode: 'instruct'
instruction_template: 'Ziya' instruction_template: 'Ziya'
.*koalpaca: .*koalpaca:
mode: 'instruct'
instruction_template: 'KoAlpaca' instruction_template: 'KoAlpaca'
.*openbuddy: .*openbuddy:
mode: 'instruct'
instruction_template: 'OpenBuddy' instruction_template: 'OpenBuddy'
(?!.*chat).*vigogne: (?!.*chat).*vigogne:
mode: 'instruct'
instruction_template: 'Vigogne-Instruct' instruction_template: 'Vigogne-Instruct'
.*vigogne.*chat: .*vigogne.*chat:
mode: 'instruct'
instruction_template: 'Vigogne-Chat' instruction_template: 'Vigogne-Chat'
.*(llama-deus|supercot|llama-natural-instructions|open-llama-0.3t-7b-instruct-dolly-hhrlhf|open-llama-0.3t-7b-open-instruct): .*(llama-deus|supercot|llama-natural-instructions|open-llama-0.3t-7b-instruct-dolly-hhrlhf|open-llama-0.3t-7b-open-instruct):
mode: 'instruct'
instruction_template: 'Alpaca' instruction_template: 'Alpaca'
.*bactrian: .*bactrian:
mode: 'instruct'
instruction_template: 'Bactrian' instruction_template: 'Bactrian'
.*(h2ogpt-oig-|h2ogpt-oasst1-|h2ogpt-research-oasst1-): .*(h2ogpt-oig-|h2ogpt-oasst1-|h2ogpt-research-oasst1-):
mode: 'instruct'
instruction_template: 'H2O-human_bot' instruction_template: 'H2O-human_bot'
.*h2ogpt-gm-: .*h2ogpt-gm-:
mode: 'instruct'
instruction_template: 'H2O-prompt_answer' instruction_template: 'H2O-prompt_answer'
.*manticore: .*manticore:
mode: 'instruct'
instruction_template: 'Manticore Chat' instruction_template: 'Manticore Chat'
.*bluemoonrp-(30|13)b: .*bluemoonrp-(30|13)b:
mode: 'instruct'
instruction_template: 'Bluemoon' instruction_template: 'Bluemoon'
truncation_length: 4096 truncation_length: 4096
.*Nous-Hermes-13b: .*Nous-Hermes-13b:
mode: 'instruct'
instruction_template: 'Alpaca' instruction_template: 'Alpaca'
.*airoboros: .*airoboros:
mode: 'instruct'
instruction_template: 'Vicuna-v1.1' instruction_template: 'Vicuna-v1.1'
.*airoboros.*1.2: .*airoboros.*1.2:
mode: 'instruct'
instruction_template: 'Airoboros-v1.2' instruction_template: 'Airoboros-v1.2'
.*alpa(cino|sta): .*alpa(cino|sta):
mode: 'instruct'
instruction_template: 'Alpaca' instruction_template: 'Alpaca'
.*hippogriff: .*hippogriff:
mode: 'instruct'
instruction_template: 'Hippogriff' instruction_template: 'Hippogriff'
.*lazarus: .*lazarus:
mode: 'instruct'
instruction_template: 'Alpaca' instruction_template: 'Alpaca'
.*guanaco-.*(7|13|33|65)b: .*guanaco-.*(7|13|33|65)b:
mode: 'instruct'
instruction_template: 'Guanaco' instruction_template: 'Guanaco'
.*hypermantis: .*hypermantis:
mode: 'instruct'
instruction_template: 'Alpaca' instruction_template: 'Alpaca'
.*open-llama-.*-open-instruct: .*open-llama-.*-open-instruct:
mode: 'instruct'
instruction_template: 'Alpaca' instruction_template: 'Alpaca'
.*starcoder-gpteacher-code-instruct: .*starcoder-gpteacher-code-instruct:
mode: 'instruct'
instruction_template: 'Alpaca' instruction_template: 'Alpaca'
.*tulu: .*tulu:
mode: 'instruct'
instruction_template: 'Tulu' instruction_template: 'Tulu'
.*chronos: .*chronos:
mode: 'instruct'
instruction_template: 'Alpaca' instruction_template: 'Alpaca'
.*samantha: .*samantha:
mode: 'instruct'
instruction_template: 'Samantha' instruction_template: 'Samantha'
.*wizardcoder: .*wizardcoder:
mode: 'instruct'
instruction_template: 'Alpaca' instruction_template: 'Alpaca'
.*starchat-beta: .*starchat-beta:
mode: 'instruct'
instruction_template: 'Starchat-Beta' instruction_template: 'Starchat-Beta'
custom_stopping_strings: '"<|end|>"' custom_stopping_strings: '"<|end|>"'
.*minotaur: .*minotaur:
mode: 'instruct'
instruction_template: 'Minotaur' instruction_template: 'Minotaur'
.*minotaur-15b: .*minotaur-15b:
truncation_length: 8192 truncation_length: 8192
.*orca_mini: .*orca_mini:
mode: 'instruct'
instruction_template: 'Orca Mini' instruction_template: 'Orca Mini'
.*landmark: .*landmark:
truncation_length: 8192 truncation_length: 8192
@ -252,56 +194,42 @@ llama-65b-gptq-3bit:
truncation_length: 8192 truncation_length: 8192
instruction_template: 'Vicuna-v0' instruction_template: 'Vicuna-v0'
.*(platypus|gplatty|superplatty): .*(platypus|gplatty|superplatty):
mode: 'instruct'
instruction_template: 'Alpaca' instruction_template: 'Alpaca'
.*longchat: .*longchat:
mode: 'instruct'
instruction_template: 'Vicuna-v1.1' instruction_template: 'Vicuna-v1.1'
.*vicuna-33b: .*vicuna-33b:
mode: 'instruct'
instruction_template: 'Vicuna-v1.1' instruction_template: 'Vicuna-v1.1'
.*redmond-hermes-coder: .*redmond-hermes-coder:
mode: 'instruct'
instruction_template: 'Alpaca' instruction_template: 'Alpaca'
truncation_length: 8192 truncation_length: 8192
.*wizardcoder-15b: .*wizardcoder-15b:
mode: 'instruct'
instruction_template: 'Alpaca' instruction_template: 'Alpaca'
truncation_length: 8192 truncation_length: 8192
.*wizardlm: .*wizardlm:
mode: 'instruct'
instruction_template: 'Vicuna-v1.1' instruction_template: 'Vicuna-v1.1'
.*godzilla: .*godzilla:
mode: 'instruct'
instruction_template: 'Alpaca' instruction_template: 'Alpaca'
.*llama-(2|v2): .*llama-(2|v2):
truncation_length: 4096 truncation_length: 4096
rms_norm_eps: 5.0e-6 rms_norm_eps: 5.0e-6
.*llama-(2|v2).*chat: .*llama-(2|v2).*chat:
mode: 'instruct'
instruction_template: 'Llama-v2' instruction_template: 'Llama-v2'
.*70b.*ggml.*\.bin: .*70b.*ggml.*\.bin:
n_gqa: 8 n_gqa: 8
.*newhope: .*newhope:
mode: 'instruct'
instruction_template: 'NewHope' instruction_template: 'NewHope'
.*stablebeluga2: .*stablebeluga2:
mode: 'instruct'
instruction_template: 'StableBeluga2' instruction_template: 'StableBeluga2'
truncation_length: 4096 truncation_length: 4096
rms_norm_eps: 5.0e-6 rms_norm_eps: 5.0e-6
.*openchat: .*openchat:
mode: 'instruct'
instruction_template: 'OpenChat' instruction_template: 'OpenChat'
.*falcon.*-instruct: .*falcon.*-instruct:
mode: 'instruct'
.*(openorca-platypus2): .*(openorca-platypus2):
mode: 'instruct'
instruction_template: 'OpenOrca-Platypus2' instruction_template: 'OpenOrca-Platypus2'
custom_stopping_strings: '"### Instruction:", "### Response:"' custom_stopping_strings: '"### Instruction:", "### Response:"'
rms_norm_eps: 5.0e-6 rms_norm_eps: 5.0e-6
.*codellama: .*codellama:
rope_freq_base: 1000000 rope_freq_base: 1000000
.*codellama.*instruct: .*codellama.*instruct:
mode: 'instruct'
instruction_template: 'Llama-v2' instruction_template: 'Llama-v2'

View file

@ -15,6 +15,7 @@ from modules.LoRA import add_lora_to_model
from modules.models import load_model, unload_model from modules.models import load_model, unload_model
from modules.models_settings import ( from modules.models_settings import (
apply_model_settings_to_state, apply_model_settings_to_state,
get_model_settings_from_yamls,
save_model_settings, save_model_settings,
update_model_parameters update_model_parameters
) )
@ -181,23 +182,29 @@ def create_event_handlers():
def load_model_wrapper(selected_model, loader, autoload=False): def load_model_wrapper(selected_model, loader, autoload=False):
if not autoload: if not autoload:
yield f"The settings for {selected_model} have been updated.\nClick on \"Load\" to load it." yield f"The settings for `{selected_model}` have been updated.\n\nClick on \"Load\" to load it."
return return
if selected_model == 'None': if selected_model == 'None':
yield "No model selected" yield "No model selected"
else: else:
try: try:
yield f"Loading {selected_model}..." yield f"Loading `{selected_model}`..."
shared.model_name = selected_model shared.model_name = selected_model
unload_model() unload_model()
if selected_model != '': if selected_model != '':
shared.model, shared.tokenizer = load_model(shared.model_name, loader) shared.model, shared.tokenizer = load_model(shared.model_name, loader)
if shared.model is not None: if shared.model is not None:
yield f"Successfully loaded {selected_model}" output = f"Successfully loaded `{selected_model}`."
settings = get_model_settings_from_yamls(selected_model)
if 'instruction_template' in settings:
output += '\n\nIt seems to be an instruction-following model with template "{}". In the chat tab, instruct or chat-instruct modes should be used.'.format(settings['instruction_template'])
yield output
else: else:
yield f"Failed to load {selected_model}." yield f"Failed to load `{selected_model}`."
except: except:
exc = traceback.format_exc() exc = traceback.format_exc()
logger.error('Failed to load the model.') logger.error('Failed to load the model.')

View file

@ -174,7 +174,6 @@ if __name__ == "__main__":
'model_type': 'None', 'model_type': 'None',
'groupsize': 'None', 'groupsize': 'None',
'pre_layer': 0, 'pre_layer': 0,
'mode': shared.settings['mode'],
'skip_special_tokens': shared.settings['skip_special_tokens'], 'skip_special_tokens': shared.settings['skip_special_tokens'],
'custom_stopping_strings': shared.settings['custom_stopping_strings'], 'custom_stopping_strings': shared.settings['custom_stopping_strings'],
'truncation_length': shared.settings['truncation_length'], 'truncation_length': shared.settings['truncation_length'],