CoolFace
Modelpublic

querypieai/qwen3.5-9b-dlp-pii-lora

sourceHugging Faceapache-2.0updated 11d agoView on Hugging Face
0likes24downloads
Model Card

QueryPie DLP PII Detector — Qwen3.5-9B LoRA

This repository contains a LoRA adapter for PII detection. It is intended to be loaded on top of the full-precision Qwen/Qwen3.5-9B base model. The adapter returns exact source-text quotes and one of 21 canonical PII types in a compact JSON object.

Language Navigation

한국어 안내

이 저장소는 개인정보(PII) 탐지를 위한 LoRA 어댑터를 포함합니다. 이 어댑터는 비양자화 BF16 기반의 Qwen/Qwen3.5-9B 베이스 모델 위에 로드해야 하며, 원본 텍스트에서 정확히 복사한 quote와 21종의 정형 InfoType만을 compact JSON으로 반환합니다.

모델의 학습 및 평가 대상 언어는 한국어와 영어입니다. 이 한국어 섹션은 설명을 위한 번역이며, 모델이 일본어 입력을 지원한다는 의미가 아닙니다.

주요 정보

  • —개발사: QueryPie
  • —모델 유형: 개인정보 추출용 PEFT LoRA 어댑터
  • —지원 언어: 한국어, 영어
  • —라이선스: Apache-2.0
  • —베이스 모델: Qwen/Qwen3.5-9B
  • —학습에 사용한 베이스 revision: c202236235762e1c871ad0ccb60c8ee5ba337b9a
  • —기반 정밀도: BF16, LoRA는 FP32
  • —LoRA 설정: rank 16, alpha 128, dropout 0.05, 62개 언어 모델 projection 모듈
  • —선택된 체크포인트: 800 micro-step 학습 중 micro step 200

응답 형식과 InfoType

모델은 아래 형식 외의 필드를 반환하지 않습니다. info_type과 quote만 사용하며, offset, likelihood, 설명, 마크다운, 코드펜스를 포함하지 않습니다.

json
{"findings":[{"info_type":"CANONICAL_TYPE","quote":"정확한 원본 텍스트"}]}

지원하는 21종 InfoType은 다음과 같습니다.

AGE, API_KEY, AUTH_TOKEN, BLOOD_TYPE, CREDIT_CARD_NUMBER, DATE_OF_BIRTH, DEVICE_ID, DRIVERS_LICENSE_NUMBER, EMAIL_ADDRESS, FINANCIAL_ACCOUNT_NUMBER, GOVERNMENT_ID, IBAN_CODE, IP_ADDRESS, MAC_ADDRESS, MEDICAL_RECORD_NUMBER, PASSPORT, PASSWORD, PERSON_NAME, PHONE_NUMBER, STREET_ADDRESS, VEHICLE_IDENTIFICATION_NUMBER

각 InfoType의 정확한 정의, 원문 quote 복사 규칙, 빈 결과 처리 규칙은 저장소의 system_prompt.txt를 그대로 사용해야 합니다. Qwen 추론에서는 thinking mode를 비활성화해야 학습 및 평가 조건과 일치합니다.

사용 목적과 범위 밖 사용

이 어댑터는 DLP 검토, 마스킹·비식별화 지원, 오프라인 개인정보 탐지 실험에 사용할 수 있습니다. 일반 대화, 창작, 요약, 법률 자문, 자동 차단·삭제·공개 결정에는 사용하지 마세요. 사람의 검토 없이 보안·프라이버시·컴플라이언스 판단을 자동화하는 용도로 사용해서는 안 됩니다.

학습 데이터와 성능

내부 QueryPie DLP 데이터를 사용했으며, 학습 데이터 자체는 이 저장소에 포함하지 않았습니다.

  • —학습 예시: 8,604
  • —전체 validation 예시: 3,165
  • —체크포인트 선택 validation 예시: 600
  • —독립 테스트 문서: 3,167
  • —독립 테스트 reference findings: 1,968

독립 테스트 세트 결과는 다음과 같습니다. 체크포인트 선택에는 validation만 사용했고, 테스트 세트는 선택에 사용하지 않았습니다.

실행 환경PrecisionRecallF1
BF160.82730.78860.8075
LLM.int80.81290.77690.7945

추가 지표:

  • —BF16 TP/FP/FN: 1,552 / 324 / 416
  • —LLM.int8 TP/FP/FN: 1,529 / 352 / 439

8bit 결과는 bitsandbytes LLM.int8로 평가했습니다. load_in_8bit=true, outlier threshold 6.0, FP32 CPU offload 비활성화를 사용했고, lm_head와 visual/vision/audio 모듈은 양자화에서 제외했습니다. 어댑터는 8bit 베이스에 맞춰 새로 학습한 것이 아니라 BF16 학습 어댑터를 동일하게 재사용한 결과입니다.

베이스 모델 업데이트 정책

위 성능은 명시된 베이스 모델 revision에서 측정된 값입니다. 재현이 필요하거나 운영 안정성이 중요한 배포에서는 해당 revision을 고정하세요. 새로운 베이스 revision은 이 어댑터와 자동으로 호환되거나 검증된 것으로 간주하지 않습니다. 베이스를 변경하기 전에 smoke test, 체크포인트 선택 validation, 독립 regression test를 다시 실행해야 하며, 새 revision이 기준을 통과할 때까지 기존 검증 revision을 유지하는 것이 안전합니다.

8bit 추론 가이드

8bit 결과를 재현하려면 BF16 가이드 대신 아래 BitsAndBytesConfig를 사용하세요. 평가 환경은 PyTorch 2.11.0+cu128, Transformers 5.16.1, PEFT 0.20.0, bitsandbytes 0.50.2, Accelerate 1.14.0이었습니다. GPU에서 CUDA가 사용 가능해야 하고, 8bit 가중치를 직렬화한 파일을 재사용한 결과이므로 저장 없이 새로 로드하면 약간 다를 수 있습니다.

python
from transformers import BitsAndBytesConfig

quantization_config = BitsAndBytesConfig(
    load_in_8bit=True,
    llm_int8_threshold=6.0,
    llm_int8_skip_modules=[
        "lm_head",
        "model.visual",
        "model.vision_tower",
        "model.audio_tower",
    ],
    llm_int8_enable_fp32_cpu_offload=False,
    llm_int8_has_fp16_weight=False,
)

model = AutoModelForImageTextToText.from_pretrained(
    base_model_id,
    revision=base_model_revision,
    quantization_config=quantization_config,
    device_map="auto",
)

日本語ガイド

このリポジトリには、個人情報(PII)検出のための LoRA アダプターが含まれます。このアダプターは、非量子化 BF16 の Qwen/Qwen3.5-9B ベースモデルの上にロードして使用します。モデルは、原文から正確にコピーした引用と、21種類の正規 InfoType のみを compact JSON として返します。

モデルの学習および評価対象言語は韓国語と英語です。この日本語セクションは説明のための翻訳であり、日本語入力への対応を意味しません。

主な情報

  • —開発組織: QueryPie
  • —モデル種別: 個人情報抽出用 PEFT LoRA アダプター
  • —対応言語: 韓国語、英語
  • —ライセンス: Apache-2.0
  • —ベースモデル: Qwen/Qwen3.5-9B
  • —学習に使用したベース revision: c202236235762e1c871ad0ccb60c8ee5ba337b9a
  • —ベース精度: BF16、LoRAはFP32
  • —LoRA設定: rank 16、alpha 128、dropout 0.05、62個の言語モデル projection モジュール
  • —選択されたチェックポイント: 800 micro-step の学習のうち micro step 200

応答形式と InfoType

モデルは次の形式以外のフィールドを返しません。info_type と quote のみを使用し、offset、likelihood、説明、Markdown、コードフェンスを含みません。

json
{"findings":[{"info_type":"CANONICAL_TYPE","quote":"原文の正確なテキスト"}]}

対応する21種類の InfoType は次のとおりです。

AGE, API_KEY, AUTH_TOKEN, BLOOD_TYPE, CREDIT_CARD_NUMBER, DATE_OF_BIRTH, DEVICE_ID, DRIVERS_LICENSE_NUMBER, EMAIL_ADDRESS, FINANCIAL_ACCOUNT_NUMBER, GOVERNMENT_ID, IBAN_CODE, IP_ADDRESS, MAC_ADDRESS, MEDICAL_RECORD_NUMBER, PASSPORT, PASSWORD, PERSON_NAME, PHONE_NUMBER, STREET_ADDRESS, VEHICLE_IDENTIFICATION_NUMBER

各 InfoType の正確な定義、原文引用のコピー規則、空の結果の扱いについては、リポジトリ内の system_prompt.txt をそのまま使用してください。Qwen の推論では、学習・評価条件と一致させるために thinking mode を無効化する必要があります。

利用目的と範囲外の利用

このアダプターは、DLP レビュー、マスキング・非識別化の支援、オフラインでの個人情報検出実験に利用できます。一般的な対話、創作、要約、法的助言、ブロック・削除・公開の自動判断には使用しないでください。人の確認なしにセキュリティ、プライバシー、コンプライアンス上の判断を自動化する用途にも使用できません。

学習データと性能

QueryPie の内部 DLP データを使用しました。学習データ自体はこのリポジトリに含めていません。

  • —学習例: 8,604
  • —検証全体の例: 3,165
  • —チェックポイント選択用検証例: 600
  • —独立テスト文書: 3,167
  • —独立テスト reference findings: 1,968

独立テストセットの結果は次のとおりです。チェックポイント選択には検証セットのみを使用し、テストセットは選択に使用していません。

実行環境PrecisionRecallF1
BF160.82730.78860.8075
LLM.int80.81290.77690.7945

追加指標:

  • —BF16 TP/FP/FN: 1,552 / 324 / 416
  • —LLM.int8 TP/FP/FN: 1,529 / 352 / 439

8bitの結果は、bitsandbytes LLM.int8で評価しました。load_in_8bit=true、outlier threshold 6.0、FP32 CPU offload無効を使用し、lm_headおよび visual/vision/audio モジュールは量子化から除外しました。アダプターは8bitベース向けに新しく学習したものではなく、BF16学習アダプターをそのまま再利用した結果です。

ベースモデル更新ポリシー

上記の性能は、明示されたベースモデル revision で測定された値です。再現性が必要な場合や運用の安定性が重要な展開では、その revision を固定してください。新しいベース revision は、このアダプターと自動的に互換性がある、または検証済みであるとみなされません。ベースを変更する前には、smoke test、チェックポイント選択用検証、独立 regression test を再実行してください。新しい revision が受け入れ基準を満たすまで、以前に検証した revision を保持することが安全です。

8bit 推論ガイド

8bitの結果を再現するには、BF16ガイドの代わりに次の BitsAndBytesConfig を使用してください。評価環境は PyTorch 2.11.0+cu128、Transformers 5.16.1、PEFT 0.20.0、bitsandbytes 0.50.2、Accelerate 1.14.0 でした。GPUで CUDA が利用可能である必要があります。8bit重みを直列化したファイルを再利用した結果であるため、保存せずに新しくロードした場合はわずかに異なる可能性があります。

python
from transformers import BitsAndBytesConfig

quantization_config = BitsAndBytesConfig(
    load_in_8bit=True,
    llm_int8_threshold=6.0,
    llm_int8_skip_modules=[
        "lm_head",
        "model.visual",
        "model.vision_tower",
        "model.audio_tower",
    ],
    llm_int8_enable_fp32_cpu_offload=False,
    llm_int8_has_fp16_weight=False,
)

model = AutoModelForImageTextToText.from_pretrained(
    base_model_id,
    revision=base_model_revision,
    quantization_config=quantization_config,
    device_map="auto",
)

Model Details

  • —Developed by: QueryPie
  • —Model type: PEFT LoRA adapter for privacy information extraction
  • —Languages: Korean, English
  • —License: Apache-2.0
  • —Base model: Qwen/Qwen3.5-9B
  • —Base revision used for training: c202236235762e1c871ad0ccb60c8ee5ba337b9a

Intended Use

Use this adapter to inspect user-supplied text and return supported PII values as:

json
{"findings":[{"info_type":"CANONICAL_TYPE","quote":"exact source text"}]}

The model detects these 21 canonical types:

AGE, API_KEY, AUTH_TOKEN, BLOOD_TYPE, CREDIT_CARD_NUMBER, DATE_OF_BIRTH, DEVICE_ID, DRIVERS_LICENSE_NUMBER, EMAIL_ADDRESS, FINANCIAL_ACCOUNT_NUMBER, GOVERNMENT_ID, IBAN_CODE, IP_ADDRESS, MAC_ADDRESS, MEDICAL_RECORD_NUMBER, PASSPORT, PASSWORD, PERSON_NAME, PHONE_NUMBER, STREET_ADDRESS, and VEHICLE_IDENTIFICATION_NUMBER.

This adapter is not a general-purpose chat model. It is intended for DLP review, redaction assistance, and offline privacy-detection experiments.

Out of Scope

  • —Production decisions about blocking, deleting, or disclosing data without human review
  • —Legal or compliance determinations
  • —Detection of PII types outside the 21 supported canonical labels
  • —Re-identification or enrichment of personal data
  • —Use in a way that conflicts with the Qwen base-model license

Loading and Inference

The base model is not bundled with this adapter. Users must have access to Qwen/Qwen3.5-9B.

python
import json
import torch
from transformers import AutoProcessor, AutoModelForImageTextToText
from peft import PeftModel

base_model_id = "Qwen/Qwen3.5-9B"
base_model_revision = "c202236235762e1c871ad0ccb60c8ee5ba337b9a"
adapter_id = "querypieai/qwen3.5-9b-dlp-pii-lora"
system_prompt = open("system_prompt.txt", encoding="utf-8").read()

model = AutoModelForImageTextToText.from_pretrained(
    base_model_id,
    revision=base_model_revision,
    torch_dtype=torch.bfloat16,
    device_map="auto",
)
model = PeftModel.from_pretrained(model, adapter_id)
model.eval()

processor = AutoProcessor.from_pretrained(base_model_id, revision=base_model_revision)
messages = [
    {"role": "system", "content": [{"type": "text", "text": system_prompt}]},
    {"role": "user", "content": [{"type": "text", "text": "Your input text goes here."}]},
]
inputs = processor.apply_chat_template(
    messages,
    add_generation_prompt=True,
    tokenize=True,
    return_dict=True,
    return_tensors="pt",
).to(model.device)

with torch.inference_mode():
    output = model.generate(**inputs, max_new_tokens=384)

generated = output[0][inputs["input_ids"].shape[1]:]
response = processor.decode(generated, skip_special_tokens=True)
print(json.dumps(json.loads(response), ensure_ascii=False, indent=2))

Use the exact system_prompt.txt provided in this repository. Qwen thinking mode must be disabled in the chat template used for evaluation.

LLM.int8 Inference

To reproduce the LLM.int8 result, use the following BitsAndBytesConfig instead of the BF16 loading example. The evaluation environment used PyTorch 2.11.0+cu128, Transformers 5.16.1, PEFT 0.20.0, bitsandbytes 0.50.2, and Accelerate 1.14.0. CUDA must be available on the GPU. The reported result reused serialized 8bit weights; loading and quantizing weights freshly may produce a slightly different result.

python
from transformers import BitsAndBytesConfig

quantization_config = BitsAndBytesConfig(
    load_in_8bit=True,
    llm_int8_threshold=6.0,
    llm_int8_skip_modules=[
        "lm_head",
        "model.visual",
        "model.vision_tower",
        "model.audio_tower",
    ],
    llm_int8_enable_fp32_cpu_offload=False,
    llm_int8_has_fp16_weight=False,
)

model = AutoModelForImageTextToText.from_pretrained(
    base_model_id,
    revision=base_model_revision,
    quantization_config=quantization_config,
    device_map="auto",
)

Base Model Update Policy

The reported metrics were produced with the base-model commit listed above. Pin that revision for reproduction and for production rollouts where behavior stability is required.

The adapter expects the same model ID and compatible architecture. A newer base-model revision is not automatically validated with this adapter. Before moving to a newer revision, rerun the smoke test, the selection validation set, and an independent regression test. Keep the previously validated base-model revision available until the new revision passes acceptance criteria.

Training Data

The adapter was trained on an internal QueryPie DLP dataset containing Korean and English examples. The data was not uploaded with this adapter.

  • —Training examples: 8,604
  • —Full validation examples: 3,165
  • —Selection validation examples: 600
  • —Independent test documents: 3,167
  • —Selection validation reference findings: 605
  • —Independent test reference findings: 1,968

The data represents query logs, conversation-like text, documents, and synthetic PII examples. No claim is made that it is representative of all production traffic or jurisdictions.

Training Procedure

  • —Base precision: BF16
  • —LoRA precision: FP32
  • —LoRA type: PEFT LoRA
  • —Rank: 16
  • —Alpha: 128
  • —Dropout: 0.05
  • —Target modules: 62 language-model projection modules
  • —Learning rate: 2e-6
  • —Micro iterations: 800
  • —Selected micro step: 200
  • —Maximum sequence length: 2,048
  • —Optimizer: AdamW
  • —Checkpoint selection: best micro F1 on the 600-example selection validation set

This adapter was initialized from a prior BF16-trained QueryPie DLP adapter and then further trained for the quote-and-type output format.

Evaluation

Evaluation used the exact system prompt, strict JSON output, exact-quote matching, and canonical type matching. The independent test set was not used for checkpoint selection.

RuntimePrecisionRecallF1
BF160.82730.78860.8075
LLM.int80.81290.77690.7945

Additional metrics:

  • —Test documents: 3,167
  • —Reference findings: 1,968
  • —BF16 TP/FP/FN: 1,552 / 324 / 416
  • —LLM.int8 TP/FP/FN: 1,529 / 352 / 439

The LLM.int8 result was evaluated with bitsandbytes using load_in_8bit=true, an outlier threshold of 6.0, FP32 CPU offload disabled, and lm_head plus visual/vision/audio modules excluded from quantization. The same BF16-trained adapter was reused on the LLM.int8 base; it was not separately trained for 8bit inference.

Bias, Risks, and Limitations

  • —PII detection can produce false positives and false negatives.
  • —Performance may differ by language, domain, formatting, generation parameters, and base-model revision.
  • —Newer base-model revisions are not automatically compatible or validated.
  • —The model should not be the sole control for privacy, security, legal, or compliance decisions.
  • —Base-model access and licensing requirements remain applicable.
  • —Users should validate performance on their own data before operational use.

Environmental Impact

Training was performed on remote accelerator infrastructure. Hardware-specific energy and emissions figures were not recorded.

Citation

No publication is associated with this adapter.