From 826e297b0ec40299318f1002f9165e7ac9c9c257 Mon Sep 17 00:00:00 2001 From: rohvani <3782201+rohvani@users.noreply.github.com> Date: Thu, 9 Mar 2023 18:31:32 -0800 Subject: [PATCH 1/4] add llama-65b-4bit support & multiple pt paths --- modules/models.py | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/modules/models.py b/modules/models.py index 3e6cea18..062ccb1f 100644 --- a/modules/models.py +++ b/modules/models.py @@ -97,19 +97,27 @@ def load_model(model_name): pt_model = '' if path_to_model.name.lower().startswith('llama-7b'): pt_model = 'llama-7b-4bit.pt' - if path_to_model.name.lower().startswith('llama-13b'): + elif path_to_model.name.lower().startswith('llama-13b'): pt_model = 'llama-13b-4bit.pt' - if path_to_model.name.lower().startswith('llama-30b'): + elif path_to_model.name.lower().startswith('llama-30b'): pt_model = 'llama-30b-4bit.pt' - - if not Path(f"models/{pt_model}").exists(): - print(f"Could not find models/{pt_model}, exiting...") - exit() - elif pt_model == '': + elif path_to_model.name.lower().startswith('llama-65b'): + pt_model = 'llama-65b-4bit.pt' + else: print(f"Could not find the .pt model for {model_name}, exiting...") exit() - model = load_quant(path_to_model, Path(f"models/{pt_model}"), 4) + # check root of models folder, and model path root + paths = [ f"{path_to_model}/{pt_model}", f"models/{pt_model}" ] + for path in [ Path(p) for p in paths ]: + if path.exists(): + pt_path = path + + if not pt_path: + print(f"Could not find {pt_model}, exiting...") + exit() + + model = load_quant(path_to_model, pt_path, 4) model = model.to(torch.device('cuda:0')) # Custom From 5ee376c580e8c2cf2e3b34e1822c43e6754b2649 Mon Sep 17 00:00:00 2001 From: rohvani <3782201+rohvani@users.noreply.github.com> Date: Thu, 9 Mar 2023 18:31:41 -0800 Subject: [PATCH 2/4] add LLaMA preset --- presets/LLaMA-Default.txt | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 presets/LLaMA-Default.txt diff --git a/presets/LLaMA-Default.txt b/presets/LLaMA-Default.txt new file mode 100644 index 00000000..3df8209a --- /dev/null +++ b/presets/LLaMA-Default.txt @@ -0,0 +1,12 @@ +do_sample=False +temperature=0.7 +top_p=0 +typical_p=1 +repetition_penalty=1.15 +top_k=40 +num_beams=1 +penalty_alpha=0 +min_length=0 +length_penalty=1 +no_repeat_ngram_size=0 +early_stopping=True From 2ac29137470396733e95e7efa77e091d5e8a5ef5 Mon Sep 17 00:00:00 2001 From: rohvani <3782201+rohvani@users.noreply.github.com> Date: Thu, 9 Mar 2023 20:13:23 -0800 Subject: [PATCH 3/4] fix reference issue --- modules/models.py | 1 + 1 file changed, 1 insertion(+) diff --git a/modules/models.py b/modules/models.py index 062ccb1f..a2256b98 100644 --- a/modules/models.py +++ b/modules/models.py @@ -109,6 +109,7 @@ def load_model(model_name): # check root of models folder, and model path root paths = [ f"{path_to_model}/{pt_model}", f"models/{pt_model}" ] + pt_path = None for path in [ Path(p) for p in paths ]: if path.exists(): pt_path = path From 706a03b2cb5bf3c0667d8c13b3a47f1a6e33cc81 Mon Sep 17 00:00:00 2001 From: oobabooga <112222186+oobabooga@users.noreply.github.com> Date: Fri, 10 Mar 2023 11:02:25 -0300 Subject: [PATCH 4/4] Minor changes --- modules/models.py | 8 +++----- presets/LLaMA-Default.txt | 12 ------------ 2 files changed, 3 insertions(+), 17 deletions(-) delete mode 100644 presets/LLaMA-Default.txt diff --git a/modules/models.py b/modules/models.py index a2256b98..a23f1fa9 100644 --- a/modules/models.py +++ b/modules/models.py @@ -104,13 +104,11 @@ def load_model(model_name): elif path_to_model.name.lower().startswith('llama-65b'): pt_model = 'llama-65b-4bit.pt' else: - print(f"Could not find the .pt model for {model_name}, exiting...") - exit() + pt_model = f'{model_name}-4bit.pt' - # check root of models folder, and model path root - paths = [ f"{path_to_model}/{pt_model}", f"models/{pt_model}" ] + # Try to find the .pt both in models/ and in the subfolder pt_path = None - for path in [ Path(p) for p in paths ]: + for path in [Path(p) for p in [f"models/{pt_model}", f"{path_to_model}/{pt_model}"]]: if path.exists(): pt_path = path diff --git a/presets/LLaMA-Default.txt b/presets/LLaMA-Default.txt deleted file mode 100644 index 3df8209a..00000000 --- a/presets/LLaMA-Default.txt +++ /dev/null @@ -1,12 +0,0 @@ -do_sample=False -temperature=0.7 -top_p=0 -typical_p=1 -repetition_penalty=1.15 -top_k=40 -num_beams=1 -penalty_alpha=0 -min_length=0 -length_penalty=1 -no_repeat_ngram_size=0 -early_stopping=True