Downloads · 30 days
43
68% of all-time downloads
querypieai/gemma4-12b-dlp-pii-lora
gemma4-12b-dlp-pii-lora is a text generation model from querypieai. 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.
This repository contains a LoRA adapter for PII detection. It is intended to be loaded on top of the full-precision google/gemma-4-12B-it base model. The adapter returns exact source-text quotes and one of 21 canonica…
Downloads · 30 days
43
68% of all-time downloads
All-time downloads
63
Public
Repo size
43.8 MB
Likes
0
Public
Click a slice to open those files.
.safetensors43.8 MB · 100%
From the Hugging Face model README
This repository contains a LoRA adapter for PII detection. It is intended to be loaded on top of the full-precision google/gemma-4-12B-it base model. The adapter returns exact source-text quotes and one of 21 canonical PII types in a compact JSON object.
이 저장소는 개인정보(PII) 탐지를 위한 LoRA 어댑터를 포함합니다. 이 어댑터는 비양자화 BF16 기반의 google/gemma-4-12B-it 베이스 모델 위에 로드해야 하며, 원본 텍스트에서 정확히 복사한 quote와 21종의 정형 InfoType만을 compact JSON으로 반환합니다.
모델의 학습 및 평가 대상 언어는 한국어와 영어입니다. 이 한국어 섹션은 설명을 위한 번역이며, 모델이 일본어 입력을 지원한다는 의미가 아닙니다.
google/gemma-4-12B-it707f0a3b8a3c7ad586ed01e27eafbad8a27dd0f7모델은 아래 형식 외의 필드를 반환하지 않습니다. info_type과 quote만 사용하며, offset, likelihood, 설명, 마크다운, 코드펜스를 포함하지 않습니다.
{"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를 그대로 사용해야 합니다.
이 어댑터는 DLP 검토, 마스킹·비식별화 지원, 오프라인 개인정보 탐지 실험에 사용할 수 있습니다. 일반 대화, 창작, 요약, 법률 자문, 자동 차단·삭제·공개 결정에는 사용하지 마세요. 사람의 검토 없이 보안·프라이버시·컴플라이언스 판단을 자동화하는 용도로 사용해서는 안 됩니다.
내부 QueryPie DLP 데이터를 사용했으며, 학습 데이터 자체는 이 저장소에 포함하지 않았습니다.
독립 테스트 세트 결과는 다음과 같습니다. 체크포인트 선택에는 validation만 사용했고, 테스트 세트는 선택에 사용하지 않았습니다.
| 실행 환경 | Precision | Recall | F1 |
|---|---|---|---|
| BF16 | 0.9627 | 0.8928 | 0.9264 |
| LLM.int8 | 0.9703 | 0.8791 | 0.9224 |
추가 지표:
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 결과를 재현하려면 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 가중치를 직렬화한 파일을 재사용한 결과이므로 저장 없이 새로 로드하면 약간 다를 수 있습니다.
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 の google/gemma-4-12B-it ベースモデルの上にロードして使用します。モデルは、原文から正確にコピーした引用と、21種類の正規 InfoType のみを compact JSON として返します。
モデルの学習および評価対象言語は韓国語と英語です。この日本語セクションは説明のための翻訳であり、日本語入力への対応を意味しません。
google/gemma-4-12B-it707f0a3b8a3c7ad586ed01e27eafbad8a27dd0f7モデルは次の形式以外のフィールドを返しません。info_type と quote のみを使用し、offset、likelihood、説明、Markdown、コードフェンスを含みません。
{"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 をそのまま使用してください。
このアダプターは、DLP レビュー、マスキング・非識別化の支援、オフラインでの個人情報検出実験に利用できます。一般的な対話、創作、要約、法的助言、ブロック・削除・公開の自動判断には使用しないでください。人の確認なしにセキュリティ、プライバシー、コンプライアンス上の判断を自動化する用途にも使用できません。
QueryPie の内部 DLP データを使用しました。学習データ自体はこのリポジトリに含めていません。
独立テストセットの結果は次のとおりです。チェックポイント選択には検証セットのみを使用し、テストセットは選択に使用していません。
| 実行環境 | Precision | Recall | F1 |
|---|---|---|---|
| BF16 | 0.9627 | 0.8928 | 0.9264 |
| LLM.int8 | 0.9703 | 0.8791 | 0.9224 |
追加指標:
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の結果を再現するには、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重みを直列化したファイルを再利用した結果であるため、保存せずに新しくロードした場合はわずかに異なる可能性があります。
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",
)
707f0a3b8a3c7ad586ed01e27eafbad8a27dd0f7Use this adapter to inspect user-supplied text and return supported PII values as:
{"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.
The base model is not bundled with this adapter. Users must have access to google/gemma-4-12B-it.
import json
import torch
from transformers import AutoProcessor, AutoModelForImageTextToText
from peft import PeftModel
base_model_id = "google/gemma-4-12B-it"
base_model_revision = "707f0a3b8a3c7ad586ed01e27eafbad8a27dd0f7"
adapter_id = "querypieai/gemma4-12b-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.
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.
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",
)
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.
The adapter was trained on an internal QueryPie DLP dataset containing Korean and English examples. The data was not uploaded with this adapter.
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.
This adapter was initialized from a prior BF16-trained QueryPie DLP adapter and then further trained for the quote-and-type output format.
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.
| Runtime | Precision | Recall | F1 |
|---|---|---|---|
| BF16 | 0.9627 | 0.8928 | 0.9264 |
| LLM.int8 | 0.9703 | 0.8791 | 0.9224 |
Additional metrics:
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.
Training was performed on remote accelerator infrastructure. Hardware-specific energy and emissions figures were not recorded.
No publication is associated with this adapter.