Downloads · 30 days
10
14% of all-time downloads
ichetandhembre/Qwen3-4B-Instruct-2507-PII-SFT-LoRA
Qwen3-4B-Instruct-2507-PII-SFT-LoRA is a machine learning model from ichetandhembre. Use it for the machine learning task on the model card, and read the license before you ship it in a product. It is set up for peft. The card lists the license as apache-2.0.
LoRA adapter that fine-tunes Qwen/Qwen3-4B-Instruct-2507 to detect personally identifiable information (PII) in text, replace it with [PII] tags, and return the masked text wrapped in <maskedoutput...</maskedoutput.
Downloads · 30 days
10
14% of all-time downloads
All-time downloads
70
Public
Repo size
77.5 MB
Likes
0
Public
Click a slice to open those files.
.safetensors66.1 MB · 85%
From the Hugging Face model README
LoRA adapter that fine-tunes Qwen/Qwen3-4B-Instruct-2507
to detect personally identifiable information (PII) in text, replace it with [PII] tags, and
return the masked text wrapped in <masked_output>...</masked_output>.
Greedy exact-match on a 5,914-row held-out split (provably disjoint from training by input):
| Model | Exact-match | Relaxed-match | mean_reward* |
|---|---|---|---|
| Base Qwen3-4B-Instruct-2507 | 0.409 | 0.577 | 0.472 |
| This adapter (SFT) | 0.932 | 0.976 | 0.939 |
*mean_reward is the normalized reward (exact·1.0 + pii_count·0.5 + format·0.1) / 1.6 (max 1.0).
The Prime Intellect verifier for this task reports the same three components un-normalized
(max 1.6), so e.g. a Prime reward of ~1.50 corresponds to ~0.94 here.
Format compliance is already ~1.00 on the base model; the adapter's gain is almost entirely
learning the exact [PII] segmentation convention (it cuts the relaxed-minus-exact gap from
0.168 to 0.045).
AdamLucek/open-pii-masking-en-us-30k (train split).The published adapter was extracted from the merged SFT checkpoint by a per-layer rank-8 SVD of
(W_merged − W_base). Base + this adapter reproduces the merged model's held-out exact-match to
within bf16 rounding (0.9319 vs 0.9325).
from peft import PeftModel
from transformers import AutoModelForCausalLM, AutoTokenizer
base = AutoModelForCausalLM.from_pretrained(
"Qwen/Qwen3-4B-Instruct-2507", torch_dtype="bfloat16", device_map="auto")
model = PeftModel.from_pretrained(base, "ichetandhembre/Qwen3-4B-Instruct-2507-PII-SFT-LoRA")
tok = AutoTokenizer.from_pretrained("Qwen/Qwen3-4B-Instruct-2507")
SYSTEM = ("Replace all personally identifiable information (PII) in the text with [PII] tags. "
"PII includes: names, dates, phone numbers, SSNs, account numbers, addresses, "
"email addresses. Wrap the masked text in <masked_output>...</masked_output>.")
msgs = [{"role": "system", "content": SYSTEM},
{"role": "user", "content": "Hi, this is John Smith, call me at 555-0123."}]
ids = tok.apply_chat_template(msgs, add_generation_prompt=True, return_tensors="pt").to(model.device)
print(tok.decode(model.generate(ids, max_new_tokens=384, do_sample=False)[0][ids.shape[1]:],
skip_special_tokens=True))
Or serve base + adapter with vLLM (enable_lora=True, max_lora_rank>=8).