Spaces:
Sleeping
Sleeping
Commit
·
cf6ebf9
1
Parent(s):
70a482f
fix on tokenizer special tokens
Browse files
models/ta_models/bp_utils.py
CHANGED
@@ -24,7 +24,7 @@ def bp_predict_message(context, input):
|
|
24 |
truncation="only_first",
|
25 |
)['input_ids']
|
26 |
body_request = {
|
27 |
-
"inputs": [tokenizer.decode(encoding)],
|
28 |
"params": {
|
29 |
"top_k": None
|
30 |
}
|
@@ -32,11 +32,12 @@ def bp_predict_message(context, input):
|
|
32 |
|
33 |
try:
|
34 |
# Send request to Serving
|
|
|
35 |
response = requests.post(url=BP_URL, headers=HEADERS, json=body_request)
|
36 |
if response.status_code == 200:
|
37 |
response = response.json()['predictions'][0]
|
38 |
-
|
39 |
-
|
40 |
except:
|
41 |
pass
|
42 |
|
|
|
24 |
truncation="only_first",
|
25 |
)['input_ids']
|
26 |
body_request = {
|
27 |
+
"inputs": [tokenizer.decode(encoding)[1:-1]],
|
28 |
"params": {
|
29 |
"top_k": None
|
30 |
}
|
|
|
32 |
|
33 |
try:
|
34 |
# Send request to Serving
|
35 |
+
logger.debug(f"raw BP body is {body_request}")
|
36 |
response = requests.post(url=BP_URL, headers=HEADERS, json=body_request)
|
37 |
if response.status_code == 200:
|
38 |
response = response.json()['predictions'][0]
|
39 |
+
logger.debug(f"Raw BP prediction is {response}")
|
40 |
+
return [{k:v > BP_THRESHOLD if k=="score" else v for k,v in dict_.items()} for _, dict_ in response.items() ]
|
41 |
except:
|
42 |
pass
|
43 |
|
models/ta_models/cpc_utils.py
CHANGED
@@ -24,7 +24,7 @@ def cpc_predict_message(context, input):
|
|
24 |
truncation="only_first",
|
25 |
)['input_ids']
|
26 |
body_request = {
|
27 |
-
"inputs": [tokenizer.decode(encoding)]
|
28 |
}
|
29 |
|
30 |
try:
|
|
|
24 |
truncation="only_first",
|
25 |
)['input_ids']
|
26 |
body_request = {
|
27 |
+
"inputs": [tokenizer.decode(encoding)[1:-1]]
|
28 |
}
|
29 |
|
30 |
try:
|