--- language: - ko base_model: klue/bert-base tags: - bert - text-classification - korean - safety - harm-detection - mental-health license: cc-by-4.0 pipeline_tag: text-classification --- # CT-NLP Harm Direction Classifier **Safe Sustained Disagreement** 프로젝트의 1단계 통합 세이프가드 핵심 부품. KLUE-BERT-base를 fine-tune해 페르소나 발화가 **치료적 과장인지 해로운 증폭인지** 방향을 탐지합니다. ## 모델 개요 발화의 **강도가 아닌 방향**으로 분류합니다. 강한 부정 정서 자체는 치료적일 수 있으며, 무망감·자기무가치·자해 방향으로의 이동만 해롭습니다. | 라벨 | 설명 | |---|---| | `therapeutic_exaggeration` (0) | 치료적 과장 — 강하지만 한정·가역적, 관점 복귀 가능 | | `borderline` (1) | 경계 — 방향 모호, 보수적 처리 필요 | | `harmful_amplification` (2) | 해로운 증폭 — 무망감·무가치·자해 방향으로 이동 | ### 5축 판별 기준 1. **귀인 방향** — 영속·전반·내부 귀인 ←→ 상황적·일시적 2. **희망·행위성** — "방법 없다/끝났다" ←→ 가능성·통제감 보존 3. **자기가치** — 무가치·자기경멸 ←→ 한정된 자기비판 4. **자해·수단** — 자해 사고·방법 언급 (규칙 기반 하드게이트) 5. **가역성·해소 arc** — 총체화·무해소 ←→ 한정·가역·관점 복귀 ## 학습 정보 | 항목 | 값 | |---|---| | Base model | klue/bert-base | | 학습 데이터 | 한국어 극단 페르소나 토론 발화 9,756건 (group-split) | | Epochs | 4 | | Weighted CE | 클래스 불균형 보정 | | Accuracy | 0.786 | | Macro F1 | 0.733 | | **Harmful F1** | **0.842** (recall 0.81) | | Therapeutic F1 | 0.870 | | Borderline F1 | 0.488 (라벨 노이즈·경계 클래스) | ## 사용법 ```python from transformers import AutoTokenizer, AutoModelForSequenceClassification import torch tok = AutoTokenizer.from_pretrained("thlee00/ct-nlp") model = AutoModelForSequenceClassification.from_pretrained("thlee00/ct-nlp") model.eval() text = "어차피 나는 뭘 해도 안 돼. 이번에도 망했고 앞으로도 그럴 거야." inputs = tok(text, return_tensors="pt", truncation=True, max_length=512) with torch.no_grad(): logits = model(**inputs).logits label = model.config.id2label[logits.argmax(-1).item()] print(label) # harmful_amplification ``` ### 통합 세이프가드로 사용 ```python from ctnlp.safeguard.safeguard import Safeguard sg = Safeguard() # models/harm_direction 자동 로드 result = sg.gate_input("걱정 문장") # {"action": "allow" | "route" | "block", "label": ..., "score": ...} ``` ## 주의사항 - 이 모델은 **토론 발화**로 학습되어 사용자 입력과 레지스터 차이가 있습니다 (도메인 시프트). - 입력 게이트 적용 시 임계값 **0.4** 권장 (무망감 재현율 100% @ 오탐 2.3%). - 임상 진단 목적으로 사용하지 마십시오. ## 프로젝트 - 코드: [CT-NLP-project](https://github.com/thlee00/CT-NLP-project) - SFT 모델: [thlee00/ct-nlp-sft](https://huggingface.co/thlee00/ct-nlp-sft)