textsightai commited on
Commit
b347258
·
verified ·
1 Parent(s): debca03

Fix handler: load tokenizer from google-t5/t5-large to avoid local spiece.model path issue

Browse files
Files changed (1) hide show
  1. handler.py +4 -2
handler.py CHANGED
@@ -1,12 +1,14 @@
1
  """Custom handler for HuggingFace Inference Endpoints — TextSight T5 Humanizer"""
2
  from typing import Dict, Any
3
- from transformers import T5ForConditionalGeneration, T5Tokenizer
4
  import torch
5
 
6
 
7
  class EndpointHandler:
8
  def __init__(self, path: str = ""):
9
- self.tokenizer = T5Tokenizer.from_pretrained(path, legacy=True)
 
 
10
  self.model = T5ForConditionalGeneration.from_pretrained(
11
  path,
12
  torch_dtype=torch.float16 if torch.cuda.is_available() else torch.float32,
 
1
  """Custom handler for HuggingFace Inference Endpoints — TextSight T5 Humanizer"""
2
  from typing import Dict, Any
3
+ from transformers import T5ForConditionalGeneration, AutoTokenizer
4
  import torch
5
 
6
 
7
  class EndpointHandler:
8
  def __init__(self, path: str = ""):
9
+ # Load tokenizer from HF hub (avoids local spiece.model path issues)
10
+ self.tokenizer = AutoTokenizer.from_pretrained("google-t5/t5-large")
11
+ # Load model weights from the local repo path
12
  self.model = T5ForConditionalGeneration.from_pretrained(
13
  path,
14
  torch_dtype=torch.float16 if torch.cuda.is_available() else torch.float32,