Downloads · 30 days
3
17% of all-time downloads
earnest-s/CyberShield-Gemma-4B-v2
CyberShield-Gemma-4B-v2 is a machine learning model from earnest-s. Use it for the machine learning task on the model card, and read the license before you ship it in a product. It is set up for peft. The card lists the license as unknown.
A fine-tuned Gemma 3 4B adapter for natural-language-to-software-architecture generation in CyberShield-Arch. This is the v2 successor to earnest-s/CyberShield-Gemma-4B, retrained on a canonicalized target representat…
Downloads · 30 days
3
17% of all-time downloads
All-time downloads
18
Public
Repo size
179 MB
Likes
0
Public
Click a slice to open those files.
.safetensors179 MB · 100%
From the Hugging Face model README
A fine-tuned Gemma 3 4B adapter for natural-language-to-software-architecture
generation in CyberShield-Arch. This is the v2 successor to
earnest-s/CyberShield-Gemma-4B,
retrained on a canonicalized target representation that makes structural fidelity
measurable and learnable.
This is an experimental research/project-demonstration model. It is not production-certified.
unsloth/gemma-3-4b-it-bnb-4bit (Gemma 3 4B, 4-bit NF4 quantized,
frozen) — taken from this adapter's adapter_config.jsonadapter_config.json)nodes,
edges, and architecture metadata:{
"nodes": [{ "id": "service-1", "type": "service" }],
"edges": [{ "source": "ui-1", "target": "service-1", "label": "HTTP" }]
}
The v2 training targets use a canonicalized representation:
{type}-{k} (e.g. ui-1,
service-2, database-1), assigned deterministically from the graph itself.
Node-id vocabulary collapses from ~28,703 arbitrary names to 45 canonical ids.(type, id) order; edges sorted by
(source, target, label) — 100% of targets deterministically ordered (vs 0–3% in v1).id_map (canonical id → original id)
plus the original architecture are retained in the dataset metadata.CyberShield_Gemma_SFT_v2_canonical — 51,498 records derived from real
architectures (ajibawa-2023/Technical-Architectures-Large via the CyberShield-Arch
pipeline); split 46,348 train / 2,575 validation / 2,575 test (held out).Measured on the untouched 2,575-record test split using a corrected non-truncating evaluation methodology (targets compared verbatim, never passed through size-capping parsers):
| Metric | V1 baseline | V2 |
|---|---|---|
| Node F1 | 0.237 | ~0.80 |
| Edge F1 | 0.069 | 0.656 |
| Structure-exact | 0% | 0.08% (2/2575) |
| Repetition failure | 0 | 0 |
| Generated node count | ~10.01 avg | exactly 10 for 2575/2575 |
Metric precision: structure-exact means the generated graph matches the target's component-type inventory and edge structure exactly. It is NOT name-level exact match — name-level exact match (exact node-id strings) remains 0% in both models. Node F1 here is computed against canonical ids, which measures type-inventory fidelity rather than reproduction of arbitrary original component names.
Runtime contract: ≤10 nodes / ≤15 edges; the integrated runtime returns v2 graphs untruncated (runtime truncation rate 0 after contract alignment).
unsloth/gemma-3-4b-it-bnb-4bit) and a CUDA-capable GPU; it is weights-only (no
tokenizer/config of its own beyond PEFT config).service-1, ui-2, …) are display labels; mapping back to
semantic component names requires the per-record id map kept in the project dataset.No license has been established for this adapter (license: unknown). The base model
unsloth/gemma-3-4b-it-bnb-4bit is subject to its own upstream terms (Google Gemma
license as distributed by the unsloth repository). The training data derives from
ajibawa-2023/Technical-Architectures-Large; see that dataset's terms. Use of this
adapter is additionally subject to the Gemma Terms of Use inherited from the base model.
import torch
from peft import PeftModel
from transformers import AutoModelForCausalLM, AutoTokenizer, BitsAndBytesConfig
base_id = "unsloth/gemma-3-4b-it-bnb-4bit"
adapter_id = "earnest-s/CyberShield-Gemma-4B-v2"
tokenizer = AutoTokenizer.from_pretrained(base_id)
if tokenizer.pad_token is None:
tokenizer.pad_token = tokenizer.eos_token
bnb = BitsAndBytesConfig(load_in_4bit=True, bnb_4bit_quant_type="nf4",
bnb_4bit_compute_dtype=torch.float16)
model = AutoModelForCausalLM.from_pretrained(base_id, device_map="auto",
quantization_config=bnb)
model = PeftModel.from_pretrained(model, adapter_id)
model.eval()
prompt = """You are a senior software architect.
Convert the following system description into a CLEAN architecture graph.
FORMAT:
{
"nodes": [
{"id": "ui-1", "type": "ui"},
{"id": "service-1", "type": "service"}
],
"edges": [
{"source": "ui-1", "target": "service-1", "label": "HTTP"}
]
}
CONSTRAINTS:
- Max nodes: 10
- Max edges: 15
Description:
A web frontend calls an API gateway that routes to order and payment services backed by PostgreSQL.
ONLY return JSON. No explanation.
"""
inputs = tokenizer(prompt, return_tensors="pt").to(model.device)
out = model.generate(**inputs, do_sample=False, repetition_penalty=1.1,
max_new_tokens=512)
print(tokenizer.decode(out[0][inputs["input_ids"].shape[1]:], skip_special_tokens=True))
Part of ArchitectAI / CyberShield-Arch — a local-first architecture generation and
editing workspace (FastAPI + React/React Flow) with a staged dataset pipeline and a
production security engine. Companion repositories/models:
earnest-s/CyberShield-Gemma-4B
(v1).