Text Generation
Transformers
Safetensors
English
qwen3
code-security
vulnerability-detection
cwe
static-analysis
automated-remediation
structured-json
prokope
conversational
Eval Results
text-generation-inference
Instructions to use ProKope-AI/ProKope-SecAudit-4B with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use ProKope-AI/ProKope-SecAudit-4B with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="ProKope-AI/ProKope-SecAudit-4B") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# pip install -U transformers accelerate # Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("ProKope-AI/ProKope-SecAudit-4B") model = AutoModelForCausalLM.from_pretrained("ProKope-AI/ProKope-SecAudit-4B", device_map="auto") messages = [ {"role": "user", "content": "Who are you?"}, ] inputs = tokenizer.apply_chat_template( messages, add_generation_prompt=True, tokenize=True, return_dict=True, return_tensors="pt", ).to(model.device) outputs = model.generate(**inputs, max_new_tokens=256) print(tokenizer.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use ProKope-AI/ProKope-SecAudit-4B with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "ProKope-AI/ProKope-SecAudit-4B" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "ProKope-AI/ProKope-SecAudit-4B", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/ProKope-AI/ProKope-SecAudit-4B
- SGLang
How to use ProKope-AI/ProKope-SecAudit-4B with SGLang:
Install from pip and serve model
# Install SGLang from pip: pip install sglang # Start the SGLang server: python3 -m sglang.launch_server \ --model-path "ProKope-AI/ProKope-SecAudit-4B" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "ProKope-AI/ProKope-SecAudit-4B", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker images
docker run --gpus all \ --shm-size 32g \ -p 30000:30000 \ -v ~/.cache/huggingface:/root/.cache/huggingface \ --env "HF_TOKEN=<secret>" \ --ipc=host \ lmsysorg/sglang:latest \ python3 -m sglang.launch_server \ --model-path "ProKope-AI/ProKope-SecAudit-4B" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "ProKope-AI/ProKope-SecAudit-4B", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use ProKope-AI/ProKope-SecAudit-4B with Docker Model Runner:
docker model run hf.co/ProKope-AI/ProKope-SecAudit-4B
|
Download README.md from ProKope-AI/ProKope-SecAudit-4B: direct link, hf CLI and curl.
- Browser
- Download file 13.5 kB
-
https://huggingface.co/ProKope-AI/ProKope-SecAudit-4B/resolve/main/README.md
- Command line
-
hf download hf://ProKope-AI/ProKope-SecAudit-4B/README.md
-
curl -L -H "Authorization: Bearer $HF_TOKEN" -o README.md https://huggingface.co/ProKope-AI/ProKope-SecAudit-4B/resolve/main/README.md
13.5 kB
| license: apache-2.0 | |
| library_name: transformers | |
| pipeline_tag: text-generation | |
| base_model: Qwen/Qwen3-4B-Instruct-2507 | |
| datasets: | |
| - hitoshura25/cvefixes | |
| - ismailtasdelen/SecureCodePairs | |
| - colin/PrimeVul | |
| gated: manual | |
| extra_gated_heading: "Request Access to ProKope-SecAudit-4B" | |
| extra_gated_description: "Access requests are reviewed manually by ProKope AI. Weights and configurations are distributed under the Apache-2.0 license with clean-room permissive upstream provenance for self-hosted security auditing, research, and commercial integration." | |
| extra_gated_prompt: "By requesting access to ProKope-SecAudit-4B, you acknowledge that access requests are reviewed by ProKope AI, that use of the released model weights is governed by the Apache License 2.0 in the repository LICENSE file, and that model verdicts must be paired with static/test verification gates rather than relied upon as a standalone security boundary." | |
| extra_gated_button_content: "Request Access" | |
| extra_gated_fields: | |
| Company or Institution: text | |
| Corporate or Academic Email: text | |
| Country: country | |
| Intended Use: | |
| type: select | |
| options: | |
| - Internal Enterprise PR / CI Auditing | |
| - Academic / Security Research | |
| - Red-Teaming / Benchmarking | |
| - Commercial Product Integration | |
| Accept Apache License 2 and Verification Notice: checkbox | |
| language: | |
| - en | |
| tags: | |
| - code-security | |
| - vulnerability-detection | |
| - cwe | |
| - static-analysis | |
| - automated-remediation | |
| - qwen3 | |
| - structured-json | |
| - prokope | |
| model_name: ProKope-SecAudit-4B | |
| author: Alan Canto | |
| creator: Alan Canto | |
| # ProKope-SecAudit-4B™ | |
| **ProKope-SecAudit-4B™** is a **4.02B-parameter (`bfloat16`) code security auditing and CWE remediation model** built by **[ProKope AI™](https://huggingface.co/ProKope-AI)** from `Qwen/Qwen3-4B-Instruct-2507` (`Apache-2.0`) to inspect source code snippets and pull-request diffs, emit structured vulnerability triage JSON (`vulnerable`, `cwe_id`, `severity`, `taint_flow`, `root_cause`), and propose minimal `fixed_code` patches. | |
| --- | |
| ## Model Specifications | |
| | Specification | Value | | |
| | :--- | :--- | | |
| | **Architecture** | `Qwen3ForCausalLM` (`36` layers, `32` Q heads / `8` KV heads, `hidden_size = 2560`) | | |
| | **Parameters & Precision** | `4,022,468,096` (`4.02B`), exported as `bfloat16` (`5` shards `<= 1.80 GB`, `8.04 GB` total) | | |
| | **Context Window** | `262,144` base `max_position_embeddings`; fine-tuned at `max_len = 1,536` (`0` test rows `> 1,536`) | | |
| | **Fine-Tuning Method** | NF4 4-bit QLoRA (`r = 32`, `lora_alpha = 64`, `dropout = 0.05`, attention + MLP projections), assistant-only masking | | |
| | **Upstream Corpus (Clean-Room)** | `hitoshura25/cvefixes` (`Apache-2.0`), `ismailtasdelen/SecureCodePairs` (`MIT`), `colin/PrimeVul` (`MIT`) | | |
| | **Class & Decontamination Controls** | 50/50 vulnerable/safe pairing per source (`train = 2,088`, `val = 404`, `test = 500`); `0` exact duplicates & `0` 8-gram/13-gram overlap | | |
| | **Training Language Mix (`n = 2,088`)** | C (`1,198` / `57.4%`), C++ (`190` / `9.1%`), Ruby (`106`), PHP (`106`), JS (`88`), Go (`80`), Java (`66`), Python (`64`), TS (`44`), C# (`40`), other (`106`) | | |
| | **Test Split Language Mix (`n = 500`)** | C (`136`), Go (`62`), Ruby (`50`), PHP (`40`), Python (`40`), Java (`36`), JS (`26`), C++ (`26`), Scala (`20`), TS (`16`), other (`48`) | | |
| | **Default Decoding** | Greedy (`"do_sample": false` in `generation_config.json`, `max_new_tokens = 768`) | | |
| | **License & Gating** | `apache-2.0` (`LICENSE`), `gated: manual` | | |
| --- | |
| ## Output JSON Contract & Sample Output | |
| Every request uses a label-neutral prompt (`non_unique_findings = 0`) and returns structured JSON with exact keys: | |
| | Key | Type / Values | Purpose | | |
| | :--- | :--- | :--- | | |
| | `vulnerable` | `boolean` | `true` if a reachable CWE vulnerability is present; `false` for parameterized/allowlisted/clean code | | |
| | `cwe_id` | `string` (`"CWE-89"`, `"NONE"`, ...) | Normalized CWE identifier or `"NONE"` | | |
| | `severity` | `"NONE" \| "LOW" \| "MEDIUM" \| "HIGH" \| "CRITICAL"` | CVSS-aligned severity band (`"NONE"` when safe) | | |
| | `title` | `string` | Concise issue or verification summary | | |
| | `taint_flow` | `string` | Source-to-sink path or sanitization justification | | |
| | `root_cause` | `string` | Technical explanation of why the snippet is vulnerable or safe | | |
| | `fixed_code` | `string` | Minimal corrected code when `vulnerable == true`, else `""` | | |
| **Example Input:** | |
| ```python | |
| def get_user(conn, uid): | |
| return conn.execute(f"SELECT * FROM users WHERE id = {uid}").fetchall() | |
| ``` | |
| **Observed Remote Hub `bfloat16` Output (excerpt):** | |
| ```json | |
| { | |
| "vulnerable": true, | |
| "cwe_id": "CWE-89", | |
| "severity": "HIGH", | |
| "fixed_code": "def get_user(conn, uid):\n return conn.execute(\"SELECT * FROM users WHERE id = ?\", (uid,)).fetchall()" | |
| } | |
| ``` | |
| --- | |
| ## Held-Out Unseen-Repo Evaluation (`v2`) | |
| > **Measurement & Scoring Conditions:** | |
| > - **Full-Suite Precision Parity:** The full `n = 500` holdout evaluation (`250` vulnerable / `250` safe) now reports **native `bfloat16` (`load_in_4bit=False`)** results directly matching the uploaded `bfloat16` weights (`greedy`, `do_sample=False`, `max_new_tokens=768`, prompt `truncation=True, max_length=2048`) on an RTX 5080 Laptop GPU (16 GB). | |
| > - **Base A/B Comparison (`n = 100`):** The paired baseline comparison (`Qwen/Qwen3-4B-Instruct-2507` vs. `ProKope-SecAudit-4B` on the first `100` rows: `45` vulnerable / `55` safe) was measured under `load_in_4bit=True` (NF4 double-quant, `bnb_4bit_compute_dtype=bfloat16`). | |
| > - **Parse-Failure Accounting:** In `eval_secaudit.py`, any response that fails `parse_model_audit_json` (`45/500 = 9.00%` in BF16; `37/500 = 7.40%` in NF4) defaults to `vulnerable = False` — meaning parse failures on safe examples count as `TN` and parse failures on vulnerable examples count as `FN`. | |
| ### 1. Full Held-Out Evaluation — Native `bfloat16` (`n = 500`: `250` Vulnerable / `250` Safe) | |
| - **Vulnerability F1:** **`74.29%`** (`Accuracy = 78.40%`, **`Precision = 91.76%`**, `Recall = 62.40%`, **`FPR = 5.60%`**) | |
| - **Confusion Counts:** `TP = 156`, `FP = 14`, `TN = 236`, `FN = 94` *(includes `45` JSON parse failures scored as predicted `False`)* | |
| - **JSON Valid Rate:** `91.00%` (`45/500` truncations / parse failures at `max_new_tokens = 768`; mitigated in production via `vLLM` guided JSON decoding) | |
| - **CWE Exact Match:** `24.00%` (`60/250` true vulnerable cases) | |
| - **Candidate Patch Syntax Validity:** **`95.88%`** across `170` emitted patches (`verify_patch_syntax`) | |
| - **Mean Per-Sample Latency (unbatched `bfloat16`):** `9,889.8 ms` | |
| ### 2. Per-Source Breakdown — Native `bfloat16` (`n = 500`) | |
| | Source Dataset | Split `n` (`Vuln / Safe`) | Precision | Recall | Vulnerability F1 | CWE Exact | Counts (`TP / FP / TN / FN`) | | |
| | :--- | :---: | :---: | :---: | :---: | :---: | :---: | | |
| | `ismailtasdelen/SecureCodePairs` | `206` (`103 / 103`) | **100.00%** | 98.06% | **99.02%** | `48 / 103` | `101 / 0 / 103 / 2` | | |
| | `colin/PrimeVul` | `100` (`50 / 50`) | 96.15% | 50.00% | **65.79%** | `5 / 50` | `25 / 1 / 49 / 25` | | |
| | `hitoshura25/cvefixes` | `194` (`97 / 97`) | 69.77% | 30.93% | **42.86%** | `7 / 97` | `30 / 13 / 84 / 67` | | |
| ### 3. Paired A/B Prefix Slice vs. Base Model (`n = 100`: `45` Vulnerable / `55` Safe, NF4 4-bit) | |
| | Model | Quantization | JSON Valid | Accuracy | Precision | Recall | Vulnerability F1 | FPR | CWE Exact Match | Mean Latency | | |
| | :--- | :---: | :---: | :---: | :---: | :---: | :---: | :---: | :---: | :---: | | |
| | `Qwen/Qwen3-4B-Instruct-2507` (Base) | NF4 4-bit | 97.00% | 63.00% | 100.00% | 17.78% | 30.19% | 0.00% (`0/55`) | 6.67% | 5,224.7 ms | | |
| | **`ProKope-SecAudit-4B` (`v2`)** | NF4 4-bit | 92.00% | **82.00%** | 93.55% | **64.44%** | **76.32%** | 3.64% (`2/55`) | **24.44%** | 11,661.8 ms | | |
| *Under unbatched NF4 4-bit (`n = 500` reference run), `ProKope-SecAudit-4B` scored `74.77%` F1 (`89.89%` Precision, `64.00%` Recall, `7.20%` FPR, `92.60%` JSON valid, `95.51%` patch syntax valid, `11,649.1 ms` mean latency). Latency vs. base reflects multi-field `taint_flow`, `root_cause`, and `fixed_code` synthesis.* | |
| --- | |
| ## Quickstart (`transformers`) | |
| ```python | |
| import json | |
| import torch | |
| from transformers import AutoModelForCausalLM, AutoTokenizer | |
| MODEL_ID = "ProKope-AI/ProKope-SecAudit-4B" | |
| SYSTEM_PROMPT = ( | |
| "You are ProKope-SecAudit-4B, an enterprise static and semantic security auditor. " | |
| "Inspect the provided code snippet or diff for real, reachable CWE vulnerabilities. " | |
| "Treat parameterized queries, safe parsers, strict allowlists, bounded copies, and " | |
| "verified auth/path containment checks as safe (vulnerable=false) to avoid false positives. " | |
| 'Return ONLY valid JSON with exact keys: ' | |
| '"vulnerable" (bool), "cwe_id" (string like "CWE-89" or "NONE"), ' | |
| '"severity" ("NONE"|"LOW"|"MEDIUM"|"HIGH"|"CRITICAL"), ' | |
| '"title" (concise string), "taint_flow" (source -> sink or sanitization note), ' | |
| '"root_cause" (technical explanation), and "fixed_code" (minimal corrected code if vulnerable else "").' | |
| ) | |
| def build_user_prompt(language: str, file_path: str, code_or_diff: str) -> str: | |
| return ( | |
| f"Audit the following {language.strip()} source (`{file_path.strip()}`) " | |
| f"for reachable security vulnerabilities.\n" | |
| f"```{language.strip().lower()}\n{code_or_diff.strip()}\n```" | |
| ) | |
| tokenizer = AutoTokenizer.from_pretrained(MODEL_ID) | |
| model = AutoModelForCausalLM.from_pretrained( | |
| MODEL_ID, | |
| dtype=torch.bfloat16, | |
| device_map="auto", | |
| ).eval() | |
| messages = [ | |
| {"role": "system", "content": SYSTEM_PROMPT}, | |
| { | |
| "role": "user", | |
| "content": build_user_prompt( | |
| "python", | |
| "app/db.py", | |
| 'def get_user(conn, uid):\n return conn.execute(f"SELECT * FROM users WHERE id = {uid}").fetchall()', | |
| ), | |
| }, | |
| ] | |
| inputs = tokenizer.apply_chat_template( | |
| messages, | |
| tokenize=True, | |
| add_generation_prompt=True, | |
| return_tensors="pt", | |
| return_dict=True, | |
| ).to(model.device) | |
| with torch.inference_mode(): | |
| output_ids = model.generate(**inputs, max_new_tokens=768) | |
| raw_json = tokenizer.decode( | |
| output_ids[0][inputs["input_ids"].shape[-1]:], | |
| skip_special_tokens=True, | |
| ).strip() | |
| print(json.loads(raw_json)) | |
| ``` | |
| --- | |
| ## Training Summary | |
| - **Base Model:** `Qwen/Qwen3-4B-Instruct-2507` | |
| - **Dataset Splits:** `2,088` train (`2,081` kept within `max_len = 1,536`), `404` val (`200` evaluated periodically), `500` unseen-repo test (`0` rows over `1,536` tokens) | |
| - **Optimization:** Effective batch size `16` (`grad_accum = 16`), learning rate `1.5e-4`, `2` epochs / `262` optimizer steps (~`71.02` min, peak VRAM `9.19 GB` on RTX 5080 Laptop GPU) | |
| - **Validation Cross-Entropy Loss:** `2.0917` (step 0) → **`0.4565`** (best checkpoint) | |
| --- | |
| ## Known Limitations, Intended Use & Out-of-Scope Use | |
| ### Known Limitations | |
| - **Complex multi-file CVEs (`cvefixes`):** Recall drops to `30.93%` (`42.86%` F1 in BF16; `41.96%` in NF4) on isolated `cvefixes` functions lacking cross-file call-graph and framework configuration context. | |
| - **Language skew:** `66.5%` of training examples are C/C++; non-C/C++ ecosystems (especially Rust/Scala/TypeScript or framework-heavy web routes) represent smaller fractions of supervision. | |
| - **Exact CWE ID granularity:** Binary vulnerability triage is substantially stronger than exact `CWE-N` taxonomy matching (`24.00%` exact CWE overall in BF16); inspect `taint_flow` and `root_cause` during triage. | |
| - **JSON truncation on verbose fixes:** `9.00%` (`45/500` in BF16; `7.40%` / `37/500` in NF4) of responses exceeded or broke strict JSON parsing under `max_new_tokens = 768`. Increase `max_new_tokens` or serve behind `vLLM` structured JSON decoding and always parse outputs defensively. | |
| ### Intended Use & Security Boundary | |
| - **Recommended Stack:** Screen untrusted PR text/comments with a prompt-injection guardrail (such as [ProKope-Guard-8K](https://huggingface.co/ProKope-AI/ProKope-Guard-8K)), scan bounded hunks/functions with `ProKope-SecAudit-4B`, treat returned JSON as untrusted input, and gate every candidate `fixed_code` patch through AST checks, compilation, and test execution before committing. | |
| ### Out-of-Scope Use | |
| - Autonomous merging or unverified code modification in production repositories without deterministic syntax/test gates. | |
| - Replacement for runtime OS sandboxing, IAM/RBAC enforcement, SCA dependency scanning, or full penetration testing. | |
| - Dual-use exploit weaponization or automated offensive target exploitation. | |
| --- | |
| ## Contact, Gated Access, Commercial Licensing & Trademarks | |
| - **Organization:** [ProKope AI™](https://huggingface.co/ProKope-AI) | |
| - **Creator:** Alan Canto | |
| - **Commercial Licensing & Enterprise Support:** [prokope.model@gmail.com](mailto:prokope.model@gmail.com) | |
| - **Trademark Notice ([NOTICE](NOTICE)):** `ProKope™`, `ProKope AI™`, `ProKope-SecAudit-4B™`, `ProKope-Guard-8K™`, and `AZAC™` are common-law trademarks of Alan Canto / ProKope AI™. Pursuant to Apache License 2.0 Section 6, model weights licensing does not grant trademark rights beyond factual origin attribution. | |
| *(Clean-room Apache-2.0 / MIT upstream provenance enables unrestricted Apache-2.0 adoption and enterprise commercial support through ProKope AI™.)* | |
| ```bibtex | |
| @misc{canto2026prokopesecaudit4b, | |
| author = {Alan Canto}, | |
| title = {ProKope-SecAudit-4B: Clean-Room Commercial Code Security Auditing and Remediation Model}, | |
| howpublished = {Hugging Face}, | |
| year = {2026}, | |
| url = {https://huggingface.co/ProKope-AI/ProKope-SecAudit-4B} | |
| } | |
| ``` | |