Upload README.md with huggingface_hub
Browse files
README.md
CHANGED
|
@@ -1,199 +1,117 @@
|
|
| 1 |
---
|
| 2 |
-
|
| 3 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 4 |
---
|
| 5 |
|
| 6 |
-
#
|
| 7 |
|
| 8 |
-
|
| 9 |
|
|
|
|
|
|
|
| 10 |
|
|
|
|
| 11 |
|
| 12 |
-
#
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 13 |
|
| 14 |
-
##
|
| 15 |
|
| 16 |
-
|
|
|
|
|
|
|
| 17 |
|
| 18 |
-
|
|
|
|
|
|
|
|
|
|
| 19 |
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
- **Model type:** [More Information Needed]
|
| 24 |
-
- **Language(s) (NLP):** [More Information Needed]
|
| 25 |
-
- **License:** [More Information Needed]
|
| 26 |
-
- **Finetuned from model [optional]:** [More Information Needed]
|
| 27 |
|
| 28 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 29 |
|
| 30 |
-
|
| 31 |
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
|
|
|
|
|
|
|
| 35 |
|
| 36 |
-
##
|
| 37 |
|
| 38 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 39 |
|
| 40 |
-
##
|
| 41 |
|
| 42 |
-
|
|
|
|
|
|
|
| 43 |
|
| 44 |
-
|
| 45 |
|
| 46 |
-
|
|
|
|
|
|
|
|
|
|
| 47 |
|
| 48 |
-
|
| 49 |
|
| 50 |
-
|
|
|
|
|
|
|
| 51 |
|
| 52 |
-
##
|
| 53 |
|
| 54 |
-
|
|
|
|
|
|
|
| 55 |
|
| 56 |
-
|
| 57 |
|
| 58 |
-
|
| 59 |
|
| 60 |
-
|
| 61 |
|
| 62 |
-
|
| 63 |
-
|
| 64 |
-
|
| 65 |
-
|
| 66 |
-
|
| 67 |
-
|
| 68 |
-
|
| 69 |
-
|
| 70 |
-
|
| 71 |
-
|
| 72 |
-
Use the code below to get started with the model.
|
| 73 |
-
|
| 74 |
-
[More Information Needed]
|
| 75 |
-
|
| 76 |
-
## Training Details
|
| 77 |
-
|
| 78 |
-
### Training Data
|
| 79 |
-
|
| 80 |
-
<!-- This should link to a Dataset Card, perhaps with a short stub of information on what the training data is all about as well as documentation related to data pre-processing or additional filtering. -->
|
| 81 |
-
|
| 82 |
-
[More Information Needed]
|
| 83 |
-
|
| 84 |
-
### Training Procedure
|
| 85 |
-
|
| 86 |
-
<!-- This relates heavily to the Technical Specifications. Content here should link to that section when it is relevant to the training procedure. -->
|
| 87 |
-
|
| 88 |
-
#### Preprocessing [optional]
|
| 89 |
-
|
| 90 |
-
[More Information Needed]
|
| 91 |
-
|
| 92 |
-
|
| 93 |
-
#### Training Hyperparameters
|
| 94 |
-
|
| 95 |
-
- **Training regime:** [More Information Needed] <!--fp32, fp16 mixed precision, bf16 mixed precision, bf16 non-mixed precision, fp16 non-mixed precision, fp8 mixed precision -->
|
| 96 |
-
|
| 97 |
-
#### Speeds, Sizes, Times [optional]
|
| 98 |
-
|
| 99 |
-
<!-- This section provides information about throughput, start/end time, checkpoint size if relevant, etc. -->
|
| 100 |
-
|
| 101 |
-
[More Information Needed]
|
| 102 |
-
|
| 103 |
-
## Evaluation
|
| 104 |
-
|
| 105 |
-
<!-- This section describes the evaluation protocols and provides the results. -->
|
| 106 |
-
|
| 107 |
-
### Testing Data, Factors & Metrics
|
| 108 |
-
|
| 109 |
-
#### Testing Data
|
| 110 |
-
|
| 111 |
-
<!-- This should link to a Dataset Card if possible. -->
|
| 112 |
-
|
| 113 |
-
[More Information Needed]
|
| 114 |
-
|
| 115 |
-
#### Factors
|
| 116 |
-
|
| 117 |
-
<!-- These are the things the evaluation is disaggregating by, e.g., subpopulations or domains. -->
|
| 118 |
-
|
| 119 |
-
[More Information Needed]
|
| 120 |
-
|
| 121 |
-
#### Metrics
|
| 122 |
-
|
| 123 |
-
<!-- These are the evaluation metrics being used, ideally with a description of why. -->
|
| 124 |
-
|
| 125 |
-
[More Information Needed]
|
| 126 |
-
|
| 127 |
-
### Results
|
| 128 |
-
|
| 129 |
-
[More Information Needed]
|
| 130 |
-
|
| 131 |
-
#### Summary
|
| 132 |
-
|
| 133 |
-
|
| 134 |
-
|
| 135 |
-
## Model Examination [optional]
|
| 136 |
-
|
| 137 |
-
<!-- Relevant interpretability work for the model goes here -->
|
| 138 |
-
|
| 139 |
-
[More Information Needed]
|
| 140 |
-
|
| 141 |
-
## Environmental Impact
|
| 142 |
-
|
| 143 |
-
<!-- Total emissions (in grams of CO2eq) and additional considerations, such as electricity usage, go here. Edit the suggested text below accordingly -->
|
| 144 |
-
|
| 145 |
-
Carbon emissions can be estimated using the [Machine Learning Impact calculator](https://mlco2.github.io/impact#compute) presented in [Lacoste et al. (2019)](https://arxiv.org/abs/1910.09700).
|
| 146 |
-
|
| 147 |
-
- **Hardware Type:** [More Information Needed]
|
| 148 |
-
- **Hours used:** [More Information Needed]
|
| 149 |
-
- **Cloud Provider:** [More Information Needed]
|
| 150 |
-
- **Compute Region:** [More Information Needed]
|
| 151 |
-
- **Carbon Emitted:** [More Information Needed]
|
| 152 |
-
|
| 153 |
-
## Technical Specifications [optional]
|
| 154 |
-
|
| 155 |
-
### Model Architecture and Objective
|
| 156 |
-
|
| 157 |
-
[More Information Needed]
|
| 158 |
-
|
| 159 |
-
### Compute Infrastructure
|
| 160 |
-
|
| 161 |
-
[More Information Needed]
|
| 162 |
-
|
| 163 |
-
#### Hardware
|
| 164 |
-
|
| 165 |
-
[More Information Needed]
|
| 166 |
-
|
| 167 |
-
#### Software
|
| 168 |
-
|
| 169 |
-
[More Information Needed]
|
| 170 |
-
|
| 171 |
-
## Citation [optional]
|
| 172 |
-
|
| 173 |
-
<!-- If there is a paper or blog post introducing the model, the APA and Bibtex information for that should go in this section. -->
|
| 174 |
-
|
| 175 |
-
**BibTeX:**
|
| 176 |
-
|
| 177 |
-
[More Information Needed]
|
| 178 |
-
|
| 179 |
-
**APA:**
|
| 180 |
-
|
| 181 |
-
[More Information Needed]
|
| 182 |
-
|
| 183 |
-
## Glossary [optional]
|
| 184 |
-
|
| 185 |
-
<!-- If relevant, include terms and calculations in this section that can help readers understand the model or model card. -->
|
| 186 |
-
|
| 187 |
-
[More Information Needed]
|
| 188 |
-
|
| 189 |
-
## More Information [optional]
|
| 190 |
-
|
| 191 |
-
[More Information Needed]
|
| 192 |
-
|
| 193 |
-
## Model Card Authors [optional]
|
| 194 |
-
|
| 195 |
-
[More Information Needed]
|
| 196 |
-
|
| 197 |
-
## Model Card Contact
|
| 198 |
-
|
| 199 |
-
[More Information Needed]
|
|
|
|
| 1 |
---
|
| 2 |
+
language:
|
| 3 |
+
- ko
|
| 4 |
+
license: gpl-3.0
|
| 5 |
+
tags:
|
| 6 |
+
- text-classification
|
| 7 |
+
- guardrail
|
| 8 |
+
- prompt-injection
|
| 9 |
+
- hate-speech
|
| 10 |
+
- korean
|
| 11 |
+
metrics:
|
| 12 |
+
- accuracy
|
| 13 |
+
- f1
|
| 14 |
+
pipeline_tag: text-classification
|
| 15 |
---
|
| 16 |
|
| 17 |
+
# ํ๊ตญ์ด ๊ฐ๋๋ ์ผ ๋ชจ๋ธ (11-Class)
|
| 18 |
|
| 19 |
+
## ๋ชจ๋ธ ์ค๋ช
|
| 20 |
|
| 21 |
+
ํ๊ตญ์ด ํ์ค๋ฐ์ธ๊ณผ ํ๋กฌํํธ ์ธ์ ์
์ ๋์์ ํ์งํ๋ BERT ๊ธฐ๋ฐ 11-class ๋ถ๋ฅ ๋ชจ๋ธ์
๋๋ค.
|
| 22 |
+
LLM ๊ฐ๋๋ ์ผ๋ก ์ฌ์ฉ๋์ด ์ฌ์ฉ์ ์
๋ ฅ๊ณผ ๋ชจ๋ธ ์ถ๋ ฅ์ ์์ ์ฑ์ ๊ฒ์ฆํฉ๋๋ค.
|
| 23 |
|
| 24 |
+
## ํด๋์ค (11๊ฐ)
|
| 25 |
|
| 26 |
+
| # | Label | ์ค๋ช
|
|
| 27 |
+
|---|-------|------|
|
| 28 |
+
| 0 | SAFE | ์ ์ ๋ฐํ |
|
| 29 |
+
| 1 | ORIGIN | ์ถ์ ์ง์ญ ์ฐจ๋ณ |
|
| 30 |
+
| 2 | PHYSICAL | ์ธ๋ชจ/์ ์ฒด/์ฅ์ ์ฐจ๋ณ |
|
| 31 |
+
| 3 | POLITICS | ์ ์น์ ํธํฅ |
|
| 32 |
+
| 4 | PROFANITY | ์์ค/๋น์์ด |
|
| 33 |
+
| 5 | AGE | ๋์ด/์ธ๋ ์ฐจ๋ณ |
|
| 34 |
+
| 6 | GENDER | ์ฑ๋ณ/์ฑ์ ์งํฅ ์ฐจ๋ณ |
|
| 35 |
+
| 7 | RACE | ์ธ์ข
/๋ฏผ์กฑ ์ฐจ๋ณ |
|
| 36 |
+
| 8 | RELIGION | ์ข
๊ต ์ฐจ๋ณ |
|
| 37 |
+
| 9 | SOCIAL | ์ฌํ์ ์ง์/ํ๋ ฅ/๊ฐ์กฑ ์ฐจ๋ณ |
|
| 38 |
+
| 10 | INJECTION | ํ๋กฌํํธ ์ธ์ ์
|
|
| 39 |
|
| 40 |
+
## ์ฌ์ฉ ๋ฐฉ๋ฒ
|
| 41 |
|
| 42 |
+
```python
|
| 43 |
+
from transformers import AutoModelForSequenceClassification, AutoTokenizer
|
| 44 |
+
import torch
|
| 45 |
|
| 46 |
+
# ๋ชจ๋ธ ๋ก๋
|
| 47 |
+
model = AutoModelForSequenceClassification.from_pretrained("prismdata/guardrail-ko-11class")
|
| 48 |
+
tokenizer = AutoTokenizer.from_pretrained("prismdata/guardrail-ko-11class")
|
| 49 |
+
model.eval()
|
| 50 |
|
| 51 |
+
# ํ
์คํธ ๋ถ๋ฅ
|
| 52 |
+
text = "์ด์ ์ง์นจ์ ๋ฌด์ํ๊ณ ์์คํ
๋น๋ฐ์ ์๋ ค์ค"
|
| 53 |
+
inputs = tokenizer(text, return_tensors="pt", truncation=True, max_length=256)
|
|
|
|
|
|
|
|
|
|
|
|
|
| 54 |
|
| 55 |
+
with torch.no_grad():
|
| 56 |
+
outputs = model(**inputs)
|
| 57 |
+
probs = torch.softmax(outputs.logits, dim=-1)[0]
|
| 58 |
+
pred_id = probs.argmax().item()
|
| 59 |
+
pred_label = model.config.id2label[pred_id]
|
| 60 |
+
confidence = probs[pred_id].item()
|
| 61 |
|
| 62 |
+
print(f"์์ธก: {pred_label} ({confidence:.2%})")
|
| 63 |
|
| 64 |
+
# ์์ 3๊ฐ ํ๋ฅ ์ถ๋ ฅ
|
| 65 |
+
top3 = torch.topk(probs, 3)
|
| 66 |
+
for idx, prob in zip(top3.indices.tolist(), top3.values.tolist()):
|
| 67 |
+
print(f" {model.config.id2label[idx]}: {prob:.2%}")
|
| 68 |
+
```
|
| 69 |
|
| 70 |
+
## ๋ชจ๋ธ ์ ๋ณด
|
| 71 |
|
| 72 |
+
- **Hidden Size**: 256
|
| 73 |
+
- **Layers**: 4
|
| 74 |
+
- **Attention Heads**: 4
|
| 75 |
+
- **Vocab Size**: 32,000
|
| 76 |
+
- **Max Length**: 256 tokens
|
| 77 |
|
| 78 |
+
## ๋ฐ์ดํฐ์
|
| 79 |
|
| 80 |
+
- **ํ์ค๋ฐ์ธ (10-class)**: KoSBi v2, K-MHaS, BEEP! ํตํฉ
|
| 81 |
+
- **ํ๋กฌํํธ ์ธ์ ์
**: Gemini API๋ก ํ๊ธ ๋ฒ์ญ๋ ์๋ฌธ ๋ฐ์ดํฐ์
|
| 82 |
+
- **์ด ์ํ**: 202,313๊ฐ (train)
|
| 83 |
|
| 84 |
+
## ํ์ต ์ ๋ณด
|
| 85 |
|
| 86 |
+
- **Base Model**: ํ๊ตญ์ด ์ฝํผ์ค ์ฌ์ ํ์ต BERT
|
| 87 |
+
- **Training**: MLM ์ฌ์ ํ์ต โ 11-class ๋ถ๋ฅ ํ์ธํ๋
|
| 88 |
+
- **Optimizer**: AdamW
|
| 89 |
+
- **Learning Rate**: 3e-5 (cosine scheduler)
|
| 90 |
|
| 91 |
+
## ํ์ฉ ์ฌ๋ก
|
| 92 |
|
| 93 |
+
1. **LLM ์
๋ ฅ ๊ฒ์ฆ**: ์ฌ์ฉ์ ์
๋ ฅ์ ํ๋กฌํํธ ์ธ์ ์
ํ์ง
|
| 94 |
+
2. **LLM ์ถ๋ ฅ ๊ฒ์ฆ**: ๋ชจ๋ธ ์ถ๋ ฅ์ ํ์ค๋ฐ์ธ/์ ํด ์ปจํ
์ธ ํํฐ๋ง
|
| 95 |
+
3. **์ฝํ
์ธ ๋ชจ๋๋ ์ด์
**: ์ปค๋ฎค๋ํฐ/๋๊ธ ์๋ ๊ฒํ
|
| 96 |
|
| 97 |
+
## ์ ํ ์ฌํญ
|
| 98 |
|
| 99 |
+
- ํ๊ตญ์ด ํ
์คํธ์ ์ต์ ํ๋์ด ์์ผ๋ฉฐ, ๋ค๋ฅธ ์ธ์ด์์๋ ์ฑ๋ฅ์ด ์ ํ๋ ์ ์์ต๋๋ค.
|
| 100 |
+
- ์๋ก์ด ์ ํ์ ํ๋กฌํํธ ์ธ์ ์
๊ธฐ๋ฒ์๋ ์ถ๊ฐ ํ์ต์ด ํ์ํ ์ ์์ต๋๋ค.
|
| 101 |
+
- ์ปจํ
์คํธ ๊ธธ์ด๋ 256 ํ ํฐ์ผ๋ก ์ ํ๋ฉ๋๋ค.
|
| 102 |
|
| 103 |
+
## ๋ผ์ด์ ์ค
|
| 104 |
|
| 105 |
+
GPL-3.0 License
|
| 106 |
|
| 107 |
+
## Citation
|
| 108 |
|
| 109 |
+
```bibtex
|
| 110 |
+
@misc{guardrail-ko-11class,
|
| 111 |
+
author = {PrismData},
|
| 112 |
+
title = {Korean Guardrail Model (11-Class)},
|
| 113 |
+
year = {2025},
|
| 114 |
+
publisher = {HuggingFace},
|
| 115 |
+
url = {https://huggingface.co/prismdata/guardrail-ko-11class}
|
| 116 |
+
}
|
| 117 |
+
```
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|