From ff453170329ad9f5414aa1e396130e82472f0b1b Mon Sep 17 00:00:00 2001 From: "Xiaojian \"JJ\" Deng" Date: Wed, 5 Jul 2023 20:40:43 -0400 Subject: [PATCH 1/3] Update models.py (#3020) Hopefully fixed error with "ValueError: Tokenizer class GPTNeoXTokenizer does not exist or is not currently imported." --- modules/models.py | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/modules/models.py b/modules/models.py index 160ca9e3..26a4880d 100644 --- a/modules/models.py +++ b/modules/models.py @@ -95,11 +95,18 @@ def load_tokenizer(model_name, model): if any(s in model_name.lower() for s in ['gpt-4chan', 'gpt4chan']) and Path(f"{shared.args.model_dir}/gpt-j-6B/").exists(): tokenizer = AutoTokenizer.from_pretrained(Path(f"{shared.args.model_dir}/gpt-j-6B/")) elif path_to_model.exists(): - tokenizer = AutoTokenizer.from_pretrained( - path_to_model, - trust_remote_code=shared.args.trust_remote_code, - use_fast=False - ) + try: + tokenizer = AutoTokenizer.from_pretrained( + path_to_model, + trust_remote_code=shared.args.trust_remote_code, + use_fast=False + ) + except ValueError: + tokenizer = AutoTokenizer.from_pretrained( + path_to_model, + trust_remote_code=shared.args.trust_remote_code, + use_fast=True + ) if tokenizer.__class__.__name__ == 'LlamaTokenizer': pairs = [ From 1f540fa4f8043f42b296280448cb51d2462466fb Mon Sep 17 00:00:00 2001 From: Fernando Tarin Morales Date: Fri, 7 Jul 2023 14:22:39 +0900 Subject: [PATCH 2/3] Added the format to be able to finetune Vicuna1.1 models (#3037) --- training/formats/vicuna-format.json | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 training/formats/vicuna-format.json diff --git a/training/formats/vicuna-format.json b/training/formats/vicuna-format.json new file mode 100644 index 00000000..c1aa4f15 --- /dev/null +++ b/training/formats/vicuna-format.json @@ -0,0 +1,3 @@ +{ + "instruction,output": "A chat between a curious user and an artificial intelligence assistant. The assistant gives helpful, detailed, and polite answers to the user's questions.\n\nUSER: %instruction%\n\nASSISTANT: %output%" +} From d7e14e1f78865ba6d702fa5b567ae48beeef9680 Mon Sep 17 00:00:00 2001 From: Fernando Tarin Morales Date: Fri, 7 Jul 2023 14:24:07 +0900 Subject: [PATCH 3/3] Fixed the param name when loading a LoRA using a model loaded in 4 or 8 bits (#3036) --- modules/LoRA.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/modules/LoRA.py b/modules/LoRA.py index e54d5337..0eb56b56 100644 --- a/modules/LoRA.py +++ b/modules/LoRA.py @@ -114,11 +114,12 @@ def add_lora_transformers(lora_names): if len(lora_names) > 0: params = {} if not shared.args.cpu: - params['dtype'] = shared.model.dtype - if hasattr(shared.model, "hf_device_map"): - params['device_map'] = {"base_model.model." + k: v for k, v in shared.model.hf_device_map.items()} - elif shared.args.load_in_8bit: - params['device_map'] = {'': 0} + if shared.args.load_in_4bit or shared.args.load_in_8bit: + params['peft_type'] = shared.model.dtype + else: + params['dtype'] = shared.model.dtype + if hasattr(shared.model, "hf_device_map"): + params['device_map'] = {"base_model.model." + k: v for k, v in shared.model.hf_device_map.items()} logger.info("Applying the following LoRAs to {}: {}".format(shared.model_name, ', '.join(lora_names))) shared.model = PeftModel.from_pretrained(shared.model, Path(f"{shared.args.lora_dir}/{lora_names[0]}"), adapter_name=lora_names[0], **params)