MCPcopy Create free account
hub / github.com/OpenBitSys/BitDistiller / build_model_and_enc

Function build_model_and_enc

quantization/clip_utils.py:174–190  ·  view source on GitHub ↗
(model_path)

Source from the content-addressed store, hash-verified

172
173
174def build_model_and_enc(model_path):
175 if not os.path.exists(model_path): # look into ssd
176 raise FileNotFoundError(f"{model_path} not found!")
177 print(f"* Building model {model_path}")
178
179 # all hf model
180 config = AutoConfig.from_pretrained(model_path, trust_remote_code=True)
181
182 enc = AutoTokenizer.from_pretrained(model_path, trust_remote_code=True)
183
184 kwargs = {"torch_dtype": torch.bfloat16, "low_cpu_mem_usage": True}
185 model = AutoModelForCausalLM.from_pretrained(
186 model_path, config=config, trust_remote_code=True, **kwargs)
187
188 model.eval()
189
190 return model, enc
191
192@torch.no_grad()
193def apply_clip(module, clip_results):

Callers 1

mainFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected