xiaopeiwu commited on
Commit
1474903
·
1 Parent(s): bf21cdb

update flagging options

Browse files
Files changed (1) hide show
  1. app.py +5 -2
app.py CHANGED
@@ -16,6 +16,9 @@ clf = pipeline("text-classification", model=model.to("cpu"), tokenizer=tokenizer
16
 
17
  def clf_result(text_input: str) -> str:
18
 
 
 
 
19
  model_res = clf(text_input)[0]
20
  label_map = {"LABEL_0": "NOT RISKY", "LABEL_1": "RISKY"}
21
  label_res = label_map.get(model_res["label"])
@@ -29,10 +32,10 @@ demo = gr.Interface(
29
  title="Test High Risk Words model v2",
30
  examples=["All the best lenders and rates for car loans in one AI powered marketplace", "Caregiver burnout can happen to your best employees."],
31
  description="DistilBert for text classification model fine tuned on 70% of annotated RM production data combined with industry-specific webscrape data",
32
- inputs=gr.Textbox(placeholder="Enter sentence here and press Submit", label="Sentence to check"),
33
  outputs="textbox",
34
  allow_flagging="manual",
35
- flagging_options=["wrong result", "inconsistent result", "debatable input", "other"],
36
  flagging_callback=hf_writer,
37
  )
38
 
 
16
 
17
  def clf_result(text_input: str) -> str:
18
 
19
+ if "best" not in text_input.lower():
20
+ res = "Please enter a sentence with the word `best`"
21
+ return res
22
  model_res = clf(text_input)[0]
23
  label_map = {"LABEL_0": "NOT RISKY", "LABEL_1": "RISKY"}
24
  label_res = label_map.get(model_res["label"])
 
32
  title="Test High Risk Words model v2",
33
  examples=["All the best lenders and rates for car loans in one AI powered marketplace", "Caregiver burnout can happen to your best employees."],
34
  description="DistilBert for text classification model fine tuned on 70% of annotated RM production data combined with industry-specific webscrape data",
35
+ inputs=gr.Textbox(placeholder="Enter sentence containing the word `best` here and press Submit", label="Sentence to check"),
36
  outputs="textbox",
37
  allow_flagging="manual",
38
+ flagging_options=["wrong result :(", "correct result :)", "inconsistent result", "debatable input", "other"],
39
  flagging_callback=hf_writer,
40
  )
41