Downloads · 30 days
6
13% of all-time downloads
bbanany/qwen25-3b-korean-pii-qlora2
qwen25-3b-korean-pii-qlora2 is a text generation model from bbanany. Use it when you need the model to write or continue text. It is set up for peft. The card lists the license as apache-2.0.
bbanany/qwen25-3b-korean-pii-qlora2는 문서 기반 RAG 응답에서 지정된 candidate span이 특정 자연인에게 연결되는 개인정보인지 판별하도록 Qwen/Qwen2.5-3B-Instruct를 QLoRA 방식으로 미세조정한 PEFT 어댑터입니다.
Downloads · 30 days
6
13% of all-time downloads
All-time downloads
47
Public
Repo size
131 MB
Likes
0
Public
Click a slice to open those files.
.safetensors120 MB · 88%
From the Hugging Face model README
bbanany/qwen25-3b-korean-pii-qlora2는 문서 기반 RAG 응답에서 지정된
candidate span이 특정 자연인에게 연결되는 개인정보인지 판별하도록
Qwen/Qwen2.5-3B-Instruct를 QLoRA 방식으로 미세조정한 PEFT 어댑터입니다.
모델은 반드시 다음 두 라벨 중 하나를 출력하도록 학습되었습니다.
PII: 해당 candidate 출현이 특정 자연인의 기록 또는 속성인 경우NOT_PII: 상품, 시스템, 법인, 프로젝트, 테스트 기준값 등 비인적 대상의 값인 경우Qwen/Qwen2.5-3B-Instructq_proj, k_proj, v_proj, o_proj, gate_proj, up_proj, down_proj이 저장소는 완전한 3B 모델 가중치가 아니라 LoRA 어댑터입니다. 추론 시
베이스 모델 Qwen/Qwen2.5-3B-Instruct가 별도로 필요합니다.
학습 데이터는 한국어 문서 및 RAG 응답 형태로 구성된 합성 데이터입니다.
대상 태그:
ACCOUNT_NUMBER, ADDRESS, AGE, BIRTHDATE, BLOOD_TYPE,
CARD_NUMBER, CITY, EMAIL, EMPLOYEE_ID, GENDER, HEIGHT,
IP_ADDRESS, MAJOR, NAME, NICKNAME, PHONE_NUMBER, POSITION,
RELIGION, WEIGHT, WORKPLACE
1e-4입력은 system 메시지와 JSON 문자열 형태의 user 메시지로 구성됩니다. start와
end는 answer 안에서 판정할 candidate의 정확한 문자 위치를 나타냅니다.
{
"answer": "김민수의 고객 원장에 연락처 010-1234-5678이 기록되어 있습니다.",
"candidate": {
"text": "010-1234-5678",
"tag": "PHONE_NUMBER",
"start": 16,
"end": 29
}
}
pip install -U torch transformers peft accelerate bitsandbytes
import torch
from peft import AutoPeftModelForCausalLM
from transformers import AutoTokenizer, BitsAndBytesConfig
model_id = "bbanany/qwen25-3b-korean-pii-qlora2"
quantization_config = BitsAndBytesConfig(
load_in_4bit=True,
bnb_4bit_quant_type="nf4",
bnb_4bit_use_double_quant=True,
bnb_4bit_compute_dtype=torch.bfloat16,
)
tokenizer = AutoTokenizer.from_pretrained(model_id)
model = AutoPeftModelForCausalLM.from_pretrained(
model_id,
quantization_config=quantization_config,
device_map="auto",
)
messages = [
{
"role": "system",
"content": (
"문서 기반 RAG 응답에서 지정된 candidate span이 특정 자연인에게 "
"연결되는 정보인지 판정하세요. 자연인의 기록이면 PII, 비인적 업무 "
"대상의 값이면 NOT_PII를 출력하세요. 반드시 두 라벨 중 하나만 출력하세요."
),
},
{
"role": "user",
"content": (
'{"answer":"김민수의 고객 원장에 연락처 010-1234-5678이 기록되어 있습니다.",'
'"candidate":{"text":"010-1234-5678","tag":"PHONE_NUMBER",'
'"start":16,"end":29}}'
),
},
]
text = tokenizer.apply_chat_template(
messages,
tokenize=False,
add_generation_prompt=True,
)
inputs = tokenizer(text, return_tensors="pt").to(model.device)
with torch.inference_mode():
output = model.generate(
**inputs,
max_new_tokens=8,
do_sample=False,
)
generated = output[0, inputs["input_ids"].shape[1]:]
print(tokenizer.decode(generated, skip_special_tokens=True).strip())
사람의 검토 없이 개인정보를 자동 공개하거나 삭제하는 최종 의사결정 용도로는 사용하지 않는 것을 권장합니다.
이 어댑터는 Apache License 2.0으로 공개됩니다. 베이스 모델 사용 시
Qwen/Qwen2.5-3B-Instruct의 라이선스와 이용 조건도 함께 확인해야 합니다.