HowWebWorks commited on
Commit ·
ed658dd
1
Parent(s): 5777436
point handler to model
Browse files123456789101112131415161718from typing import Dictimport torchfrom transformers import AutoTokenizer, AutoModelForCausalLMclass EndpointHandler:"""Custom handler for NuExtract-2-8B (InternLM2 based)."""def __init__(self, path: str = "") -> None:# ↓↓↓ allow the repo’s custom configuration & modelling codeself.tokenizer = AutoTokenizer.from_pretrained(path,trust_remote_code=True # ← mandatory)self.model = AutoModelForCausalLM.from_pretrained(path,trust_remote_code=True, # ← mandatorytorch_dtype=torch.float16, # fits on a 16 GB GPUdevice_map="auto" # put tensors on the GPU1234567891011121314151617181920from typing import Dictimport torchfrom transformers import AutoTokenizer, AutoModelForCausalLMimport osclass EndpointHandler:"""Custom handler for NuExtract-2-8B (InternLM2 based)."""def __init__(self, path: str = "") -> None:model_path = os.path.join(path, "model")# ↓↓↓ allow the repo’s custom configuration & modelling codeself.tokenizer = AutoTokenizer.from_pretrained(model_path,trust_remote_code=True # ← mandatory)self.model = AutoModelForCausalLM.from_pretrained(model_path,trust_remote_code=True, # ← mandatorytorch_dtype=torch.float16, # fits on a 16 GB GPUdevice_map="auto" # put tensors on the GPU
handler.py+4-2