Commit
·
73697bb
1
Parent(s):
351fc66
use static path oleksandrfluxon/mpt-7b-chat-4bit in custom handler
Browse files- pipeline.py +6 -1
pipeline.py
CHANGED
@@ -3,11 +3,13 @@ import transformers
|
|
3 |
from typing import Dict, List, Any
|
4 |
|
5 |
class PreTrainedPipeline():
|
6 |
-
def __init__(self, path="
|
|
|
7 |
print("===> path", path)
|
8 |
config = transformers.AutoConfig.from_pretrained(path, trust_remote_code=True)
|
9 |
config.max_seq_len = 4096 # (input + output) tokens can now be up to 4096
|
10 |
|
|
|
11 |
model = transformers.AutoModelForCausalLM.from_pretrained(
|
12 |
path,
|
13 |
config=config,
|
@@ -15,10 +17,12 @@ class PreTrainedPipeline():
|
|
15 |
trust_remote_code=True,
|
16 |
load_in_4bit=True, # Load model in the lowest 4-bit precision quantization
|
17 |
)
|
|
|
18 |
|
19 |
tokenizer = transformers.AutoTokenizer.from_pretrained('EleutherAI/gpt-neox-20b', padding_side="left", device_map="auto")
|
20 |
|
21 |
self.pipeline = transformers.pipeline('text-generation', model=model, tokenizer=tokenizer)
|
|
|
22 |
|
23 |
def __call__(self, data: Dict[str, Any]) -> List[Dict[str, Any]]:
|
24 |
"""
|
@@ -36,5 +40,6 @@ class PreTrainedPipeline():
|
|
36 |
print("===> inputs", parameters)
|
37 |
|
38 |
result = self.pipeline(inputs, **parameters)
|
|
|
39 |
|
40 |
return result
|
|
|
3 |
from typing import Dict, List, Any
|
4 |
|
5 |
class PreTrainedPipeline():
|
6 |
+
def __init__(self, path=""):
|
7 |
+
path = "oleksandrfluxon/mpt-7b-chat-4bit"
|
8 |
print("===> path", path)
|
9 |
config = transformers.AutoConfig.from_pretrained(path, trust_remote_code=True)
|
10 |
config.max_seq_len = 4096 # (input + output) tokens can now be up to 4096
|
11 |
|
12 |
+
print("===> loading model")
|
13 |
model = transformers.AutoModelForCausalLM.from_pretrained(
|
14 |
path,
|
15 |
config=config,
|
|
|
17 |
trust_remote_code=True,
|
18 |
load_in_4bit=True, # Load model in the lowest 4-bit precision quantization
|
19 |
)
|
20 |
+
print("===> model loaded")
|
21 |
|
22 |
tokenizer = transformers.AutoTokenizer.from_pretrained('EleutherAI/gpt-neox-20b', padding_side="left", device_map="auto")
|
23 |
|
24 |
self.pipeline = transformers.pipeline('text-generation', model=model, tokenizer=tokenizer)
|
25 |
+
print("===> init finished")
|
26 |
|
27 |
def __call__(self, data: Dict[str, Any]) -> List[Dict[str, Any]]:
|
28 |
"""
|
|
|
40 |
print("===> inputs", parameters)
|
41 |
|
42 |
result = self.pipeline(inputs, **parameters)
|
43 |
+
print("===> result", result)
|
44 |
|
45 |
return result
|