Spaces:
Running
Running
Commit
·
bf69cf6
1
Parent(s):
af940c9
worse prompts = better results
Browse files- model/analyzer.py +18 -34
model/analyzer.py
CHANGED
@@ -28,84 +28,68 @@ class ContentAnalyzer:
|
|
28 |
"mapped_name": "Violence",
|
29 |
"description": (
|
30 |
"Any act involving physical force or aggression intended to cause harm, injury, or death to a person, animal, or object. "
|
31 |
-
"Includes direct physical confrontations
|
32 |
-
"or large-scale events like wars, riots, or violent protests."
|
33 |
)
|
34 |
},
|
35 |
"Death": {
|
36 |
"mapped_name": "Death References",
|
37 |
"description": (
|
38 |
-
|
39 |
-
"or abstract references to mortality
|
40 |
-
"grieving, or any dialogue that centers around death, do not take metaphors into context that don't actually lead to death."
|
41 |
)
|
42 |
},
|
43 |
"Substance Use": {
|
44 |
"mapped_name": "Substance Use",
|
45 |
"description": (
|
46 |
"Any explicit or implied reference to the consumption, misuse, or abuse of drugs, alcohol, or other intoxicating substances. "
|
47 |
-
"Includes scenes of drinking, smoking,
|
48 |
-
"rehabilitation, or substance-related paraphernalia (e.g., needles, bottles, pipes)."
|
49 |
)
|
50 |
},
|
51 |
"Gore": {
|
52 |
"mapped_name": "Gore",
|
53 |
"description": (
|
54 |
-
"Extremely detailed and graphic depictions of
|
55 |
-
"
|
56 |
)
|
57 |
},
|
58 |
"Vomit": {
|
59 |
"mapped_name": "Vomit",
|
60 |
-
"description":
|
61 |
-
|
62 |
-
"mentions of nausea leading to vomiting, or its aftermath (e.g., the presence of vomit, cleaning it up, or characters reacting to it)."
|
63 |
-
)
|
64 |
-
},
|
65 |
"Sexual Content": {
|
66 |
"mapped_name": "Sexual Content",
|
67 |
"description": (
|
68 |
-
"Any depiction or mention of sexual activity, intimacy, or sexual behavior,
|
69 |
-
"This includes romantic encounters, physical descriptions of characters in a sexual context, sexual dialogue, or references to sexual themes (e.g., harassment, innuendos)."
|
70 |
)
|
71 |
},
|
72 |
"Sexual Abuse": {
|
73 |
"mapped_name": "Sexual Abuse",
|
74 |
"description": (
|
75 |
-
"Any form of non-consensual sexual act, behavior, or interaction, involving coercion, manipulation, or physical force.
|
76 |
-
"This includes incidents of sexual assault, molestation, exploitation, harassment, and any acts where an individual is subjected to sexual acts against their will or without their consent. "
|
77 |
-
"It also covers discussions or depictions of the aftermath of such abuse, such as trauma, emotional distress, legal proceedings, or therapy. "
|
78 |
-
"References to inappropriate sexual advances, groping, or any other form of sexual misconduct are also included, as well as the psychological and emotional impact on survivors. "
|
79 |
-
"Scenes where individuals are placed in sexually compromising situations, even if not directly acted upon, may also fall under this category."
|
80 |
)
|
81 |
},
|
82 |
"Self-Harm": {
|
83 |
"mapped_name": "Self-Harm",
|
84 |
"description": (
|
85 |
-
|
86 |
-
"as well as suicidal ideation, suicide attempts, or discussions of self-destructive thoughts and actions. References to scars, bruises, or other lasting signs of self-harm are also included."
|
87 |
)
|
88 |
},
|
89 |
"Gun Use": {
|
90 |
"mapped_name": "Gun Use",
|
91 |
"description": (
|
92 |
-
"Any explicit or implied mention of firearms being handled, fired, or used in a threatening manner.
|
93 |
-
"gun-related accidents, or the presence of firearms in a tense or dangerous context (e.g., holstered weapons during an argument)."
|
94 |
)
|
95 |
},
|
96 |
"Animal Cruelty": {
|
97 |
"mapped_name": "Animal Cruelty",
|
98 |
"description": (
|
99 |
-
"Any act of harm, abuse, or neglect toward animals, whether intentional or accidental.
|
100 |
-
"mental or emotional mistreatment (e.g., starvation, isolation), and scenes where animals are subjected to pain or suffering for human entertainment or experimentation."
|
101 |
)
|
102 |
},
|
103 |
"Mental Health Issues": {
|
104 |
"mapped_name": "Mental Health Issues",
|
105 |
"description": (
|
106 |
-
"Any reference to mental health struggles, disorders, or psychological distress
|
107 |
-
"or other conditions. Scenes depicting therapy sessions, psychiatric treatment, or coping mechanisms (e.g., medication, journaling) are also included. May cover subtle hints "
|
108 |
-
"like a character expressing feelings of worthlessness, hopelessness, or detachment from reality."
|
109 |
)
|
110 |
}
|
111 |
}
|
@@ -172,10 +156,10 @@ class ContentAnalyzer:
|
|
172 |
with torch.no_grad():
|
173 |
outputs = self.model.generate(
|
174 |
**inputs,
|
175 |
-
max_new_tokens=
|
176 |
do_sample=True,
|
177 |
-
temperature=0.
|
178 |
-
top_p=0.
|
179 |
pad_token_id=self.tokenizer.eos_token_id
|
180 |
)
|
181 |
|
@@ -185,7 +169,7 @@ class ContentAnalyzer:
|
|
185 |
if first_word == "YES":
|
186 |
chunk_triggers[mapped_name] = chunk_triggers.get(mapped_name, 0) + 1
|
187 |
elif first_word == "MAYBE":
|
188 |
-
chunk_triggers[mapped_name] = chunk_triggers.get(mapped_name, 0) + 0.
|
189 |
|
190 |
if progress:
|
191 |
current_progress += progress_step
|
|
|
28 |
"mapped_name": "Violence",
|
29 |
"description": (
|
30 |
"Any act involving physical force or aggression intended to cause harm, injury, or death to a person, animal, or object. "
|
31 |
+
"Includes direct physical confrontations, implied violence, or large-scale events like wars, riots, or violent protests."
|
|
|
32 |
)
|
33 |
},
|
34 |
"Death": {
|
35 |
"mapped_name": "Death References",
|
36 |
"description": (
|
37 |
+
"Any mention, implication, or depiction of the loss of life, including direct deaths of characters, mentions of deceased individuals, "
|
38 |
+
"or abstract references to mortality. This covers depictions of funerals, mourning, or death-centered dialogue."
|
|
|
39 |
)
|
40 |
},
|
41 |
"Substance Use": {
|
42 |
"mapped_name": "Substance Use",
|
43 |
"description": (
|
44 |
"Any explicit or implied reference to the consumption, misuse, or abuse of drugs, alcohol, or other intoxicating substances. "
|
45 |
+
"Includes scenes of drinking, smoking, drug use, withdrawal symptoms, or rehabilitation."
|
|
|
46 |
)
|
47 |
},
|
48 |
"Gore": {
|
49 |
"mapped_name": "Gore",
|
50 |
"description": (
|
51 |
+
"Extremely detailed and graphic depictions of severe physical injuries, mutilation, or extreme bodily harm, including heavy blood, "
|
52 |
+
"exposed organs, or dismemberment."
|
53 |
)
|
54 |
},
|
55 |
"Vomit": {
|
56 |
"mapped_name": "Vomit",
|
57 |
+
"description": "Any reference to the act of vomiting, whether directly described, implied, or depicted in detail."
|
58 |
+
},
|
|
|
|
|
|
|
59 |
"Sexual Content": {
|
60 |
"mapped_name": "Sexual Content",
|
61 |
"description": (
|
62 |
+
"Any depiction or mention of sexual activity, intimacy, or sexual behavior, from implied scenes to explicit descriptions."
|
|
|
63 |
)
|
64 |
},
|
65 |
"Sexual Abuse": {
|
66 |
"mapped_name": "Sexual Abuse",
|
67 |
"description": (
|
68 |
+
"Any form of non-consensual sexual act, behavior, or interaction, involving coercion, manipulation, or physical force."
|
|
|
|
|
|
|
|
|
69 |
)
|
70 |
},
|
71 |
"Self-Harm": {
|
72 |
"mapped_name": "Self-Harm",
|
73 |
"description": (
|
74 |
+
"Any mention or depiction of behaviors where an individual intentionally causes harm to themselves, including suicidal thoughts."
|
|
|
75 |
)
|
76 |
},
|
77 |
"Gun Use": {
|
78 |
"mapped_name": "Gun Use",
|
79 |
"description": (
|
80 |
+
"Any explicit or implied mention of firearms being handled, fired, or used in a threatening manner."
|
|
|
81 |
)
|
82 |
},
|
83 |
"Animal Cruelty": {
|
84 |
"mapped_name": "Animal Cruelty",
|
85 |
"description": (
|
86 |
+
"Any act of harm, abuse, or neglect toward animals, whether intentional or accidental."
|
|
|
87 |
)
|
88 |
},
|
89 |
"Mental Health Issues": {
|
90 |
"mapped_name": "Mental Health Issues",
|
91 |
"description": (
|
92 |
+
"Any reference to mental health struggles, disorders, or psychological distress, including therapy and treatment."
|
|
|
|
|
93 |
)
|
94 |
}
|
95 |
}
|
|
|
156 |
with torch.no_grad():
|
157 |
outputs = self.model.generate(
|
158 |
**inputs,
|
159 |
+
max_new_tokens=3,
|
160 |
do_sample=True,
|
161 |
+
temperature=0.7,
|
162 |
+
top_p=0.8,
|
163 |
pad_token_id=self.tokenizer.eos_token_id
|
164 |
)
|
165 |
|
|
|
169 |
if first_word == "YES":
|
170 |
chunk_triggers[mapped_name] = chunk_triggers.get(mapped_name, 0) + 1
|
171 |
elif first_word == "MAYBE":
|
172 |
+
chunk_triggers[mapped_name] = chunk_triggers.get(mapped_name, 0) + 0.5
|
173 |
|
174 |
if progress:
|
175 |
current_progress += progress_step
|