Eraly-ml commited on
Commit
0619dcc
·
verified ·
1 Parent(s): 5e03908

Update inference.py

Browse files
Files changed (1) hide show
  1. inference.py +5 -2
inference.py CHANGED
@@ -39,9 +39,12 @@ class MilUnixCoder(nn.Module):
39
 
40
  def load_model():
41
  """Load the model and tokenizer"""
42
- tokenizer = AutoTokenizer.from_pretrained("YoungDSMLKZ/UnixCoder-MIL")
 
 
43
  model = MilUnixCoder("microsoft/unixcoder-base")
44
- model.load_state_dict(load_file("YoungDSMLKZ/UnixCoder-MIL/model.safetensors"))
 
45
  model.to(DEVICE).eval()
46
  return model, tokenizer
47
 
 
39
 
40
  def load_model():
41
  """Load the model and tokenizer"""
42
+ from huggingface_hub import hf_hub_download
43
+ repo = "YoungDSMLKZ/UnixCoder-MIL"
44
+ tokenizer = AutoTokenizer.from_pretrained(repo)
45
  model = MilUnixCoder("microsoft/unixcoder-base")
46
+ weights_path = hf_hub_download(repo_id=repo, filename="model.safetensors")
47
+ model.load_state_dict(load_file(weights_path))
48
  model.to(DEVICE).eval()
49
  return model, tokenizer
50