osanseviero commited on
Commit
f30b48a
1 Parent(s): ec619b3

Create pipeline.py

Browse files
Files changed (1) hide show
  1. pipeline.py +27 -0
pipeline.py ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from typing import Dict
2
+ import numpy as np
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
+ raise NotImplementedError(
11
+ "Please implement PreTrainedPipeline __init__ function"
12
+ )
13
+
14
+ def __call__(self, inputs: str) -> List[List[Dict[str, float]]]:
15
+ """
16
+ Args:
17
+ inputs (:obj:`str`):
18
+ a string containing some text
19
+ Return:
20
+ A :obj:`list`:. The object returned should be a list of one list like [[{"label": 0.9939950108528137}]] containing :
21
+ - "label": A string representing what the label/class is. There can be multiple labels.
22
+ - "score": A score between 0 and 1 describing how confident the model is for this label/class.
23
+ """
24
+ # IMPLEMENT_THIS
25
+ raise NotImplementedError(
26
+ "Please implement PreTrainedPipeline __call__ function"
27
+ )