Instructions to use OASecure/promptguard-context-classifier with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Scikit-learn
How to use OASecure/promptguard-context-classifier with Scikit-learn:
from huggingface_hub import hf_hub_download import joblib model = joblib.load( hf_hub_download("OASecure/promptguard-context-classifier", "sklearn_model.joblib") ) # only load pickle files from sources you trust # read more about it here https://skops.readthedocs.io/en/stable/persistence.html - Notebooks
- Google Colab
- Kaggle
PromptGuard Context Classifier v287
This repository hosts the complete runtime artifact package for PromptGuard's context-risk classifier.
It contains both required runtime stages:
LR candidate generator:models/context_with_patch_v287_lr_c4_dev_classifier.joblibRoBERTa verifier:models/context_verifier_klue_roberta_base_lrmined_v287_global002_compactv2_lpft_focal_1p2ep/model.safetensors
The Hugging Face base_model metadata points only to the fine-tuned verifier base, klue/roberta-base. The LR stage is a scikit-learn linear classifier over Qwen embedding vectors, so it has no Transformer base model of its own.
Runtime Architecture
PromptGuard uses a two-stage context classifier. This repository is a runtime artifact package, not a single Transformer checkpoint loaded from the repository root.
- Frozen Qwen embedding dependency + One-vs-Rest Logistic Regression candidate generator
- Fine-tuned KLUE RoBERTa label-aware verifier
The Logistic Regression stage is a high-recall linear candidate generator stored as a joblib artifact. It is not a fine-tuned Qwen model and does not have its own Hugging Face base model. It expects normalized embedding vectors produced by Qwen/Qwen3-Embedding-0.6B.
The RoBERTa verifier is the fine-tuned Transformer stage. Its base model is klue/roberta-base, and the fine-tuned verifier checkpoint is stored under models/context_verifier_klue_roberta_base_lrmined_v287_global002_compactv2_lpft_focal_1p2ep/.
Artifact Inventory
The runtime is complete only when all of these files are present:
| Runtime part | File |
|---|---|
| Source-of-truth manifest | models/context_lr_roberta_active_best_f1_manifest.json |
| Target label list | models/context_target_labels.json |
| Verifier label definitions | models/context_label_definitions_verifier_compact_v2.json |
| LR candidate generator | models/context_with_patch_v287_lr_c4_dev_classifier.joblib |
| RoBERTa verifier checkpoint | models/context_verifier_klue_roberta_base_lrmined_v287_global002_compactv2_lpft_focal_1p2ep/model.safetensors |
| RoBERTa tokenizer/config | models/context_verifier_klue_roberta_base_lrmined_v287_global002_compactv2_lpft_focal_1p2ep/* |
If only the LR joblib file is downloaded, the PromptGuard context pipeline is incomplete. Download with --include "models/*" so both stages are available.
Files
Download the models/ directory into the PromptGuard project root. The application reads:
models/context_lr_roberta_active_best_f1_manifest.jsonmodels/context_target_labels.jsonmodels/context_label_definitions_verifier_compact_v2.jsonmodels/context_with_patch_v287_lr_c4_dev_classifier.joblibmodels/context_verifier_klue_roberta_base_lrmined_v287_global002_compactv2_lpft_focal_1p2ep/
models/SHA256SUMS contains checksums for the uploaded runtime files.
Target Labels
SECRET_CREDENTIAL_CONTEXTPERSONAL_DATA_CONTEXTFINANCIAL_IDENTIFIER_CONTEXTCONFIDENTIAL_BUSINESS_CONTEXTPROPRIETARY_TECHNICAL_CONTEXTSECURITY_CONTROL_CONTEXTINTERNAL_OPERATION_CONTEXTBULK_SENSITIVE_RECORD_CONTEXT
Threshold Policy
The source-of-truth policy is stored in models/context_lr_roberta_active_best_f1_manifest.json.
- LR candidate threshold:
0.02 - Verifier threshold mode: label-wise
- Verifier chunk policy:
chunk_chars=900,chunk_overlap=120,max_chunks=8 - Verifier pooling: max verifier score per label across chunks
Usage
From the PromptGuard repository root:
pip install "huggingface_hub[hf_xet]"
hf download OASecure/promptguard-context-classifier \
--revision v287-20260623 \
--include "models/*" \
--local-dir .
Then enable the runtime:
PROMPTGUARD_CLASSIFIER_RUNTIME_ENABLED=true
PROMPTGUARD_CLASSIFIER_MANIFEST_PATH=/opt/promptguard/models/context_lr_roberta_active_best_f1_manifest.json
PROMPTGUARD_VERIFIER_RUNTIME_ENABLED=true
PROMPTGUARD_VERIFIER_MANIFEST_PATH=/opt/promptguard/models/context_lr_roberta_active_best_f1_manifest.json
Do not load this repository root directly with AutoModelForSequenceClassification.from_pretrained("OASecure/promptguard-context-classifier"). PromptGuard reads models/context_lr_roberta_active_best_f1_manifest.json, loads the LR joblib file for candidate generation, and loads the verifier directory named in that manifest for RoBERTa verification.
Data and Privacy
This repository contains runtime artifacts only. It does not include raw prompts, source documents, extracted text, filenames, training/evaluation detail rows, embedding vectors, logits, exact classifier scores, or full masked prompts.
License Notes
The PromptGuard application code is distributed separately on GitHub. These model artifacts are published for PromptGuard runtime use. Qwen/Qwen3-Embedding-0.6B is used as a frozen embedding dependency for the LR stage, not as the fine-tuned base model of this repository. klue/roberta-base is the verifier base model. Downstream users should review base-model and training-data obligations before redistribution or commercial use.
Limitations
This model is a context-risk classifier. It is not a complete DLP system by itself and does not replace PromptGuard's separate regex/span masking policy layer.
- Downloads last month
- -
Model tree for OASecure/promptguard-context-classifier
Base model
klue/roberta-base
from huggingface_hub import hf_hub_download import joblib model = joblib.load( hf_hub_download("OASecure/promptguard-context-classifier", "sklearn_model.joblib") ) # only load pickle files from sources you trust # read more about it here https://skops.readthedocs.io/en/stable/persistence.html