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