prismdata commited on
Commit
dbc33ff
ยท
verified ยท
1 Parent(s): ff12a9f

Upload README.md with huggingface_hub

Browse files
Files changed (1) hide show
  1. README.md +89 -171
README.md CHANGED
@@ -1,199 +1,117 @@
1
  ---
2
- library_name: transformers
3
- tags: []
 
 
 
 
 
 
 
 
 
 
 
4
  ---
5
 
6
- # Model Card for Model ID
7
 
8
- <!-- Provide a quick summary of what the model is/does. -->
9
 
 
 
10
 
 
11
 
12
- ## Model Details
 
 
 
 
 
 
 
 
 
 
 
 
13
 
14
- ### Model Description
15
 
16
- <!-- Provide a longer summary of what this model is. -->
 
 
17
 
18
- This is the model card of a ๐Ÿค— transformers model that has been pushed on the Hub. This model card has been automatically generated.
 
 
 
19
 
20
- - **Developed by:** [More Information Needed]
21
- - **Funded by [optional]:** [More Information Needed]
22
- - **Shared by [optional]:** [More Information Needed]
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
- ### Model Sources [optional]
 
 
 
 
 
29
 
30
- <!-- Provide the basic links for the model. -->
31
 
32
- - **Repository:** [More Information Needed]
33
- - **Paper [optional]:** [More Information Needed]
34
- - **Demo [optional]:** [More Information Needed]
 
 
35
 
36
- ## Uses
37
 
38
- <!-- Address questions around how the model is intended to be used, including the foreseeable users of the model and those affected by the model. -->
 
 
 
 
39
 
40
- ### Direct Use
41
 
42
- <!-- This section is for the model use without fine-tuning or plugging into a larger ecosystem/app. -->
 
 
43
 
44
- [More Information Needed]
45
 
46
- ### Downstream Use [optional]
 
 
 
47
 
48
- <!-- This section is for the model use when fine-tuned for a task, or when plugged into a larger ecosystem/app -->
49
 
50
- [More Information Needed]
 
 
51
 
52
- ### Out-of-Scope Use
53
 
54
- <!-- This section addresses misuse, malicious use, and uses that the model will not work well for. -->
 
 
55
 
56
- [More Information Needed]
57
 
58
- ## Bias, Risks, and Limitations
59
 
60
- <!-- This section is meant to convey both technical and sociotechnical limitations. -->
61
 
62
- [More Information Needed]
63
-
64
- ### Recommendations
65
-
66
- <!-- This section is meant to convey recommendations with respect to the bias, risk, and technical limitations. -->
67
-
68
- Users (both direct and downstream) should be made aware of the risks, biases and limitations of the model. More information needed for further recommendations.
69
-
70
- ## How to Get Started with the Model
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
+ ```