Upload folder using huggingface_hub
Browse files- handler.py +12 -2
- inference.py +6 -0
- requirements.txt +4 -4
- temp_check/requirements.txt +4 -0
handler.py
CHANGED
|
@@ -1,14 +1,24 @@
|
|
| 1 |
from transformers import AutoTokenizer, AutoModelForSeq2SeqLM
|
| 2 |
import torch
|
|
|
|
| 3 |
|
| 4 |
class EndpointHandler:
|
| 5 |
def __init__(self, path=""):
|
| 6 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 7 |
self.model = AutoModelForSeq2SeqLM.from_pretrained(
|
| 8 |
path,
|
| 9 |
torch_dtype=torch.bfloat16,
|
| 10 |
-
trust_remote_code=True
|
|
|
|
| 11 |
)
|
|
|
|
| 12 |
|
| 13 |
def __call__(self, data):
|
| 14 |
inputs = data.pop("inputs", data)
|
|
|
|
| 1 |
from transformers import AutoTokenizer, AutoModelForSeq2SeqLM
|
| 2 |
import torch
|
| 3 |
+
import os
|
| 4 |
|
| 5 |
class EndpointHandler:
|
| 6 |
def __init__(self, path=""):
|
| 7 |
+
# Explicitly prevent sentence-transformers auto-detection
|
| 8 |
+
os.environ["TRANSFORMERS_OFFLINE"] = "1"
|
| 9 |
+
|
| 10 |
+
print(f"Loading T5Gemma model from: {path}")
|
| 11 |
+
self.tokenizer = AutoTokenizer.from_pretrained(
|
| 12 |
+
path,
|
| 13 |
+
trust_remote_code=True
|
| 14 |
+
)
|
| 15 |
self.model = AutoModelForSeq2SeqLM.from_pretrained(
|
| 16 |
path,
|
| 17 |
torch_dtype=torch.bfloat16,
|
| 18 |
+
trust_remote_code=True,
|
| 19 |
+
device_map="auto"
|
| 20 |
)
|
| 21 |
+
print("T5Gemma model loaded successfully")
|
| 22 |
|
| 23 |
def __call__(self, data):
|
| 24 |
inputs = data.pop("inputs", data)
|
inference.py
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# This file explicitly tells HF this is a custom text generation model
|
| 2 |
+
# and prevents auto-detection of sentence-transformers
|
| 3 |
+
|
| 4 |
+
TASK = "text-generation"
|
| 5 |
+
FRAMEWORK = "transformers"
|
| 6 |
+
MODEL_TYPE = "t5gemma"
|
requirements.txt
CHANGED
|
@@ -1,4 +1,4 @@
|
|
| 1 |
-
torch>=2.6.0
|
| 2 |
-
transformers==4.54.1
|
| 3 |
-
sentencepiece>=0.1.99
|
| 4 |
-
accelerate>=0.21.0
|
|
|
|
| 1 |
+
torch>=2.6.0
|
| 2 |
+
transformers==4.54.1
|
| 3 |
+
sentencepiece>=0.1.99
|
| 4 |
+
accelerate>=0.21.0
|
temp_check/requirements.txt
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
torch>=2.4.0
|
| 2 |
+
transformers==4.54.1
|
| 3 |
+
sentencepiece>=0.1.99
|
| 4 |
+
accelerate>=0.21.0
|