osanseviero
commited on
Commit
•
f10669a
1
Parent(s):
aa323e3
Rename to model.bin
Browse files- debate2vec.bin → model.bin +0 -0
- pipeline.py +0 -30
debate2vec.bin → model.bin
RENAMED
File without changes
|
pipeline.py
DELETED
@@ -1,30 +0,0 @@
|
|
1 |
-
from typing import Dict, List
|
2 |
-
|
3 |
-
import os
|
4 |
-
|
5 |
-
import fasttext.util
|
6 |
-
|
7 |
-
class PreTrainedPipeline():
|
8 |
-
|
9 |
-
def __init__(self, path=""):
|
10 |
-
"""
|
11 |
-
Initialize model
|
12 |
-
"""
|
13 |
-
|
14 |
-
self.model = fasttext.load_model(os.path.join(path, 'debate2vec.bin'))
|
15 |
-
|
16 |
-
def __call__(self, inputs: str) -> List[List[Dict[str, float]]]:
|
17 |
-
"""
|
18 |
-
Args:
|
19 |
-
inputs (:obj:`str`):
|
20 |
-
a string containing some text
|
21 |
-
Return:
|
22 |
-
A :obj:`list`:. The object returned should be a list of one list like [[{"label": 0.9939950108528137}]] containing :
|
23 |
-
- "label": A string representing what the label/class is. There can be multiple labels.
|
24 |
-
- "score": A score between 0 and 1 describing how confident the model is for this label/class.
|
25 |
-
"""
|
26 |
-
preds = self.model.get_nearest_neighbors("dog", k=10)
|
27 |
-
result = []
|
28 |
-
for distance, word in preds:
|
29 |
-
result.append({"label": word, "score": distance})
|
30 |
-
return [result]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|