Update README.md
Browse files
README.md
CHANGED
|
@@ -1,3 +1,67 @@
|
|
| 1 |
-
---
|
| 2 |
-
license: cc-by-nc-4.0
|
| 3 |
-
---
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
license: cc-by-nc-4.0
|
| 3 |
+
---
|
| 4 |
+
## 🚀Installation
|
| 5 |
+
|
| 6 |
+
1. Clone the repositories:
|
| 7 |
+
|
| 8 |
+
```bash
|
| 9 |
+
git clone https://github.com/zjunlp/ChineseHarm-bench
|
| 10 |
+
cd ChineseHarm-bench
|
| 11 |
+
git clone https://github.com/hiyouga/LLaMA-Factory
|
| 12 |
+
```
|
| 13 |
+
|
| 14 |
+
2. Install dependencies:
|
| 15 |
+
|
| 16 |
+
```bash
|
| 17 |
+
cd LLaMA-Factory
|
| 18 |
+
pip install -e ".[torch,metrics]"
|
| 19 |
+
```
|
| 20 |
+
|
| 21 |
+
## 📚Inference
|
| 22 |
+
|
| 23 |
+
We release the following variants of our harmful content detection model:
|
| 24 |
+
|
| 25 |
+
🔹 Single Inference (Example)
|
| 26 |
+
|
| 27 |
+
Run single-input inference using the ChineseGuard-1.5B model:
|
| 28 |
+
|
| 29 |
+
```
|
| 30 |
+
SCRIPT_PATH="../infer/single_infer.py"
|
| 31 |
+
model_name="zjunlp/ChineseGuard-1.5B"
|
| 32 |
+
text="代发短信,有想做的联系我,无押金"
|
| 33 |
+
|
| 34 |
+
python $SCRIPT_PATH \
|
| 35 |
+
--model_name $model_name \
|
| 36 |
+
--text $text
|
| 37 |
+
```
|
| 38 |
+
|
| 39 |
+
🔸 Batch Inference (Multi-NPU or Multi-GPU)
|
| 40 |
+
|
| 41 |
+
To run inference on the entire ChineseHarm-Bench using ChineseGuard-1.5B and 8 NPUs:
|
| 42 |
+
|
| 43 |
+
```
|
| 44 |
+
SCRIPT_PATH="../infer/batch_infer.py"
|
| 45 |
+
model_name="zjunlp/ChineseHarm-1.5B"
|
| 46 |
+
file_name="../benchmark/bench.json"
|
| 47 |
+
output_file="../benchmark/bench_ChineseHarm-1.5B.json"
|
| 48 |
+
|
| 49 |
+
python $SCRIPT_PATH \
|
| 50 |
+
--model_name $model_name \
|
| 51 |
+
--file_name $file_name \
|
| 52 |
+
--output_file $output_file \
|
| 53 |
+
--num_npus 8
|
| 54 |
+
|
| 55 |
+
```
|
| 56 |
+
|
| 57 |
+
> For more configuration options (e.g., batch size, device selection, custom prompt templates), please refer to `single_infer.py` and `batch_infer.py`.
|
| 58 |
+
>
|
| 59 |
+
> **Note:** The inference scripts support both NPU and GPU devices.
|
| 60 |
+
|
| 61 |
+
## 🚩Citation
|
| 62 |
+
|
| 63 |
+
Please cite our repository if you use ChineseGuard in your work. Thanks!
|
| 64 |
+
|
| 65 |
+
```bibtex
|
| 66 |
+
|
| 67 |
+
```
|