NeuronLens
Browse the documentation
Guides

Screen a model before you deploy it

A short Python script that scans a fine-tune or merge and stops if its safety was stripped.


Run this before you adopt a new fine-tune or merge, or wire it into your release process. It scans the model, saves the signed report, fails on tampered, and warns on review and not_assessed. Standard library only.

# screen.py: python screen.py hf://org/name[@revision]
import json, os, sys, time, urllib.request

API = "https://api.neuronlens.com/v1/integrity"
HEAD = {"Authorization": f"Bearer {os.environ['NEURONLENS_API_KEY']}", "Content-Type": "application/json"}

def call(path, body=None):
    req = urllib.request.Request(API + path, headers=HEAD, method="POST" if body else "GET",
                                 data=json.dumps(body).encode() if body else None)
    with urllib.request.urlopen(req, timeout=60) as r:
        return json.loads(r.read())

scan = call("/scans", {"model": sys.argv[1]})
while scan["status"] not in ("done", "failed"):
    time.sleep(10)
    scan = call(f"/scans/{scan['scan_id']}")

if scan["status"] == "failed":
    sys.exit(f"Scan failed: {scan['error']['code']}: {scan['error']['message']}")

with open(f"{scan['scan_id']}.json", "w") as f:            # keep the signed report as your record
    json.dump(call(f"/scans/{scan['scan_id']}/report.json"), f)

print(f"{scan['model']['ref']} @ {scan['model']['revision'][:12]}: {scan['verdict']}")
print(scan.get("summary") or "")
if scan["verdict"] == "tampered":
    sys.exit("Safety training was removed: do not deploy.")
if scan["verdict"] == "review":
    print("WARNING: part of the refusal signal is gone; review before deploying.")
if scan["verdict"] == "not_assessed":
    print("Not assessed: see https://neuronlens.com/docs/integrity-lens/base-models")
$ python screen.py hf://mlabonne/gemma-3-4b-it-abliterated-v2
hf://mlabonne/gemma-3-4b-it-abliterated-v2 @ 375331eeafe1: tampered
Safety has been stripped. The internal refusal signal is largely gone, and models at this level answer most harmful requests.
Safety training was removed: do not deploy.

Tips

  • Pin the revision you deploy (@<commit>): the result then refers to exactly those weights, and a repeat scan of the same commit returns at once.
  • Check measured_against. If the model card names the wrong base, pass the right one as compare.
  • To block silent updates as well as stripped models, approve the version you ship and use the CI gate.