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

Function load

light-eval/src/eval_cmmlu.py:65–90  ·  view source on GitHub ↗
(args)

Source from the content-addressed store, hash-verified

63
64# load model and tokenizer
65def load(args):
66
67 # define the model
68 misc.init_distributed_mode(args)
69 fs_init.initialize_model_parallel(args.model_parallel_size)
70 model = MetaModel(args.llama_type, args.llama_config, args.tokenizer_path, with_visual=True)
71 print(f"load pretrained from {args.pretrained_path}")
72 load_tensor_parallel_model_list(model, args.pretrained_path)
73
74 if args.quant:
75 print("Quantizing model to 4bit!")
76
77 from transformers.utils.quantization_config import BitsAndBytesConfig
78 quantization_config = BitsAndBytesConfig.from_dict(
79 config_dict={
80 "load_in_8bit": False,
81 "load_in_4bit": True,
82 "bnb_4bit_quant_type": "nf4",
83 },
84 return_unused_kwargs=False,
85 )
86 quantize(model, quantization_config)
87
88 #print("Model = %s" % str(model))
89 model.bfloat16().cuda()
90 return model
91
92def format_example(line, include_answer=True):
93 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