Instructions to use limbo23/holdback-student with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use limbo23/holdback-student with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("token-classification", model="limbo23/holdback-student")# pip install -U transformers accelerate # Load model directly from transformers import AutoTokenizer, AutoModelForTokenClassification tokenizer = AutoTokenizer.from_pretrained("limbo23/holdback-student") model = AutoModelForTokenClassification.from_pretrained("limbo23/holdback-student", device_map="auto") - Notebooks
- Google Colab
- Kaggle
holdback student detector
Browse files- README.md +106 -0
- config.json +68 -0
- model.safetensors +3 -0
- tokenizer.json +0 -0
- tokenizer_config.json +15 -0
README.md
ADDED
|
@@ -0,0 +1,106 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
license: apache-2.0
|
| 3 |
+
language: [en, zh, de, fr, es, it, pt, nl]
|
| 4 |
+
library_name: transformers
|
| 5 |
+
pipeline_tag: token-classification
|
| 6 |
+
base_model: intfloat/multilingual-e5-small
|
| 7 |
+
datasets: [nvidia/Nemotron-PII, asgdaudahu/pii-bench-zh]
|
| 8 |
+
tags: [pii, secrets, redaction, privacy, distillation]
|
| 9 |
+
widget:
|
| 10 |
+
- text: "Ask Maria Gonzalez at maria.gonzalez@example.com or +1 415 555 0198 before you rotate the staging password Tr0ub4dor&3."
|
| 11 |
+
- text: "请联系张伟,电话 13812345678,邮箱 zhang.wei@example.com。"
|
| 12 |
+
---
|
| 13 |
+
|
| 14 |
+
# holdback student detector
|
| 15 |
+
|
| 16 |
+
A token classifier that finds personal data and secrets in what coding agents send to cloud models. It is the
|
| 17 |
+
distilled replacement for OpenAI's Privacy Filter (a 1.5B-parameter mixture of experts) in
|
| 18 |
+
[holdback](https://github.com/Daveyuwang/holdback), a local proxy and Claude Code hook that replaces private values
|
| 19 |
+
with placeholders before a request leaves the machine.
|
| 20 |
+
|
| 21 |
+
6 layers, hidden size 384, 28.2M parameters, a 45,252-piece vocabulary pruned from multilingual-e5-small, and the
|
| 22 |
+
Privacy Filter's eight categories (account_number, private_address, private_date, private_email, private_person,
|
| 23 |
+
private_phone, private_url, secret) as BIO tags.
|
| 24 |
+
|
| 25 |
+
## Use with holdback
|
| 26 |
+
|
| 27 |
+
holdback 0.1.1 and later run this model natively, followed by holdback's structure rules:
|
| 28 |
+
|
| 29 |
+
```bash
|
| 30 |
+
hf download limbo23/holdback-student --local-dir ~/.cache/holdback/student
|
| 31 |
+
HOLDBACK_STUDENT_DIR=~/.cache/holdback/student holdback run claude
|
| 32 |
+
```
|
| 33 |
+
|
| 34 |
+
For hook mode, put `HOLDBACK_STUDENT_DIR` with the folder's absolute path in the `env` block of Claude Code's
|
| 35 |
+
settings, then stop the running local process (`pkill -f "holdback serve"`) so that the next session starts it with
|
| 36 |
+
this model. `holdback doctor` shows which detector runs.
|
| 37 |
+
|
| 38 |
+
## Use from Python
|
| 39 |
+
|
| 40 |
+
```python
|
| 41 |
+
from transformers import pipeline
|
| 42 |
+
|
| 43 |
+
detect = pipeline("token-classification", model="limbo23/holdback-student", aggregation_strategy="simple")
|
| 44 |
+
detect("Ask Maria Gonzalez at maria.gonzalez@example.com")
|
| 45 |
+
```
|
| 46 |
+
|
| 47 |
+
The model was trained on windows of up to 254 tokens. Split longer text first, as holdback does: at a line break,
|
| 48 |
+
else a separator such as a comma, else a space. The results below include holdback's rules, which keep hosts, ports,
|
| 49 |
+
paths, dates and IDs that the model alone would replace.
|
| 50 |
+
|
| 51 |
+
## Results
|
| 52 |
+
|
| 53 |
+
Leaked labeled values and false-positive characters, both detectors followed by holdback's rules. The lockbox sets
|
| 54 |
+
were held back until the model was chosen and scored once.
|
| 55 |
+
|
| 56 |
+
| Test | Privacy Filter | This model |
|
| 57 |
+
| --- | ---: | ---: |
|
| 58 |
+
| PrivacyBench, persona never trained on | 9.7% / 0.6% | 0.8% / 0.6% |
|
| 59 |
+
| PrivacyBench, three more personas (lockbox) | 18.8% / 0.3% | 3.2% / 0.4% |
|
| 60 |
+
| ai4privacy EN validation, a dataset never trained on | 12.7% / 11.1% | 6.0% / 10.8% |
|
| 61 |
+
| CredData, credentials from files never sampled before (lockbox) | 19.8% / 6.1% | 20.2% / 4.8% |
|
| 62 |
+
| holdback's generated agent tasks (seeds 7 and 11), values leaked of 288 and tasks broken of 186 | 1 and 0; 6 and 6 | 0 and 0; 6 and 6 |
|
| 63 |
+
| Developer text, false replacements per 100 KB (tuning, held-out) | 4, 0 | 4, 2 |
|
| 64 |
+
| Claude Code sessions on 9 public crates, 45 tasks, hook mode | 45/45 | 45/45, no planted value sent |
|
| 65 |
+
| Chinese names in news, MSRA NER test odd rows, 1,301 names (evaluation only) | 67.3% / 0.6% | 13.1% / 1.4% |
|
| 66 |
+
| 30 Chinese developer requests written for this check, 10 values | 2 of 10 / 0.8% | 0 of 10 / 0.6% |
|
| 67 |
+
|
| 68 |
+
Speed and memory in holdback 0.1.1 on an Apple M5 CPU, for inputs of 16, 128, 2,048 and 8,192 tokens as the
|
| 69 |
+
Privacy Filter's tokenizer counts them: labeling takes 1.8, 7.5, 65 and 261 ms (Privacy Filter: 24.5, 87, 512 and
|
| 70 |
+
1,856 ms), medians of three alternating rounds on an idle machine. A fresh process peaks at 76 MB of memory for 16
|
| 71 |
+
tokens and 190 MB for 8,192 (Privacy Filter: 83 and 146 MB).
|
| 72 |
+
|
| 73 |
+
## Training
|
| 74 |
+
|
| 75 |
+
Labels on natural text: Privacy Filter's spans plus the dataset's own labels where the teacher found nothing on the
|
| 76 |
+
public sets; only planted values on developer text. Constructed rows with exact labels: lockfile and checksum text,
|
| 77 |
+
code and config snippets where values of the same shape are secrets under secret names and plain under other names,
|
| 78 |
+
generated agent output (logs, cluster and CI output, chat, payments, configs), and secrets as source code writes them.
|
| 79 |
+
|
| 80 |
+
| Source | License |
|
| 81 |
+
| --- | --- |
|
| 82 |
+
| intfloat/multilingual-e5-small, the starting weights (6 of its 12 layers) | MIT |
|
| 83 |
+
| nvidia/Nemotron-PII, 16,000 training rows | CC BY 4.0, NVIDIA |
|
| 84 |
+
| asgdaudahu/pii-bench-zh, rows 1,000 to 6,999 | Apache-2.0 |
|
| 85 |
+
| Teacher labels from openai/privacy-filter | Apache-2.0 |
|
| 86 |
+
| Source of public Rust crates and Python packages, as unlabeled developer text | the packages' own licenses |
|
| 87 |
+
| Lockfiles of public crates and git object listings of three public repositories (ripgrep, serde, fd) | the projects' own licenses |
|
| 88 |
+
| Chinese documentation of ant-design, vant, ahooks and umi, with planted values and filtered teacher labels | MIT |
|
| 89 |
+
| Generated rows (Faker values) | |
|
| 90 |
+
|
| 91 |
+
ai4privacy/pii-masking-400k is not in the training data: its license allows academic and non-commercial use only.
|
| 92 |
+
|
| 93 |
+
## Limits
|
| 94 |
+
|
| 95 |
+
- Secrets in code are found about as often as by Privacy Filter, not more often; UUIDs are kept by holdback's
|
| 96 |
+
policy and count as leaks in CredData.
|
| 97 |
+
- In Chinese it finds far more names than Privacy Filter and sometimes takes a common word for a name (0.6% of
|
| 98 |
+
characters in developer requests, 1.4% in news, against 0.8% and 0.6%). Natural Chinese text from MIT-licensed
|
| 99 |
+
documentation fixed most of this; generated Chinese sentences alone did not carry over to new text.
|
| 100 |
+
- Scripts beyond the training data fall back to single-character pieces.
|
| 101 |
+
- One training seed; on PrivacyBench, seeds of the same recipe differ by about 1.5 points.
|
| 102 |
+
|
| 103 |
+
## License
|
| 104 |
+
|
| 105 |
+
Apache-2.0. The sources above keep their own licenses; Nemotron-PII is used under CC BY 4.0 with attribution to
|
| 106 |
+
NVIDIA.
|
config.json
ADDED
|
@@ -0,0 +1,68 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"add_cross_attention": false,
|
| 3 |
+
"architectures": [
|
| 4 |
+
"BertForTokenClassification"
|
| 5 |
+
],
|
| 6 |
+
"attention_probs_dropout_prob": 0.1,
|
| 7 |
+
"bos_token_id": null,
|
| 8 |
+
"classifier_dropout": null,
|
| 9 |
+
"dtype": "float32",
|
| 10 |
+
"eos_token_id": null,
|
| 11 |
+
"hidden_act": "gelu",
|
| 12 |
+
"hidden_dropout_prob": 0.1,
|
| 13 |
+
"hidden_size": 384,
|
| 14 |
+
"id2label": {
|
| 15 |
+
"0": "O",
|
| 16 |
+
"1": "B-account_number",
|
| 17 |
+
"2": "I-account_number",
|
| 18 |
+
"3": "B-private_address",
|
| 19 |
+
"4": "I-private_address",
|
| 20 |
+
"5": "B-private_date",
|
| 21 |
+
"6": "I-private_date",
|
| 22 |
+
"7": "B-private_email",
|
| 23 |
+
"8": "I-private_email",
|
| 24 |
+
"9": "B-private_person",
|
| 25 |
+
"10": "I-private_person",
|
| 26 |
+
"11": "B-private_phone",
|
| 27 |
+
"12": "I-private_phone",
|
| 28 |
+
"13": "B-private_url",
|
| 29 |
+
"14": "I-private_url",
|
| 30 |
+
"15": "B-secret",
|
| 31 |
+
"16": "I-secret"
|
| 32 |
+
},
|
| 33 |
+
"initializer_range": 0.02,
|
| 34 |
+
"intermediate_size": 1536,
|
| 35 |
+
"is_decoder": false,
|
| 36 |
+
"label2id": {
|
| 37 |
+
"B-account_number": 1,
|
| 38 |
+
"B-private_address": 3,
|
| 39 |
+
"B-private_date": 5,
|
| 40 |
+
"B-private_email": 7,
|
| 41 |
+
"B-private_person": 9,
|
| 42 |
+
"B-private_phone": 11,
|
| 43 |
+
"B-private_url": 13,
|
| 44 |
+
"B-secret": 15,
|
| 45 |
+
"I-account_number": 2,
|
| 46 |
+
"I-private_address": 4,
|
| 47 |
+
"I-private_date": 6,
|
| 48 |
+
"I-private_email": 8,
|
| 49 |
+
"I-private_person": 10,
|
| 50 |
+
"I-private_phone": 12,
|
| 51 |
+
"I-private_url": 14,
|
| 52 |
+
"I-secret": 16,
|
| 53 |
+
"O": 0
|
| 54 |
+
},
|
| 55 |
+
"layer_norm_eps": 1e-12,
|
| 56 |
+
"max_position_embeddings": 512,
|
| 57 |
+
"model_type": "bert",
|
| 58 |
+
"num_attention_heads": 12,
|
| 59 |
+
"num_hidden_layers": 6,
|
| 60 |
+
"pad_token_id": 0,
|
| 61 |
+
"position_embedding_type": "absolute",
|
| 62 |
+
"tie_word_embeddings": true,
|
| 63 |
+
"tokenizer_class": "XLMRobertaTokenizer",
|
| 64 |
+
"transformers_version": "5.23.0",
|
| 65 |
+
"type_vocab_size": 2,
|
| 66 |
+
"use_cache": true,
|
| 67 |
+
"vocab_size": 45252
|
| 68 |
+
}
|
model.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:90a838b34daafdbf1b16dafdbcefd4087390765a257f5911a2b97ab49891f0bb
|
| 3 |
+
size 112924844
|
tokenizer.json
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
tokenizer_config.json
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"add_prefix_space": true,
|
| 3 |
+
"backend": "tokenizers",
|
| 4 |
+
"bos_token": "<s>",
|
| 5 |
+
"clean_up_tokenization_spaces": true,
|
| 6 |
+
"cls_token": "<s>",
|
| 7 |
+
"eos_token": "</s>",
|
| 8 |
+
"mask_token": "<mask>",
|
| 9 |
+
"model_max_length": 512,
|
| 10 |
+
"pad_token": "<pad>",
|
| 11 |
+
"sep_token": "</s>",
|
| 12 |
+
"sp_model_kwargs": {},
|
| 13 |
+
"tokenizer_class": "XLMRobertaTokenizer",
|
| 14 |
+
"unk_token": "<unk>"
|
| 15 |
+
}
|