mirror of
https://github.com/nomic-ai/gpt4all.git
synced 2024-10-01 01:06:10 -04:00
fix: add tokens
This commit is contained in:
parent
eac7734cbf
commit
d87af69a93
@ -19,7 +19,10 @@ def generate(tokenizer, prompt, model, config):
|
|||||||
def setup_model(config):
|
def setup_model(config):
|
||||||
model = AutoModelForCausalLM.from_pretrained(config["model_name"], device_map="auto", torch_dtype=torch.float16)
|
model = AutoModelForCausalLM.from_pretrained(config["model_name"], device_map="auto", torch_dtype=torch.float16)
|
||||||
tokenizer = AutoTokenizer.from_pretrained(config["tokenizer_name"])
|
tokenizer = AutoTokenizer.from_pretrained(config["tokenizer_name"])
|
||||||
tokenizer.add_special_tokens({"bos_token": "<s>", "eos_token": "</s>"})
|
added_tokens = tokenizer.add_special_tokens({"bos_token": "<s>", "eos_token": "</s>", "pad_token": "<pad>"})
|
||||||
|
|
||||||
|
if added_tokens > 0:
|
||||||
|
model.resize_token_embeddings(len(tokenizer))
|
||||||
|
|
||||||
if config["lora"]:
|
if config["lora"]:
|
||||||
model = PeftModelForCausalLM.from_pretrained(model, config["lora_path"], device_map="auto", torch_dtype=torch.float16)
|
model = PeftModelForCausalLM.from_pretrained(model, config["lora_path"], device_map="auto", torch_dtype=torch.float16)
|
||||||
|
Loading…
Reference in New Issue
Block a user