Update handler.py
Browse files- handler.py +5 -0
handler.py
CHANGED
@@ -2,6 +2,10 @@ import torch
|
|
2 |
from typing import Dict, List, Any
|
3 |
from transformers import AutoTokenizer, AutoModelForCausalLM, pipeline
|
4 |
|
|
|
|
|
|
|
|
|
5 |
format_input = (
|
6 |
"Below is an instruction that describes a task. "
|
7 |
"Write a response that appropriately completes the request.\n\n"
|
@@ -23,6 +27,7 @@ class EndpointHandler:
|
|
23 |
"text-generation",
|
24 |
model=model,
|
25 |
tokenizer=tokenizer,
|
|
|
26 |
max_length=256,
|
27 |
)
|
28 |
|
|
|
2 |
from typing import Dict, List, Any
|
3 |
from transformers import AutoTokenizer, AutoModelForCausalLM, pipeline
|
4 |
|
5 |
+
# check for GPU
|
6 |
+
device = 0 if torch.cuda.is_available() else -1
|
7 |
+
|
8 |
+
|
9 |
format_input = (
|
10 |
"Below is an instruction that describes a task. "
|
11 |
"Write a response that appropriately completes the request.\n\n"
|
|
|
27 |
"text-generation",
|
28 |
model=model,
|
29 |
tokenizer=tokenizer,
|
30 |
+
device=device,
|
31 |
max_length=256,
|
32 |
)
|
33 |
|