Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -7,14 +7,12 @@ from prompt import Prompting
|
|
7 |
prompting= Prompting(model=model_path)
|
8 |
prompt= ". Because it was "+ prompting.tokenizer.mask_token +"."
|
9 |
|
10 |
-
|
11 |
def predict(text):
|
12 |
THRESHOLD = prompting.compute_tokens_prob(prompt, token_list1=["good"], token_list2= ["bad"])[0].item()
|
13 |
res=prompting.compute_tokens_prob(text+prompt, token_list1=["good"], token_list2= ["bad"])
|
14 |
if res[0] > THRESHOLD:
|
15 |
-
return {"POSITIVE":res[0].item()-THRESHOLD}
|
16 |
-
return {"NEGATIVE":THRESHOLD-res[
|
17 |
-
|
18 |
|
19 |
|
20 |
import gradio as gr
|
|
|
7 |
prompting= Prompting(model=model_path)
|
8 |
prompt= ". Because it was "+ prompting.tokenizer.mask_token +"."
|
9 |
|
|
|
10 |
def predict(text):
|
11 |
THRESHOLD = prompting.compute_tokens_prob(prompt, token_list1=["good"], token_list2= ["bad"])[0].item()
|
12 |
res=prompting.compute_tokens_prob(text+prompt, token_list1=["good"], token_list2= ["bad"])
|
13 |
if res[0] > THRESHOLD:
|
14 |
+
return {"POSITIVE":(res[0].item()-THRESHOLD)/ (1-THRESHOLD)}
|
15 |
+
return {"NEGATIVE":(THRESHOLD-res[0].item())/THRESHOLD}
|
|
|
16 |
|
17 |
|
18 |
import gradio as gr
|