Add library name and link to code
#1
by
nielsr
HF Staff
- opened
README.md
CHANGED
|
@@ -1,11 +1,13 @@
|
|
| 1 |
---
|
| 2 |
-
|
|
|
|
| 3 |
language:
|
| 4 |
- zh
|
|
|
|
| 5 |
pipeline_tag: text-classification
|
| 6 |
-
|
| 7 |
-
- zjunlp/ChineseHarm-bench
|
| 8 |
---
|
|
|
|
| 9 |
## 🚀Installation
|
| 10 |
|
| 11 |
1. Clone the repositories:
|
|
@@ -27,13 +29,17 @@ datasets:
|
|
| 27 |
|
| 28 |
We release the following variants of our harmful content detection model:
|
| 29 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 30 |
🔹 Single Inference (Example)
|
| 31 |
|
| 32 |
-
Run single-input inference using the ChineseGuard-
|
| 33 |
|
| 34 |
```
|
| 35 |
SCRIPT_PATH="../infer/single_infer.py"
|
| 36 |
-
model_name="zjunlp/ChineseGuard-
|
| 37 |
text="代发短信,有想做的联系我,无押金"
|
| 38 |
|
| 39 |
python $SCRIPT_PATH \
|
|
@@ -43,13 +49,13 @@ python $SCRIPT_PATH \
|
|
| 43 |
|
| 44 |
🔸 Batch Inference (Multi-NPU or Multi-GPU)
|
| 45 |
|
| 46 |
-
To run inference on the entire ChineseHarm-Bench using ChineseGuard-
|
| 47 |
|
| 48 |
```
|
| 49 |
SCRIPT_PATH="../infer/batch_infer.py"
|
| 50 |
-
model_name="zjunlp/ChineseHarm-
|
| 51 |
file_name="../benchmark/bench.json"
|
| 52 |
-
output_file="../benchmark/bench_ChineseHarm-
|
| 53 |
|
| 54 |
python $SCRIPT_PATH \
|
| 55 |
--model_name $model_name \
|
|
@@ -63,9 +69,20 @@ python $SCRIPT_PATH \
|
|
| 63 |
>
|
| 64 |
> **Note:** The inference scripts support both NPU and GPU devices.
|
| 65 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 66 |
## 🚩Citation
|
| 67 |
|
| 68 |
-
Please cite our repository if you use
|
| 69 |
|
| 70 |
```bibtex
|
| 71 |
@misc{liu2025chineseharmbenchchineseharmfulcontent,
|
|
@@ -77,4 +94,6 @@ Please cite our repository if you use ChineseGuard in your work. Thanks!
|
|
| 77 |
primaryClass={cs.CL},
|
| 78 |
url={https://arxiv.org/abs/2506.10960},
|
| 79 |
}
|
| 80 |
-
```
|
|
|
|
|
|
|
|
|
| 1 |
---
|
| 2 |
+
datasets:
|
| 3 |
+
- zjunlp/ChineseHarm-bench
|
| 4 |
language:
|
| 5 |
- zh
|
| 6 |
+
license: cc-by-nc-4.0
|
| 7 |
pipeline_tag: text-classification
|
| 8 |
+
library_name: transformers
|
|
|
|
| 9 |
---
|
| 10 |
+
|
| 11 |
## 🚀Installation
|
| 12 |
|
| 13 |
1. Clone the repositories:
|
|
|
|
| 29 |
|
| 30 |
We release the following variants of our harmful content detection model:
|
| 31 |
|
| 32 |
+
- [**ChineseGuard-1.5B**](https://huggingface.co/zjunlp/ChineseGuard-1.5B)
|
| 33 |
+
- [**ChineseGuard-3B**](https://huggingface.co/zjunlp/ChineseGuard-3B)
|
| 34 |
+
- [**ChineseGuard-7B**](https://huggingface.co/zjunlp/ChineseGuard-7B)
|
| 35 |
+
|
| 36 |
🔹 Single Inference (Example)
|
| 37 |
|
| 38 |
+
Run single-input inference using the ChineseGuard-1.5B model:
|
| 39 |
|
| 40 |
```
|
| 41 |
SCRIPT_PATH="../infer/single_infer.py"
|
| 42 |
+
model_name="zjunlp/ChineseGuard-1.5B"
|
| 43 |
text="代发短信,有想做的联系我,无押金"
|
| 44 |
|
| 45 |
python $SCRIPT_PATH \
|
|
|
|
| 49 |
|
| 50 |
🔸 Batch Inference (Multi-NPU or Multi-GPU)
|
| 51 |
|
| 52 |
+
To run inference on the entire ChineseHarm-Bench using ChineseGuard-1.5B and 8 NPUs:
|
| 53 |
|
| 54 |
```
|
| 55 |
SCRIPT_PATH="../infer/batch_infer.py"
|
| 56 |
+
model_name="zjunlp/ChineseHarm-1.5B"
|
| 57 |
file_name="../benchmark/bench.json"
|
| 58 |
+
output_file="../benchmark/bench_ChineseHarm-1.5B.json"
|
| 59 |
|
| 60 |
python $SCRIPT_PATH \
|
| 61 |
--model_name $model_name \
|
|
|
|
| 69 |
>
|
| 70 |
> **Note:** The inference scripts support both NPU and GPU devices.
|
| 71 |
|
| 72 |
+
**Evaluation: Calculating F1 Score**
|
| 73 |
+
|
| 74 |
+
After inference, evaluate the predictions by computing the F1 score with the following command:
|
| 75 |
+
|
| 76 |
+
```
|
| 77 |
+
python ../calculate_metrics.py \
|
| 78 |
+
--file_path "../benchmark/bench_ChineseHarm-1.5B.json" \
|
| 79 |
+
--true_label_field "标签" \
|
| 80 |
+
--predicted_label_field "predict_label"
|
| 81 |
+
```
|
| 82 |
+
|
| 83 |
## 🚩Citation
|
| 84 |
|
| 85 |
+
Please cite our repository if you use ChineseHarm-bench in your work. Thanks!
|
| 86 |
|
| 87 |
```bibtex
|
| 88 |
@misc{liu2025chineseharmbenchchineseharmfulcontent,
|
|
|
|
| 94 |
primaryClass={cs.CL},
|
| 95 |
url={https://arxiv.org/abs/2506.10960},
|
| 96 |
}
|
| 97 |
+
```
|
| 98 |
+
|
| 99 |
+
Codebase: https://github.com/zjunlp/ChineseHarm-bench
|