Text Generation
GGUF
English
llama.cpp
gemma
factbank
security
secure-coding
appsec
cwe
reasoning
conversational
Instructions to use mhndayesh/gemma-4-E2B-security-expert-GGUF with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- llama.cpp
How to use mhndayesh/gemma-4-E2B-security-expert-GGUF with llama.cpp:
Install (macOS, Linux)
curl -LsSf https://llama.app/install.sh | sh # Start a local OpenAI-compatible server with a web UI: llama serve -hf mhndayesh/gemma-4-E2B-security-expert-GGUF:Q4_K_M # Run inference directly in the terminal: llama cli -hf mhndayesh/gemma-4-E2B-security-expert-GGUF:Q4_K_M
Install from WinGet (Windows)
winget install llama.cpp # Start a local OpenAI-compatible server with a web UI: llama serve -hf mhndayesh/gemma-4-E2B-security-expert-GGUF:Q4_K_M # Run inference directly in the terminal: llama cli -hf mhndayesh/gemma-4-E2B-security-expert-GGUF:Q4_K_M
Use pre-built binary
# Download pre-built binary from: # https://github.com/ggerganov/llama.cpp/releases # Start a local OpenAI-compatible server with a web UI: ./llama-server -hf mhndayesh/gemma-4-E2B-security-expert-GGUF:Q4_K_M # Run inference directly in the terminal: ./llama-cli -hf mhndayesh/gemma-4-E2B-security-expert-GGUF:Q4_K_M
Build from source code
git clone https://github.com/ggerganov/llama.cpp.git cd llama.cpp cmake -B build cmake --build build -j --target llama-server llama-cli # Start a local OpenAI-compatible server with a web UI: ./build/bin/llama-server -hf mhndayesh/gemma-4-E2B-security-expert-GGUF:Q4_K_M # Run inference directly in the terminal: ./build/bin/llama-cli -hf mhndayesh/gemma-4-E2B-security-expert-GGUF:Q4_K_M
Use Docker
docker model run hf.co/mhndayesh/gemma-4-E2B-security-expert-GGUF:Q4_K_M
- LM Studio
- Jan
- vLLM
How to use mhndayesh/gemma-4-E2B-security-expert-GGUF with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "mhndayesh/gemma-4-E2B-security-expert-GGUF" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "mhndayesh/gemma-4-E2B-security-expert-GGUF", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/mhndayesh/gemma-4-E2B-security-expert-GGUF:Q4_K_M
- Ollama
How to use mhndayesh/gemma-4-E2B-security-expert-GGUF with Ollama:
ollama run hf.co/mhndayesh/gemma-4-E2B-security-expert-GGUF:Q4_K_M
- Unsloth Desktop
- Pi
How to use mhndayesh/gemma-4-E2B-security-expert-GGUF with Pi:
Start the llama.cpp server
# Install llama.cpp: brew install llama.cpp # Start a local OpenAI-compatible server: llama serve -hf mhndayesh/gemma-4-E2B-security-expert-GGUF:Q4_K_M
Configure the model in Pi
# Install Pi: npm install -g @earendil-works/pi-coding-agent # Add to ~/.pi/agent/models.json: { "providers": { "llama-cpp": { "baseUrl": "http://localhost:8080/v1", "api": "openai-completions", "apiKey": "none", "models": [ { "id": "mhndayesh/gemma-4-E2B-security-expert-GGUF:Q4_K_M" } ] } } }Run Pi
# Start Pi in your project directory: pi
- Docker Model Runner
How to use mhndayesh/gemma-4-E2B-security-expert-GGUF with Docker Model Runner:
docker model run hf.co/mhndayesh/gemma-4-E2B-security-expert-GGUF:Q4_K_M
- Lemonade
How to use mhndayesh/gemma-4-E2B-security-expert-GGUF with Lemonade:
Pull the model
# Download Lemonade from https://lemonade-server.ai/ lemonade pull mhndayesh/gemma-4-E2B-security-expert-GGUF:Q4_K_M
Run and chat with the model
lemonade run user.gemma-4-E2B-security-expert-GGUF-Q4_K_M
List all available models
lemonade list
- Hermes Agent
How to use mhndayesh/gemma-4-E2B-security-expert-GGUF with Hermes Agent:
Start the llama.cpp server
# Install llama.cpp: brew install llama.cpp # Start a local OpenAI-compatible server: llama serve -hf mhndayesh/gemma-4-E2B-security-expert-GGUF:Q4_K_M
Configure Hermes
# Install Hermes: curl -fsSL https://hermes-agent.nousresearch.com/install.sh | bash hermes setup # Point Hermes at the local server: hermes config set model.provider custom hermes config set model.base_url http://127.0.0.1:8080/v1 hermes config set model.default mhndayesh/gemma-4-E2B-security-expert-GGUF:Q4_K_M
Run Hermes
hermes
- Atomic Chat
- OpenClaw
How to use mhndayesh/gemma-4-E2B-security-expert-GGUF with OpenClaw:
Start the llama.cpp server
# Install llama.cpp: brew install llama.cpp # Start a local OpenAI-compatible server: llama serve -hf mhndayesh/gemma-4-E2B-security-expert-GGUF:Q4_K_M
Configure OpenClaw
# Install OpenClaw: npm install -g openclaw@latest # Register the local server and set it as the default model: openclaw onboard --non-interactive --mode local \ --auth-choice custom-api-key \ --custom-base-url http://127.0.0.1:8080/v1 \ --custom-model-id "mhndayesh/gemma-4-E2B-security-expert-GGUF:Q4_K_M" \ --custom-provider-id llama-cpp \ --custom-compatibility openai \ --custom-text-input \ --accept-risk \ --skip-health
Run OpenClaw
openclaw agent --local --agent main --message "Hello from Hugging Face"
Upload README.md with huggingface_hub
Browse files
README.md
CHANGED
|
@@ -14,125 +14,91 @@ tags:
|
|
| 14 |
- secure-coding
|
| 15 |
- appsec
|
| 16 |
- cwe
|
| 17 |
-
-
|
| 18 |
-
- edge
|
| 19 |
---
|
| 20 |
|
| 21 |
# gemma-4-E2B-security-expert (GGUF)
|
| 22 |
|
| 23 |
-
**A ~2B
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
insecure-by-default pattern it would otherwise emit. **Weights are untouched**; there is no external
|
| 27 |
-
RAG service, no fine-tuning. Runs on a laptop.
|
| 28 |
|
| 29 |
-
>
|
| 30 |
-
> supplies the *security knowledge* the weights lack, so the small model behaves like one taught to
|
| 31 |
-
> code securely. On the results below, this 2B **beats DeepSeek-V4** at secure-code generation.
|
| 32 |
|
| 33 |
-
|
| 34 |
-
|
|
|
|
|
|
|
|
|
|
| 35 |
|
| 36 |
-
|
| 37 |
-
|
| 38 |
-
|
| 39 |
-
|
| 40 |
-
|
| 41 |
-
| load a PyTorch checkpoint | `torch.load(path)` | `torch.load(path, weights_only=True)` *(post-cutoff default)* |
|
| 42 |
-
| parse an XML file | `etree.parse(f)` | `XMLParser(resolve_entities=False, no_network=True)` *(XXE)* |
|
| 43 |
-
| load a YAML config | `yaml.load(...)` | `yaml.safe_load(...)` |
|
| 44 |
-
| generate a token / nonce | `random.random()` | `secrets.token_hex()` / `os.urandom` |
|
| 45 |
-
| a DB credential | `password = "hunter2"` | `os.environ.get("DB_PASSWORD")` |
|
| 46 |
-
| run a SQL query with user input | string-concatenated SQL | parameterized query |
|
| 47 |
-
| evaluate a user expression | `eval(...)` | `ast.literal_eval(...)` |
|
| 48 |
-
| compare an HMAC signature | `a == b` | constant-time compare |
|
| 49 |
-
|
| 50 |
-
You **don't have to name the vulnerability** β the bank is indexed by the *coding task*
|
| 51 |
-
("verify a signed URL", "load a model", "parse untrusted XML"), so it fires on benign prompts.
|
| 52 |
-
|
| 53 |
-
## Coverage β what's in the bank
|
| 54 |
-
- **258 security concepts** (backed by the **MITRE CWE** taxonomy) β **3,984 language/framework
|
| 55 |
-
variants** β the same weakness written the way it actually appears in each ecosystem. (This bank is
|
| 56 |
-
organized by **weakness/CWE**, not by a short library list β it spans the whole secure-coding surface.)
|
| 57 |
-
- **10+ languages:** Python, Java, JavaScript, C / C++, Swift, Go, C#, Rust, Ruby, and more.
|
| 58 |
-
- **Frameworks & platforms:** Android, iOS / SwiftUI / WKWebView, Flask, Django, Express, Node.js,
|
| 59 |
-
ASP.NET / .NET, Spring, Java EE, Rails, Laravel.
|
| 60 |
-
- **Mined from 7 permissive security sources:** MITRE **CWE**, GitHub **CodeQL** queries, SAST rules
|
| 61 |
-
(**Bandit** + **gosec**), OWASP **MASTG** (mobile), **RustSec** advisories, **NIST / RFC / Mozilla**
|
| 62 |
-
crypto-&-network guidance, and **OWASP**. Every fact was quote-grounded to its source, then put
|
| 63 |
-
through an **adversarial correctness audit** (a second model tried to refute each fact; ~3.8%
|
| 64 |
-
wrong/stale were removed β grounding proves a fact is *real*, the audit checks it's *right*).
|
| 65 |
-
|
| 66 |
-
## Benchmarks β hand-scored (the project rule is to read outputs, not trust a scorer)
|
| 67 |
-
|
| 68 |
-
### External benchmark: SecurityEval (s2e-lab, MSR 2022)
|
| 69 |
-
121 Python CWE-tagged insecure-by-default function-completion tasks; complete each stub securely.
|
| 70 |
-
|
| 71 |
-
| arm | secure (pattern-checkable subset, 28 tasks) |
|
| 72 |
-
|---|---|
|
| 73 |
-
| e2b **base** (2B) | 14 / 28 |
|
| 74 |
-
| **e2b + this bank** | **25 / 28 (+11, 0 regressions)** |
|
| 75 |
|
| 76 |
-
|
| 77 |
-
|
| 78 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 79 |
|
| 80 |
-
##
|
| 81 |
-
|
|
|
|
|
|
|
|
|
|
| 82 |
|
| 83 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 84 |
|---|---|
|
| 85 |
-
|
|
| 86 |
-
| **
|
| 87 |
-
| **e2b + this bank (2B)** | **22 / 24** |
|
| 88 |
|
| 89 |
-
|
| 90 |
-
|
| 91 |
-
|
| 92 |
-
|
| 93 |
-
> **Honest caveats.** Hand-scored on the pattern-checkable subset (the rest weren't machine-judgeable).
|
| 94 |
-
> `deepseek-v4-flash` is a strong, large cloud model but not literally GPT-5 / Claude-Opus (those
|
| 95 |
-
> weren't callable in the harness). Numbers are a secure-code delta, not a security guarantee.
|
| 96 |
|
| 97 |
## How to run
|
| 98 |
|
| 99 |
-
###
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 100 |
```bash
|
| 101 |
-
|
|
|
|
|
|
|
|
|
|
| 102 |
```
|
| 103 |
-
|
| 104 |
-
|
| 105 |
-
unchanged. **Sampling β Gemma-native:** `temperature 1.0, top_k 64, top_p 0.95, min_p 0.01` (the
|
| 106 |
-
`min_p` floor prevents reasoning-loop empty answers). Don't quantize the KV cache on a model this
|
| 107 |
-
small. Ships **thinking-OFF** β the correct config for a baked expert (chain-of-thought reverts a
|
| 108 |
-
habit-reversal fact to the model's trained prior).
|
| 109 |
-
|
| 110 |
-
### LM Studio β use the Hub model (delivers the full bank)
|
| 111 |
-
The bank template is **4.18 MB**, over LM Studio's ~980 KB raw-GGUF metadata cap β so if you load
|
| 112 |
-
*this GGUF* directly in LM Studio the template is silently truncated and the bank won't fire. For LM
|
| 113 |
-
Studio, install the **virtual-model** edition, which hands the full template to LM Studio's own engine
|
| 114 |
-
(no cap):
|
| 115 |
-
|
| 116 |
-
**β‘ https://lmstudio.ai/mhndayesh/gemma-4-e2b-security-expert** β open it and click *"Use Model in
|
| 117 |
-
LM Studio"* (or `lms get mhndayesh/gemma-4-e2b-security-expert`).
|
| 118 |
-
|
| 119 |
-
Both editions carry the **same** bank; only the delivery differs. This GGUF is for llama.cpp and
|
| 120 |
-
OpenAI-compatible servers; the Hub edition is for LM Studio.
|
| 121 |
|
| 122 |
## Limitations
|
| 123 |
-
- **Scoped to
|
| 124 |
-
- **Supplies knowledge, not reasoning
|
| 125 |
-
|
| 126 |
-
- **Keyword + faceted retrieval, not embeddings
|
| 127 |
-
"I don't know" signal β a miss looks like a normal answer.
|
| 128 |
-
- **Grounded & audited, but research-grade** β review generated code; this is an assistant, not a
|
| 129 |
-
substitute for review.
|
| 130 |
-
- Hand-scored security tests, not a general coding benchmark.
|
| 131 |
|
| 132 |
## Provenance & license
|
| 133 |
-
- **Base:** `lmstudio-community/gemma-4-E2B-it-GGUF` (
|
| 134 |
-
|
| 135 |
-
|
| 136 |
-
|
| 137 |
-
is FactBank-project content (repo `LICENSE`); mined sources keep their own licenses.
|
| 138 |
- **Source & method:** [github.com/mhndayesh/experts-models](https://github.com/mhndayesh/experts-models).
|
|
|
|
| 14 |
- secure-coding
|
| 15 |
- appsec
|
| 16 |
- cwe
|
| 17 |
+
- reasoning
|
|
|
|
| 18 |
---
|
| 19 |
|
| 20 |
# gemma-4-E2B-security-expert (GGUF)
|
| 21 |
|
| 22 |
+
**A ~2B (E2B) model that writes *secure code by default* β an application-security *FactBank* is baked into
|
| 23 |
+
its chat-template and fires **inside the inference engine** to steer the model off insecure-by-default
|
| 24 |
+
patterns.** Weights untouched; no external RAG. This repo ships **two editions** (see below).
|
|
|
|
|
|
|
| 25 |
|
| 26 |
+
> π **Full project:** [github.com/mhndayesh/experts-models](https://github.com/mhndayesh/experts-models)
|
|
|
|
|
|
|
| 27 |
|
| 28 |
+
## Two editions β pick one (files in this repo)
|
| 29 |
+
| edition | file | when to use | notes |
|
| 30 |
+
|---|---|---|---|
|
| 31 |
+
| **thinking-OFF** (default) | `gemma-4-E2B-security-expert-Q4_K_M.gguf` | production, speed, reliability | 0 empty answers, fast, secure. No reasoning trace. **The safe default.** |
|
| 32 |
+
| **thinking-ON** | `gemma-4-E2B-security-expert-thinking-Q4_K_M.gguf` | you want a visible reasoning trace | Shows its work and is strong on most tasks, **but ~10% of the hardest-reasoning prompts can run long and return a *blank* answer** (fails safe β it does not emit insecure code; just retry). Needs a large context + generous output budget. |
|
| 33 |
|
| 34 |
+
Both editions carry the **same** bank. They differ only in whether chain-of-thought is on. We ship both so
|
| 35 |
+
you know exactly what you're getting β a landmine fact *reverses a trained habit*, and with thinking on the
|
| 36 |
+
model sometimes over-reasons back toward its prior, so the thinking edition trades some reliability for a
|
| 37 |
+
reasoning trace. Thinking-ON has a **known llama.cpp Gemma-4 fix applied** (the generation prompt opens the
|
| 38 |
+
thought channel) + **strong authority framing** so facts hold; the residual ~10% is inherent to reasoning-on.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 39 |
|
| 40 |
+
## Settings that work (baked into the Hub editions; set these yourself on llama.cpp)
|
| 41 |
+
- **Sampling (gemma-native):** `temperature 1.0, top_k 64, top_p 0.95, min_p 0.01`. The **`min_p 0.01`** floor
|
| 42 |
+
is important β it stops the low-temperature repetition loop that otherwise yields empty answers.
|
| 43 |
+
- **Context length:** **β₯ 16k, 32k recommended** (`contextLength 32768` is baked). The bank injects ~3,400
|
| 44 |
+
tokens per query, so a small context truncates the answer β especially with thinking on.
|
| 45 |
+
- **Output budget (thinking-ON):** allow **generous `max_tokens`** (reasoning traces run ~2β3k tokens); too
|
| 46 |
+
small a cap truncates before the answer.
|
| 47 |
|
| 48 |
+
## What it does
|
| 49 |
+
Given a normal coding request it silently corrects insecure defaults, e.g. `torch.load(weights_only=True)`
|
| 50 |
+
(post-cutoff), XXE `resolve_entities=False`, `yaml.safe_load`, `secrets` over `random`, `os.environ` creds,
|
| 51 |
+
parameterized SQL, `ast.literal_eval` over `eval`, constant-time HMAC compare. You **don't name the
|
| 52 |
+
vulnerability** β the bank is indexed by the coding task, so it fires on benign prompts.
|
| 53 |
|
| 54 |
+
## Coverage β what's in the bank
|
| 55 |
+
- **258 CWE concepts β 3,984 language/framework variants** (organized by weakness, not a short lib list).
|
| 56 |
+
- **10+ languages:** Python, Java, JavaScript, C/C++, Swift, Go, C#, Rust, Ruby, and more.
|
| 57 |
+
- **Frameworks:** Android, iOS/SwiftUI/WKWebView, Flask, Django, Express, Node.js, ASP.NET/.NET, Spring,
|
| 58 |
+
Java EE, Rails, Laravel.
|
| 59 |
+
- **7 mined sources:** MITRE **CWE**, GitHub **CodeQL**, SAST (**Bandit**+**gosec**), OWASP **MASTG**,
|
| 60 |
+
**RustSec**, **NIST/RFC/Mozilla** crypto-net, **OWASP** β each fact quote-grounded then adversarially
|
| 61 |
+
correctness-audited (~3.8% wrong/stale removed).
|
| 62 |
+
|
| 63 |
+
## Benchmarks (E2B, hand-scored β read the outputs, don't trust a scorer)
|
| 64 |
+
External **SecurityEval** (s2e-lab, MSR 2022, 121 Python CWE tasks), pattern-checkable subset:
|
| 65 |
+
|
| 66 |
+
| arm | secure |
|
| 67 |
|---|---|
|
| 68 |
+
| base (2B) | 14/28 |
|
| 69 |
+
| **+ this bank** | **25/28 (+11, 0 regressions; XXE 0/6β6/6)** |
|
|
|
|
| 70 |
|
| 71 |
+
And vs a strong cloud model on the same 24 tasks: base 12 Β· **DeepSeek-V4 (`deepseek-v4-flash`) 13** Β·
|
| 72 |
+
**+bank 22** β the 2B+bank *strictly dominates* the cloud model (9 wins, 0 losses). These are FactBank
|
| 73 |
+
retrieval measurements; the shipped GGUFs bake the same bank in-engine.
|
|
|
|
|
|
|
|
|
|
|
|
|
| 74 |
|
| 75 |
## How to run
|
| 76 |
|
| 77 |
+
### LM Studio (Hub editions β the full bank is delivered via model.yaml)
|
| 78 |
+
The bank template is 4.2 MB β over LM Studio's ~980 KB raw-GGUF cap, so for LM Studio use the **Hub virtual
|
| 79 |
+
models** (they hand the full template to the engine, no cap), which also carry the settings above:
|
| 80 |
+
- **thinking-OFF:** https://lmstudio.ai/mhndayesh/gemma-4-e2b-security-expert
|
| 81 |
+
- **thinking-ON:** https://lmstudio.ai/mhndayesh/gemma-4-e2b-security-expert-thinking
|
| 82 |
+
|
| 83 |
+
### llama.cpp / any OpenAI-compatible server (this GGUF, full bank embedded)
|
| 84 |
```bash
|
| 85 |
+
# thinking-OFF (recommended)
|
| 86 |
+
llama-server -m gemma-4-E2B-security-expert-Q4_K_M.gguf --jinja --ctx-size 32768 --port 8080
|
| 87 |
+
# thinking-ON
|
| 88 |
+
llama-server -m gemma-4-E2B-security-expert-thinking-Q4_K_M.gguf --jinja --ctx-size 32768 --port 8080
|
| 89 |
```
|
| 90 |
+
Sampling: `temperature 1.0, top_k 64, top_p 0.95, min_p 0.01`. Don't quantize the KV cache on small models.
|
| 91 |
+
Exposes an OpenAI-compatible API at `/v1`.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 92 |
|
| 93 |
## Limitations
|
| 94 |
+
- **Scoped to secure coding.** Outside it, base model.
|
| 95 |
+
- **Supplies knowledge, not reasoning** β still misses some multi-step fixes.
|
| 96 |
+
- **thinking-ON:** ~10% of hard prompts run long / blank (fails safe). Use thinking-OFF for reliability.
|
| 97 |
+
- **Keyword + faceted retrieval, not embeddings** β an unusual phrasing can miss. Research-grade; review output.
|
|
|
|
|
|
|
|
|
|
|
|
|
| 98 |
|
| 99 |
## Provenance & license
|
| 100 |
+
- **Base:** `lmstudio-community/gemma-4-E2B-it-GGUF` (weights untouched). Only `tokenizer.chat_template` is rewritten to embed an
|
| 101 |
+
inverted-index retriever + the bank (`factbank.version 0.4.0`).
|
| 102 |
+
- **License:** Google **Gemma Terms of Use** (`license: gemma`). Fact bank = FactBank-project content; mined
|
| 103 |
+
sources keep their own licenses.
|
|
|
|
| 104 |
- **Source & method:** [github.com/mhndayesh/experts-models](https://github.com/mhndayesh/experts-models).
|