SamanthaStorm commited on
Commit
04a0e54
·
verified ·
1 Parent(s): 2efdba9

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +25 -25
app.py CHANGED
@@ -6,7 +6,7 @@ from transformers import RobertaForSequenceClassification, RobertaTokenizer
6
 
7
  Load custom fine-tuned sentiment model
8
 
9
- sentiment_model = AutoModelForSequenceClassification.from_pretrained(SamanthaStorm/tether-sentiment”)
10
  sentiment_tokenizer = AutoTokenizer.from_pretrained(“SamanthaStorm/tether-sentiment”)
11
 
12
  Load abuse pattern model
@@ -16,39 +16,39 @@ model = RobertaForSequenceClassification.from_pretrained(model_name, trust_remot
16
  tokenizer = RobertaTokenizer.from_pretrained(model_name, trust_remote_code=True)
17
 
18
  LABELS = [
19
- gaslighting”, “mockery”, “dismissiveness”, “control”, “guilt_tripping”, “apology_baiting”, “blame_shifting”, “projection”,
20
- contradictory_statements”, “manipulation”, “deflection”, “insults”, “obscure_formal”, “recovery_phase”, “non_abusive”,
21
- suicidal_threat”, “physical_threat”, “extreme_control”
22
  ]
23
 
24
  THRESHOLDS = {
25
- gaslighting”: 0.25, “mockery”: 0.15, “dismissiveness”: 0.30, “control”: 0.43, “guilt_tripping”: 0.19,
26
- apology_baiting”: 0.45, “blame_shifting”: 0.23, “projection”: 0.50, “contradictory_statements”: 0.25,
27
- manipulation”: 0.25, “deflection”: 0.30, “insults”: 0.34, “obscure_formal”: 0.25, “recovery_phase”: 0.25,
28
- non_abusive”: 2.0, “suicidal_threat”: 0.45, “physical_threat”: 0.02, “extreme_control”: 0.36
29
  }
30
 
31
  PATTERN_LABELS = LABELS[:15]
32
  DANGER_LABELS = LABELS[15:18]
33
 
34
  EXPLANATIONS = {
35
- gaslighting”: “Gaslighting involves making someone question their own reality or perceptions…”,
36
- blame_shifting”: “Blame-shifting is when one person redirects the responsibility…”,
37
- projection”: “Projection involves accusing the victim of behaviors the abuser exhibits.”,
38
- dismissiveness”: “Dismissiveness is belittling or disregarding another person’s feelings.”,
39
- mockery”: “Mockery ridicules someone in a hurtful, humiliating way.”,
40
- recovery_phase”: “Recovery phase dismisses someone’s emotional healing process.”,
41
- insults”: “Insults are derogatory remarks aimed at degrading someone.”,
42
- apology_baiting”: “Apology-baiting manipulates victims into apologizing for abuser’s behavior.”,
43
- deflection”: “Deflection avoids accountability by redirecting blame.”,
44
- control”: “Control restricts autonomy through manipulation or coercion.”,
45
- extreme_control”: “Extreme control dominates decisions and behaviors entirely.”,
46
- physical_threat”: “Physical threats signal risk of bodily harm.”,
47
- suicidal_threat”: “Suicidal threats manipulate others using self-harm threats.”,
48
- guilt_tripping”: “Guilt-tripping uses guilt to manipulate someone’s actions.”,
49
- manipulation”: “Manipulation deceives to influence or control outcomes.”,
50
- non_abusive”: “Non-abusive language is respectful and free of coercion.”,
51
- obscure_formal”: “Obscure/formal language manipulates through confusion or superiority.”
52
  }
53
 
54
  def custom_sentiment(text):
 
6
 
7
  Load custom fine-tuned sentiment model
8
 
9
+ sentiment_model = AutoModelForSequenceClassification.from_pretrained("SamanthaStorm/tether-sentiment”)
10
  sentiment_tokenizer = AutoTokenizer.from_pretrained(“SamanthaStorm/tether-sentiment”)
11
 
12
  Load abuse pattern model
 
16
  tokenizer = RobertaTokenizer.from_pretrained(model_name, trust_remote_code=True)
17
 
18
  LABELS = [
19
+ "gaslighting”, “mockery”, “dismissiveness”, “control”, “guilt_tripping”, “apology_baiting”, “blame_shifting”, “projection”,
20
+ "contradictory_statements”, “manipulation”, “deflection”, “insults”, “obscure_formal”, “recovery_phase”, “non_abusive”,
21
+ "suicidal_threat”, “physical_threat”, “extreme_control”
22
  ]
23
 
24
  THRESHOLDS = {
25
+ "gaslighting”: 0.25, “mockery”: 0.15, “dismissiveness”: 0.30, “control”: 0.43, “guilt_tripping”: 0.19,
26
+ "apology_baiting”: 0.45, “blame_shifting”: 0.23, “projection”: 0.50, “contradictory_statements”: 0.25,
27
+ "manipulation”: 0.25, “deflection”: 0.30, “insults”: 0.34, “obscure_formal”: 0.25, “recovery_phase”: 0.25,
28
+ "non_abusive”: 2.0, “suicidal_threat”: 0.45, “physical_threat”: 0.02, “extreme_control”: 0.36
29
  }
30
 
31
  PATTERN_LABELS = LABELS[:15]
32
  DANGER_LABELS = LABELS[15:18]
33
 
34
  EXPLANATIONS = {
35
+ "gaslighting”: “Gaslighting involves making someone question their own reality or perceptions…”,
36
+ "blame_shifting”: “Blame-shifting is when one person redirects the responsibility…”,
37
+ "projection”: “Projection involves accusing the victim of behaviors the abuser exhibits.”,
38
+ "dismissiveness”: “Dismissiveness is belittling or disregarding another person’s feelings.”,
39
+ "mockery”: “Mockery ridicules someone in a hurtful, humiliating way.”,
40
+ "recovery_phase”: “Recovery phase dismisses someone’s emotional healing process.”,
41
+ "insults”: “Insults are derogatory remarks aimed at degrading someone.”,
42
+ "apology_baiting”: “Apology-baiting manipulates victims into apologizing for abuser’s behavior.”,
43
+ "deflection”: “Deflection avoids accountability by redirecting blame.”,
44
+ "control”: “Control restricts autonomy through manipulation or coercion.”,
45
+ "extreme_control”: “Extreme control dominates decisions and behaviors entirely.”,
46
+ "physical_threat”: “Physical threats signal risk of bodily harm.”,
47
+ "suicidal_threat”: “Suicidal threats manipulate others using self-harm threats.”,
48
+ "guilt_tripping”: “Guilt-tripping uses guilt to manipulate someone’s actions.”,
49
+ "manipulation”: “Manipulation deceives to influence or control outcomes.”,
50
+ "non_abusive”: “Non-abusive language is respectful and free of coercion.”,
51
+ "obscure_formal”: “Obscure/formal language manipulates through confusion or superiority.”
52
  }
53
 
54
  def custom_sentiment(text):