ifmain commited on
Commit
5f6055b
·
verified ·
1 Parent(s): dc7c4c3

Use neural scores only; remove language selector, word lists and model-repo code

Browse files
README.md CHANGED
@@ -39,7 +39,7 @@ Supports 17 languages: en, de, fr, es, it, sv, fi, pl, cs, lv, zh, ja, ko, ru, u
39
  The raw sigmoid scores are **not calibrated probabilities**. They remain unchanged when selecting a preset.
40
  Categories: `harassment`, `harassment_threatening`, `hate`, `hate_threatening`, `self_harm`, `self_harm_instructions`, `self_harm_intent`, `sexual`, `sexual_minors`, `violence`, `violence_graphic`.
41
 
42
- Raw scores are always displayed. Select a preset (`light`, `medium`, `high`, `corporate`) to populate editable per-category thresholds; every edit immediately affects filtering. There is no mode selector. A `null` threshold disables a category. Enabled categories trigger when `score >= threshold`; any trigger blocks the text. High and corporate presets also apply a finite multilingual profanity lexicon. Custom thresholds can change each category independently and optionally enable that lexicon. Changing presets or thresholds reuses session-local scores without running the model again. Editing the text clears the previous result. The Python API still supports raw-only output with `preset=None`.
43
 
44
  Corporate is the strictest **content-threshold** preset. The project owner also intends to restrict non-work discussions in workplace deployments, but this release has **no workplace-topic relevance detector**. A benign statement about equal rights is not a hate ground-truth label merely because an organization chooses to restrict that topic. The published evaluation retains its original content-policy labels; it does not measure a separate work-topic policy.
45
 
@@ -51,11 +51,11 @@ Clone the GitHub repository, install `requirements.txt`, and run `python app.py`
51
  from moderation03 import Moderation03
52
 
53
  model = Moderation03("ifmain/Moderation-03")
54
- raw = model.predict("Hello, thanks for your help.", language="en")
55
- medium = model.predict("Hello, thanks for your help.", language="en", preset="medium")
56
  custom = dict.fromkeys(model.config["categories"], None)
57
  custom["harassment"] = 0.4
58
- result = model.predict("Hello, thanks for your help.", language="en", thresholds=custom)
59
  print(result["raw_scores"], result["policy"])
60
  ```
61
 
@@ -79,8 +79,8 @@ Internal held-out content-policy results:
79
  |---|---:|---:|---:|---:|---:|---:|
80
  | Light | 109 | 35 | 244 | 24 | 75.7% | 82.0% |
81
  | Medium | 189 | 51 | 146 | 26 | 78.8% | 87.9% |
82
- | High | 245 | 24 | 121 | 22 | 91.1% | 91.8% |
83
- | Corporate | 252 | 22 | 115 | 23 | 92.0% | 91.6% |
84
 
85
  External evaluation: [mmathys/openai-moderation-api-evaluation](https://huggingface.co/datasets/mmathys/openai-moderation-api-evaluation), revision `84e5cf3bcd6acb3dfc70b6760451645872218a3e`, **1,680 English examples**. Unknown labels are excluded, not treated as negatives. No thresholds were fitted on this dataset. Exact normalized overlaps with used groups, including all their translations: zero; arbitrary paraphrase/pretraining contamination is not excluded. 76 external texts exceed 512 tokens and were truncated.
86
 
@@ -102,3 +102,7 @@ The detailed report contains category/language metrics and the frozen thresholds
102
  ## License
103
 
104
  Apache-2.0 for released code and head weights. The backbone is downloaded separately under its own Apache-2.0 license. External evaluation provenance and definitions: [OpenAI moderation-api-release](https://github.com/openai/moderation-api-release).
 
 
 
 
 
39
  The raw sigmoid scores are **not calibrated probabilities**. They remain unchanged when selecting a preset.
40
  Categories: `harassment`, `harassment_threatening`, `hate`, `hate_threatening`, `self_harm`, `self_harm_instructions`, `self_harm_intent`, `sexual`, `sexual_minors`, `violence`, `violence_graphic`.
41
 
42
+ Raw scores are always displayed. Select a preset (`light`, `medium`, `high`, `corporate`) to populate editable per-category thresholds; every edit immediately affects filtering. There is no mode selector. A `null` threshold disables a category. Enabled categories trigger when `score >= threshold`; any trigger blocks the text. Custom thresholds can change each category independently without any additional word-list rules. Changing presets or thresholds reuses session-local scores without running the model again. Editing the text clears the previous result. The Python API still supports raw-only output with `preset=None`.
43
 
44
  Corporate is the strictest **content-threshold** preset. The project owner also intends to restrict non-work discussions in workplace deployments, but this release has **no workplace-topic relevance detector**. A benign statement about equal rights is not a hate ground-truth label merely because an organization chooses to restrict that topic. The published evaluation retains its original content-policy labels; it does not measure a separate work-topic policy.
45
 
 
51
  from moderation03 import Moderation03
52
 
53
  model = Moderation03("ifmain/Moderation-03")
54
+ raw = model.predict("Hello, thanks for your help.")
55
+ medium = model.predict("Hello, thanks for your help.", preset="medium")
56
  custom = dict.fromkeys(model.config["categories"], None)
57
  custom["harassment"] = 0.4
58
+ result = model.predict("Hello, thanks for your help.", thresholds=custom)
59
  print(result["raw_scores"], result["policy"])
60
  ```
61
 
 
79
  |---|---:|---:|---:|---:|---:|---:|
80
  | Light | 109 | 35 | 244 | 24 | 75.7% | 82.0% |
81
  | Medium | 189 | 51 | 146 | 26 | 78.8% | 87.9% |
82
+ | High | 238 | 24 | 121 | 29 | 90.8% | 89.1% |
83
+ | Corporate | 245 | 22 | 115 | 30 | 91.8% | 89.1% |
84
 
85
  External evaluation: [mmathys/openai-moderation-api-evaluation](https://huggingface.co/datasets/mmathys/openai-moderation-api-evaluation), revision `84e5cf3bcd6acb3dfc70b6760451645872218a3e`, **1,680 English examples**. Unknown labels are excluded, not treated as negatives. No thresholds were fitted on this dataset. Exact normalized overlaps with used groups, including all their translations: zero; arbitrary paraphrase/pretraining contamination is not excluded. 76 external texts exceed 512 tokens and were truncated.
86
 
 
102
  ## License
103
 
104
  Apache-2.0 for released code and head weights. The backbone is downloaded separately under its own Apache-2.0 license. External evaluation provenance and definitions: [OpenAI moderation-api-release](https://github.com/openai/moderation-api-release).
105
+
106
+ ## Neural-only interface
107
+
108
+ The interface accepts text without a language selector. Decisions use only the 11 neural scores and editable thresholds. No profanity word list or other lexical blocker is used. The internal table above has been recomputed without the removed rule; `evaluation/neural_only_evaluation.json` records this change. Historical evaluation files retain the original protocol. Model weights and threshold values are unchanged. Application and inference source code live in GitHub and the Gradio Space; the model repository contains artifacts and documentation only.
calibration/thresholds.json CHANGED
@@ -73,6 +73,8 @@
73
  "probabilities_calibrated": false,
74
  "checkpoint_sha256": "4218fb73825ff2fbbdd897a4346dd67141b15fc63d1811413929dddb88d408d3",
75
  "fit_ids_sha256": "852388954817cf5ef3047eae79e8a1480cc60a1311673e439a02fbb9511cca23",
76
- "policy": "Reference four-profile policy plus finite profanity rule. Research intent checks scored separately.",
77
- "limitations": "Weak teacher-derived and synthetic labels. No new detector heads were trained."
 
 
78
  }
 
73
  "probabilities_calibrated": false,
74
  "checkpoint_sha256": "4218fb73825ff2fbbdd897a4346dd67141b15fc63d1811413929dddb88d408d3",
75
  "fit_ids_sha256": "852388954817cf5ef3047eae79e8a1480cc60a1311673e439a02fbb9511cca23",
76
+ "policy": "Neural scores and per-category thresholds only. No word lists or language selection.",
77
+ "limitations": "Weak teacher-derived and synthetic labels. No new detector heads were trained.",
78
+ "historical_fit_policy": "Reference four-profile policy plus finite profanity rule. Research intent checks scored separately.",
79
+ "postprocessing": "neural_thresholds_only"
80
  }
evaluation/neural_only_evaluation.json ADDED
@@ -0,0 +1,66 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "policy": "neural_thresholds_only",
3
+ "weights_unchanged": true,
4
+ "threshold_values_unchanged": true,
5
+ "internal_audit": {
6
+ "light": {
7
+ "n": 412,
8
+ "TP": 109,
9
+ "FP": 35,
10
+ "TN": 244,
11
+ "FN": 24
12
+ },
13
+ "medium": {
14
+ "n": 412,
15
+ "TP": 189,
16
+ "FP": 51,
17
+ "TN": 146,
18
+ "FN": 26
19
+ },
20
+ "high": {
21
+ "n": 412,
22
+ "TP": 238,
23
+ "FP": 24,
24
+ "TN": 121,
25
+ "FN": 29
26
+ },
27
+ "corporate": {
28
+ "n": 412,
29
+ "TP": 245,
30
+ "FP": 22,
31
+ "TN": 115,
32
+ "FN": 30
33
+ }
34
+ },
35
+ "challenge": {
36
+ "light": {
37
+ "n": 265,
38
+ "TP": 68,
39
+ "FP": 43,
40
+ "TN": 78,
41
+ "FN": 76
42
+ },
43
+ "medium": {
44
+ "n": 265,
45
+ "TP": 127,
46
+ "FP": 33,
47
+ "TN": 52,
48
+ "FN": 53
49
+ },
50
+ "high": {
51
+ "n": 265,
52
+ "TP": 133,
53
+ "FP": 36,
54
+ "TN": 49,
55
+ "FN": 47
56
+ },
57
+ "corporate": {
58
+ "n": 265,
59
+ "TP": 138,
60
+ "FP": 41,
61
+ "TN": 44,
62
+ "FN": 42
63
+ }
64
+ },
65
+ "note": "Reuses saved scores. Historical evaluation.json includes the removed lexical rule in internal policy metrics. External projected category metrics are unaffected."
66
+ }