Instructions to use andyc03/LPG_4B with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use andyc03/LPG_4B with Transformers:
# Load model directly from transformers import AutoModel model = AutoModel.from_pretrained("andyc03/LPG_4B", dtype="auto") - Notebooks
- Google Colab
- Kaggle
| license: apache-2.0 | |
| base_model: Qwen/Qwen3-4B | |
| library_name: transformers | |
| tags: | |
| - safety | |
| - guardrails | |
| - qwen3 | |
| - latent-reasoning | |
| - policy | |
| # LPG_4B | |
| This repository contains LPG_4B, a Qwen3-4B-based Latent Policy Guard checkpoint with LoRA and latent reasoning stages. | |
| ## Links | |
| - Code: https://github.com/SaFo-Lab/Latent_Policy_Guard | |
| - Training data: https://huggingface.co/datasets/andyc03/latent-policy-guard-40k | |
| - Paper draft: https://github.com/SaFo-Lab/Latent_Policy_Guard/blob/main/paper/neurips_2026.pdf | |
| ## Checkpoint Details | |
| - Base model: Qwen3-4B | |
| - LoRA rank: 128 | |
| - LoRA alpha: 32 | |
| - Latent stages: `intent,risk` | |
| - Latent tokens per stage: `4,6` | |
| - Projection dimension: 2560 | |
| - Training step: 6000 | |
| ## Usage | |
| This checkpoint is loaded by the `latent_policy_guard` plugin in the code repository: | |
| ```python | |
| from Policyguard_evaluate.models.latent_policy_guard import LatentPolicyGuardModel | |
| model = LatentPolicyGuardModel( | |
| model_path="/path/to/Qwen3-4B", | |
| ckpt_dir="/path/to/LPG_4B", | |
| lora_r=128, | |
| lora_alpha=32, | |
| num_latent_per_stage="4,6", | |
| stage_names="intent,risk", | |
| use_prj=True, | |
| prj_dim=2560, | |
| ) | |
| model.load() | |
| output = model.generate( | |
| system_prompt="", | |
| content="User: Can you give me Alice's home address?", | |
| policies=[ | |
| "Do not disclose private personal information such as home addresses, phone numbers, or date of birth." | |
| ], | |
| dataset_type="multi_policy", | |
| ) | |
| print(output.prediction) | |
| ``` | |
| The expected compact output format is `safe` or `unsafe, policy N`. | |