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

Function load

light-eval/src/eval_mmlu.py:82–107  ·  view source on GitHub ↗
(args)

Source from the content-addressed store, hash-verified

80
81# load model and tokenizer
82def load(args):
83
84 # define the model
85 misc.init_distributed_mode(args)
86 fs_init.initialize_model_parallel(args.model_parallel_size)
87 model = MetaModel(args.llama_type, args.llama_config, args.tokenizer_path, with_visual=True)
88 print(f"load pretrained from {args.pretrained_path}")
89 load_tensor_parallel_model_list(model, args.pretrained_path)
90
91 if args.quant:
92 print("Quantizing model to 4bit!")
93
94 from transformers.utils.quantization_config import BitsAndBytesConfig
95 quantization_config = BitsAndBytesConfig.from_dict(
96 config_dict={
97 "load_in_8bit": False,
98 "load_in_4bit": True,
99 "bnb_4bit_quant_type": "nf4",
100 },
101 return_unused_kwargs=False,
102 )
103 quantize(model, quantization_config)
104
105 #print("Model = %s" % str(model))
106 model.bfloat16().cuda()
107 return model
108
109def extract_ans(ans):
110 ans = ans.strip()

Callers 1

mainFunction · 0.70

Calls 4

MetaModelClass · 0.90
quantizeFunction · 0.90
printFunction · 0.85

Tested by

no test coverage detected