MCPcopy Create free account
hub / github.com/Alpha-VLLM/LLaMA2-Accessory / load

Function load

light-eval/src/eval_ceval.py:59–84  ·  view source on GitHub ↗
(args)

Source from the content-addressed store, hash-verified

57
58# load model and tokenizer
59def load(args):
60
61 # define the model
62 misc.init_distributed_mode(args)
63 fs_init.initialize_model_parallel(args.model_parallel_size)
64 model = MetaModel(args.llama_type, args.llama_config, args.tokenizer_path, with_visual=True)
65 print(f"load pretrained from {args.pretrained_path}")
66 load_tensor_parallel_model_list(model, args.pretrained_path)
67
68 if args.quant:
69 print("Quantizing model to 4bit!")
70
71 from transformers.utils.quantization_config import BitsAndBytesConfig
72 quantization_config = BitsAndBytesConfig.from_dict(
73 config_dict={
74 "load_in_8bit": False,
75 "load_in_4bit": True,
76 "bnb_4bit_quant_type": "nf4",
77 },
78 return_unused_kwargs=False,
79 )
80 quantize(model, quantization_config)
81
82 #print("Model = %s" % str(model))
83 model.bfloat16().cuda()
84 return model
85
86def format_example(line, include_answer=True):
87 example = line['question']

Callers 1

mainFunction · 0.70

Calls 4

MetaModelClass · 0.90
quantizeFunction · 0.90
printFunction · 0.85

Tested by

no test coverage detected