--- license: apache-2.0 base_model: dragonkue/snowflake-arctic-embed-l-v2.0-ko private: true datasets: - werty1248/Ko-Edu-Annotation-500K language: - ko --- # Ko-Edu Classifier 2k 한국어 사전학습 말뭉치 퀄리티 평가 모델 ## 상세 기반 모델: [dragonkue/snowflake-arctic-embed-l-v2.0-ko](https://huggingface.co/dragonkue/snowflake-arctic-embed-l-v2.0-ko) 학습 데이터: **[werty1248/Ko-Edu-Annotation-500K](https://huggingface.co/datasets/werty1248/Ko-Edu-Annotation-500K)** 및 **AI HUB 데이터 등을 같은 방식으로 라벨링 한 100K 데이터**(약관에 따라 공개 X) - 100K 데이터 목록: [독파모 사전 학습 데이터 - 한국어](https://aihub.or.kr/aihubdata/data/view.do?currMenu=520&topMenu=100&aihubDataSe=wblextrldata&dataSetSn=71898), [한국어 성능이 개선된 초거대AI 언어모델 개발 및 데이터](https://aihub.or.kr/aihubdata/data/view.do?currMenu=115&topMenu=100&dataSetSn=71748), 나무위키 문서 데이터 문서의 앞 512토큰을 넣는 것이 속도 면에서 권장되지만, 최대 2048토큰까지 학습되었습니다. 퀄리티 예측 평균과 분산을 함께 출력하므로 일부 분산이 높은 데이터만 더 긴 문맥을 주고 평가를 요청할 수 있습니다. - 512토큰에서 test accuracy: 69.87% - 1,024토큰에서 test accuracy: 72.92% - 2,048토큰에서 test accuracy: 74.10% ## 사용법 - 첫번째 head: 퀄리티 예측 logit (mu = 4 * sigmoid(logit)) - 두번째 head: 퀄리티 예측의 분산 logit (sigma = sqrt(e^(logit))) - 3-5번째 head: [정상 / 약간의 파싱 오류 / 심각한 파싱 오류] 3-class classification logit ``` python import torch from transformers import AutoModelForSequenceClassification, AutoTokenizer tokenizer = AutoTokenizer.from_pretrained("werty1248/Ko-Edu-Classifier-2k") model = AutoModelForSequenceClassification.from_pretrained("werty1248/Ko-Edu-Classifier-2k") max_tokens = 512 # or 1024, 2048 model.eval() text = """나 아는사람 강다니엘 닮은 이모가 다시보게되는게 다시 그때처럼 안닮게 엄마보면 느껴지는걸수도 있는거임? 엄마도?""" text2 = """Ko-Edu-Annotation-500K 한국어 사전학습 데이터 퀄리티 평가 모델 학습 데이터 셋 Annotation 시간 기준 1x 5090에서 약 24시간 내용 quality_score: 최종 어노테이션 점수 content_score: 파싱 에러를 무시했을 때 내용의 점수 critical_error: 파싱 에러(핵심 그림/표/수식 누락)로 인해 원문을 알아보기 힘듦 noncritical_error: 파싱 에러(표가 plane text로 변환 등)가 있지만 원문을 이해할수는 있음 Annotation Model LilaRest/gemma-4-31B-it-NVFP4-turbo Gemma-4-31B 모델에 Attention까지 NVFP4로 양자화 한 모델 Solar Pro 4, Qwen 3.8 Flash Next 모델과 함께 비교했을 때, 정성적 평가(edge case 확인) 및 정량적 평가(동일 모델 3회 반복 평가의 Spearman 상관 계수와 서로 다른 모델 간 평가 간 Spearman 상관 계수가 0.78->0.73 정도로 큰 차이 없음)를 들어, 해당 모델이 충분히 변별력이 있다고 판단했습니다. """ input = tokenizer([text, text2], return_tensors='pt', truncation=True, padding=True, max_length=max_tokens) with torch.no_grad(): output = model(**input) mu = 4.0 * torch.sigmoid(output.logits[:, 0]) sigma = torch.sqrt(torch.exp(output.logits[:, 1].clamp(-5.0, 2.0))) # Pass, Non-Critical, Critical integrity_prob = torch.softmax(output.logits[:, 2:5], dim=-1) crit_prob = integrity_prob[:, 2] # if mu < 2.0, final_mu = mu. # else, final_mu = (1-crit_prob) * mu + crit_prob * 2.0 final_mu = mu - crit_prob * torch.relu(mu - 2.0) print(f"Value: {final_mu[0].item():.3f}±{sigma[0].item():.3f}") print(f"Value: {final_mu[1].item():.3f}±{sigma[1].item():.3f}") ``` ``` # 예상 출력 Value: 0.050±0.152 Value: 2.344±0.434 ``` ## 성능 **Validation (60K)** 512토큰 truncation | 점수 | Precision | Recall | F1 | Support | | --- | --- | --- | --- | --- | | 0 | 87.53 | 75.56 | 81.11 | 6,735 | | 1 | 85.79 | 87.25 | 86.52 | 27,932 | | 2 | 68.29 | 71.22 | 69.73 | 14,252 | | 3 | 66.76 | 64.30 | 65.51 | 7,830 | | 4 | 72.18 | 74.93 | 73.53 | 3,251 | | 합계 | - | macro-F1 | 75.28 | 60,000 | 2048토큰 truncation | 점수 | Precision | Recall | F1 | Support | | --- | --- | --- | --- | --- | | 0 | 87.63 | 76.39 | 81.63 | 6,735 | | 1 | 86.92 | 88.58 | 87.74 | 27,932 | | 2 | 72.43 | 73.95 | 73.18 | 14,252 | | 3 | 71.18 | 67.94 | 69.52 | 7,830 | | 4 | 73.30 | 82.01 | 77.41 | 3,251 | | 합계 | - | macro-F1 | 77.90 | 60,000 | **Test (4,096)** 512토큰 truncation | 점수 | F1 | Support | | --- | --- | --- | | 0 | 94.72 | 1,091 | | 1 | 68.84 | 720 | | 2 | 59.73 | 975 | | 3 | 52.77 | 647 | | 4 | 62.03 | 663 | | Macro-F1 | 67.62 | 4,096 | | 실제\예측 | 0 | 1 | 2 | 3 | 4 | | --- | --- | --- | --- | --- | --- | | 0 | 1005 | 85 | 0 | 1 | 0 | | 1 | 18 | 591 | 109 | 2 | 0 | | 2 | 7 | 260 | 597 | 95 | 3 | | 3 | 1 | 48 | 215 | 348 | 41 | | 4 | 0 | 13 | 116 | 220 | 321 | 2048토큰 truncation | 점수 | F1 | Support | | --- | --- | --- | | 0 | 95.24 | 1,091 | | 1 | 72.93 | 720 | | 2 | 66.84 | 975 | | 3 | 54.64 | 647 | | 4 | 71.37 | 663 | | Macro-F1 | 72.21 | 4,096 | | 실제\예측 | 0 | 1 | 2 | 3 | 4 | | --- | --- | --- | --- | --- | --- | | 0 | 1010 | 75 | 4 | 1 | 1 | | 1 | 18 | 578 | 118 | 6 | 0 | | 2 | 2 | 195 | 635 | 121 | 9 | | 3 | 0 | 14 | 146 | 362 | 131 | | 4 | 0 | 3 | 35 | 182 | 450 | **분산 활용** 1. 512토큰 truncation으로 1차 예측 2. 1차 예측에서 모델의 예측값이 하나의 점수 구간(0.5 미만 / 0.5-1.5 / 1.5-2.5 / 2.5-3.5 / 3.5 이상) 안에 들어갈 확률이 x% 미만인 경우 입력 토큰 길이를 늘려 2차 예측 ![image](https://cdn-uploads.huggingface.co/production/uploads/6629154d55d7c289634b8c5d/kaeUttGrKtNCVpd2GtSig.png) 이론 비용: 512토큰 예측 비용을 1로 두고, 토큰 길이가 n배가 되면 연산량이 n^2이 된다는 전제 하에 추정한 이론적 비용 예를 들어, **512 -> 1024, x = 50%**의 경우, 20.1% 데이터가 1차 예측만으로 라벨을 확정할 수 없어 1,024토큰 예측을 수행함. 예상 비용은 1.8배가 되고(20.1%에 대해 4배 비용 추가 예측), 대신 정확도는 69.87%->72.07%로 상승함. ## 학습 상세 퀄리티의 평균과 분산을 함께 예측하는 불확실성 모델링 + 파싱 에러를 판단하는 3-class classification - 학습 대상: 기반 모델의 마지막 6레이어 + regression head + variance head + 3-class classification head - 손실 함수: GaussianNLLLoss(regression) + CrossEntropyLoss(classification) - 학습률: 3e-5 for 6 layers, 3e-4 for heads - 배치 크기: 256 - 학습 데이터: 567,552 문서 (540K 문서 + 4점 데이터 upsampling) - epoch: 4 (8,868 steps) - sequence length: 512, 1024, 2048 (4:2:1 ratio) - 데이터 특이사항: 4점 데이터를 upsampling 하여 전체 데이터의 10% 이상이 되도록 조정(약 2배 upsampling) 1x 5090에서 약 8시간(0.5 epoch마다 validation에 소요된 총 3시간 포함)