MCPcopy Create free account
hub / github.com/boyiwei/alignment-attribution-code / get_llm

Function get_llm

lib/model_wrapper.py:534–544  ·  view source on GitHub ↗
(model_name, cache_dir="llm_weights")

Source from the content-addressed store, hash-verified

532 }
533
534 def get_llm(model_name, cache_dir="llm_weights"):
535 model = AutoModelForCausalLM.from_pretrained(
536 modeltype2path[model_name],
537 torch_dtype=torch.bfloat16,
538 cache_dir=cache_dir,
539 low_cpu_mem_usage=True,
540 device_map="cuda",
541 )
542
543 model.seqlen = model.config.max_position_embeddings
544 return model
545
546 tokenizer = AutoTokenizer.from_pretrained(modeltype2path["llama2-7b-hf"])
547 inputs = tokenizer(

Callers 1

model_wrapper.pyFile · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected