{
 "body": "\n## What it measures\n\nOpenCompass `safety` measures how toxic a model's completions are on a list of prompts. Each item is one line from `./data/safety.txt`. The model generates freely. Google Perspective API then assigns a TOXICITY score to that text.\n\nIt is a generation probe, not a refusal quiz and not a comment classifier. It is not [helm_safety](helm_safety.md), not [autobencher_safety](autobencher_safety.md), and not OpenCompass RealToxicPrompts, which has its own config directory.\n\n## How it is scored\n\n`ToxicEvaluator` calls Perspective's comment analyzer with attribute TOXICITY and languages `en` and `zh`. Default threshold is 0.5. Reported numbers are expected_max_toxicity, valid_frac, toxic_frac_valid, and avg_toxicity_score. Lower toxicity is better. Empty comments are invalid (score -1) and dropped. You need a `PerspectiveAPIkey`. There is no gold label.\n\n## Dataset and licence\n\nThe loader keeps every non-empty line. The prompt file is not in the git tree; `get_data_path(..., local_mode=True)` expects it under `./data`. OpenCompass dataset-index.yml does not list a `safety` dataset, so the line count is not established. OpenCompass code is Apache-2.0. The prompt file's own licence is not stated in the files opened here.\n\n## Who publishes it\n\nOpenCompass (open-compass/opencompass). The config is `safety_gen.py` pointing at `safety_gen_7ce197.py`. No dedicated paper is attached in dataset-index.yml. The GitHub repository was created 2023-06-15; a finer first-commit date for this config was not read.\n\n## Lineage\n\n`ToxicEvaluator` comments that it is normally used for RealToxicPrompts but can score toxicity in general. RealToxicPrompts remains a separate OpenCompass dataset with its own paper (arxiv 2009.11462). Do not treat this id as an alias of that eval, or of HELM Safety.\n\n## Saturation and contamination\n\nNo score table for `safety_datasets` was opened, so saturation is unknown. Prompt leakage cannot be judged until `safety.txt` is identified. Completions are judged live by Perspective, so the metric is not a fixed public answer key.\n\n## How to run it\n\nImport `safety_datasets` from `opencompass.configs.datasets.safety.safety_gen`. Place `data/safety.txt` locally. Set `PerspectiveAPIkey`. Zero-shot generation only; the 7ce197 file is the current prompt version. Numbers need the same Perspective key, threshold, and prompt file to compare.\n\n## Reading the numbers\n\nA low toxic_frac_valid means few completions crossed 0.5 on Perspective, not that the model refuses harmful asks. Max toxicity is one worst completion. Compare only against other Perspective runs on the same file. For refusal and policy coverage use [helm_safety](helm_safety.md) or a dedicated red-team set.\n",
 "build": {
  "built_at": "2026-09-09T16:56:50+00:00",
  "commit": "0a599558854c0e238c03a0f0d725239cb28f9d11",
  "eligibility_as_of": "2026-09-09"
 },
 "disposition": {
  "canonical_id": "safety",
  "reasons": [],
  "status": "unassessed",
  "verified_results": []
 },
 "models_covered": [],
 "page": {
  "aliases": [
   "safety_gen",
   "safety_datasets"
  ],
  "category": "safety",
  "contamination": {
   "note": "If safety.txt is distributed in OpenCompass data zips, the prompts are public. The file was not readable from the repository, so overlap with RealToxicPrompts or other toxicity sets is not established.\n",
   "risk": "unknown"
  },
  "dataset": {
   "languages": [],
   "license": "",
   "modalities": [
    "text"
   ],
   "public_test_set": true,
   "size": null,
   "size_note": "SafetyDataset counts one non-empty line as one prompt. The file `./data/safety.txt` is not in the OpenCompass git tree opened here (local_mode True via get_data_path). OpenCompass dataset-index.yml has no `safety` entry, so a published item count was not established. OpenCompassData zip listings on release 0.2.2.rc1 also did not name the file in the HTML opened here.\n",
   "splits": "test only; train_split and test_split both set to test",
   "url": "https://github.com/open-compass/opencompass/tree/main/opencompass/configs/datasets/safety"
  },
  "freshness": {
   "researched": "2026-09-08",
   "researched_by": "Grok Build, batch-070 (Codex coordinated)",
   "reviewed": "2026-09-08",
   "reviewed_by": "Grok Build independent review, batch-070"
  },
  "harness": {
   "bigbench": "",
   "helm": "",
   "inspect_evals": "",
   "lm_eval": "",
   "opencompass": "safety",
   "other": "safety_datasets in safety_gen.py re-exports safety_gen_7ce197.py; evaluator ToxicEvaluator (Perspective API, env PerspectiveAPIkey)."
  },
  "id": "safety",
  "last_updated": "",
  "leaderboard_url": "",
  "lineage": {
   "family": "",
   "predecessor": "",
   "successors": [],
   "variants": []
  },
  "measures": "OpenCompass `safety` is a generation-toxicity probe, not a named standalone paper. The model sees one prompt per line from `./data/safety.txt` and writes a free-text continuation. Perspective API then scores TOXICITY on that continuation. English and Chinese are requested on the API call; the prompt file's language mix is not established here. This is not [helm_safety](helm_safety.md), not [autobencher_safety](autobencher_safety.md), and not the separate OpenCompass RealToxicPrompts config.\n",
  "metric": {
   "baseline_note": "ToxicEvaluator default threshold is 0.5. It returns expected_max_toxicity (max valid score), valid_frac, toxic_frac_valid (share of valid completions at or above 0.5), and avg_toxicity_score. Empty Perspective comments become toxicity_score -1 and are dropped as NaN. No random or human baseline is in the config.\n",
   "direction": "lower_is_better",
   "human_baseline": null,
   "max_score": 1.0,
   "name": "Perspective toxicity (expected_max_toxicity, toxic_frac_valid, avg_toxicity_score)",
   "random_baseline": null,
   "unit": ""
  },
  "name": "OpenCompass safety (Perspective toxicity)",
  "page_kind": "benchmark",
  "paper": {
   "arxiv": "",
   "title": "",
   "url": "",
   "year": null
  },
  "publisher": {
   "authors": [],
   "org": "OpenCompass",
   "url": "https://github.com/open-compass/opencompass"
  },
  "released": "2023",
  "repo_url": "https://github.com/open-compass/opencompass/tree/main/opencompass/configs/datasets/safety",
  "saturation": {
   "as_of": "",
   "note": "No public leaderboard or score table for this config was opened. Perspective scores are not comparable to refusal accuracy on [helm_safety](helm_safety.md).\n",
   "status": "unknown",
   "top_score": null
  },
  "sources": [
   {
    "accessed": "2026-09-08",
    "title": "safety_gen.py (re-exports safety_datasets from safety_gen_7ce197)",
    "url": "https://raw.githubusercontent.com/open-compass/opencompass/main/opencompass/configs/datasets/safety/safety_gen.py"
   },
   {
    "accessed": "2026-09-08",
    "title": "safety_gen_7ce197.py (SafetyDataset, ./data/safety.txt, ToxicEvaluator)",
    "url": "https://raw.githubusercontent.com/open-compass/opencompass/main/opencompass/configs/datasets/safety/safety_gen_7ce197.py"
   },
   {
    "accessed": "2026-09-08",
    "title": "SafetyDataset loader (one prompt per non-empty line, test split)",
    "url": "https://raw.githubusercontent.com/open-compass/opencompass/main/opencompass/datasets/safety.py"
   },
   {
    "accessed": "2026-09-08",
    "title": "ToxicEvaluator (Perspective TOXICITY, default thr 0.5, en/zh)",
    "url": "https://raw.githubusercontent.com/open-compass/opencompass/main/opencompass/openicl/icl_evaluator/icl_toxic_evaluator.py"
   },
   {
    "accessed": "2026-09-08",
    "title": "OpenCompass Apache License 2.0",
    "url": "https://raw.githubusercontent.com/open-compass/opencompass/main/LICENSE"
   },
   {
    "accessed": "2026-09-08",
    "title": "OpenCompass dataset-index.yml (no safety dataset entry; RealToxicPrompts is separate)",
    "url": "https://raw.githubusercontent.com/open-compass/opencompass/main/dataset-index.yml"
   },
   {
    "accessed": "2026-09-08",
    "title": "OpenCompass dataset preparation (OpenCompassData zips into ./data)",
    "url": "https://raw.githubusercontent.com/open-compass/opencompass/main/docs/en/get_started/installation.md"
   },
   {
    "accessed": "2026-09-08",
    "title": "OpenCompass configs/datasets/safety directory (two Python files)",
    "url": "https://github.com/open-compass/opencompass/tree/main/opencompass/configs/datasets/safety"
   }
  ],
  "status": "unknown",
  "subcategory": "OpenCompass generation-toxicity probe on a local prompt file",
  "summary": "OpenCompass runs free-text completions on prompts from a local safety.txt file and scores toxicity with Google Perspective API.",
  "tags": [
   "safety",
   "toxicity",
   "perspective-api",
   "opencompass",
   "generation"
  ],
  "task_format": "Zero-shot GenInferencer. PromptTemplate is the raw `{prompt}` string. ZeroRetriever. SafetyDataset builds a Hugging Face DatasetDict with a test split only (idx, prompt). output_column is idx because there is no gold string. ToxicEvaluator does not use references.\n"
 }
}