osanseviero
commited on
Commit
•
5d3c45e
1
Parent(s):
dd47aec
Create pipeline.py
Browse files- pipeline.py +24 -0
pipeline.py
ADDED
@@ -0,0 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from typing import Dict, List, Any
|
2 |
+
|
3 |
+
class PreTrainedPipeline():
|
4 |
+
def __init__(self, path=""):
|
5 |
+
# IMPLEMENT_THIS
|
6 |
+
# Preload all the elements you are going to need at inference.
|
7 |
+
# For instance your model, processors, tokenizer that might be needed.
|
8 |
+
# This function is only called once, so do all the heavy processing I/O here"""
|
9 |
+
raise NotImplementedError(
|
10 |
+
"Please implement PreTrainedPipeline __init__ function"
|
11 |
+
)
|
12 |
+
|
13 |
+
def __call__(self, inputs: str) -> List[float]:
|
14 |
+
"""
|
15 |
+
Args:
|
16 |
+
inputs (:obj:`str`):
|
17 |
+
a string to get the features from.
|
18 |
+
Return:
|
19 |
+
A :obj:`list` of floats: The features computed by the model.
|
20 |
+
"""
|
21 |
+
# IMPLEMENT_THIS
|
22 |
+
raise NotImplementedError(
|
23 |
+
"Please implement PreTrainedPipeline __call__ function"
|
24 |
+
)
|