savasy commited on
Commit
753c37b
1 Parent(s): 142690b

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +2 -4
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[1].item()}
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