Christopher Glaze
commited on
Commit
·
9067c0f
1
Parent(s):
c5d744a
Fix model path
Browse files- handler.py +9 -6
handler.py
CHANGED
|
@@ -54,19 +54,22 @@ class SimcseGenerator(TransformerMixin):
|
|
| 54 |
return embeddings
|
| 55 |
|
| 56 |
class EndpointHandler():
|
| 57 |
-
def __init__(self):
|
| 58 |
|
| 59 |
-
|
|
|
|
|
|
|
|
|
|
| 60 |
|
| 61 |
-
with open(
|
| 62 |
self.stop_words = set(json.load(fp))
|
| 63 |
|
| 64 |
-
with open(
|
| 65 |
self.instruction_label_map = json.load(fp)
|
| 66 |
self.instruction_label_map = {int(k):v for k,v in self.instruction_label_map.items()}
|
| 67 |
|
| 68 |
-
self.instruction_pipeline = joblib.load(
|
| 69 |
-
self.response_pipeline = joblib.load(
|
| 70 |
|
| 71 |
self.simcse_generator = SimcseGenerator()
|
| 72 |
|
|
|
|
| 54 |
return embeddings
|
| 55 |
|
| 56 |
class EndpointHandler():
|
| 57 |
+
def __init__(self, path: str = ""):
|
| 58 |
|
| 59 |
+
if len(path)==0:
|
| 60 |
+
path = Path(__file__).parent
|
| 61 |
+
else:
|
| 62 |
+
path = Path(path)
|
| 63 |
|
| 64 |
+
with open(path/'stop_words.json','r') as fp:
|
| 65 |
self.stop_words = set(json.load(fp))
|
| 66 |
|
| 67 |
+
with open(path/'instruction_label_map.json','r') as fp:
|
| 68 |
self.instruction_label_map = json.load(fp)
|
| 69 |
self.instruction_label_map = {int(k):v for k,v in self.instruction_label_map.items()}
|
| 70 |
|
| 71 |
+
self.instruction_pipeline = joblib.load(path/'instruction_classification_pipeline.joblib')
|
| 72 |
+
self.response_pipeline = joblib.load(path/'response_quality_pipeline.joblib')
|
| 73 |
|
| 74 |
self.simcse_generator = SimcseGenerator()
|
| 75 |
|