Files
wehub-resource-sync a65ab1ac53
Deploy to GitHub Pages / deploy (push) Has been cancelled
Deploy to GitHub Pages / build (push) Has been cancelled
chore: import upstream snapshot with attribution
2026-07-13 13:31:56 +08:00

15 lines
748 B
Python

from transformers import AutoModelForCausalLM, AutoTokenizer
from transformers.generation import GenerationConfig
class HFModel(object):
def __init__(self, model_path):
self.tokenizer = AutoTokenizer.from_pretrained(model_path, trust_remote_code=True)
self.model = AutoModelForCausalLM.from_pretrained(model_path,
trust_remote_code=True,
device_map='auto',
low_cpu_mem_usage=True).eval()
self.model.generation_config = GenerationConfig.from_pretrained(model_path, trust_remote_code=True)
self.model.generation_config.do_sample = False