Run this model with HF Jobs
Run SkillJev/SkillJev-2B on Hugging Face's managed compute, monitor its progress, and retrieve the results when it's done.
Paste one of these prompts into your coding agent:
Fine-tune on my dataset
Use HF Jobs to fine-tune https://huggingface.co/SkillJev/SkillJev-2B. Ask me which dataset to train on, then push the fine-tuned model to a new model repo. Run `hf jobs --help` first to learn the CLI.
Run batch inference
Use HF Jobs to run batch inference with https://huggingface.co/SkillJev/SkillJev-2B on the inputs in a mounted HF Bucket. Ask me which Bucket to use, then write the outputs back to it and keep each input ID. Run `hf jobs --help` first to learn the CLI.
Instructions to use SkillJev/SkillJev-2B with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use SkillJev/SkillJev-2B with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-classification", model="SkillJev/SkillJev-2B")# pip install -U transformers accelerate # Load model directly from transformers import AutoProcessor, AutoModelForSequenceClassification processor = AutoProcessor.from_pretrained("SkillJev/SkillJev-2B") model = AutoModelForSequenceClassification.from_pretrained("SkillJev/SkillJev-2B", device_map="auto") - Notebooks
- Google Colab
- Kaggle
Release SkillJev-Direct v1 full model and original adapter
Browse filesFiles changed (14)
- README.md+13-59
- USAGE.mdAdded+32
- adapter/README.mdAdded+7
- adapter/USAGE.mdAdded+55
- adapter/adapter_config.jsonAdded+52
- adapter/adapter_model.safetensorsAdded+3
- adapter/chat_template.jinjaAdded+154
- adapter/scoring_config.jsonAdded+32
- adapter/tokenizer.jsonAdded+3
- adapter/tokenizer_config.jsonAdded+36
- merge_verification.jsonAdded+40
- score.pyAdded+58
- scoring_config.jsonAdded+32
- weights_manifest.jsonAdded+90
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192---pipeline_tag: text-classificationtags:- agent-security- nli- lora- skilljev- researchdatasets:- ProtectSkills/MaliciousSkillBench---# SkillJev-Direct-2BSkillJev-Direct-2B scores malicious AI-agent skills from `SKILL.md`, using [OpenJev 2B](https://huggingface.co/AlexWortega/openjev/tree/a20448012c213128955ca0c693e7c943865cab77/qwen3.5-2b-nli-v5), LoRA and a trained classification head. It returns a calibrated score without generating text.University of Toronto MScAC AI team, in collaboration with TrendAI.**Research preview:** training and frozen evaluation are complete; weights are not yet published here.## Results[MaliciousSkillBench](https://huggingface.co/datasets/ProtectSkills/MaliciousSkillBench/tree/d4b42ce5766a6e0359c987cf59c1007cb3795a90), official **Source-Balanced Random** protocol: 6,812 train / 973 validation / 1,950 test.| Method | Test recall | Benign false-positive rate ||---|---:|---:|| **SkillJev-Direct-2B** | **99.13%** | **5.57%** || Word-SVM | 99.40% | 40.98% || Untuned OpenJev-2B | 99.47% | 99.78% |Thresholds were frozen on validation, targeting 99% recall. Direct has **159 fewer false positives and four additional misses** than Word-SVM. One seed; sources are shared across partitions.## Model inputPremise: `SKILL.md`. Fixed hypothesis:> This AI agent skill is malicious.Run `direct-r002`: one epoch, 2.19M trainable parameters, 8,192-token limit. Long inputs retain the Markdown prefix and complete hypothesis. Calibration uses validation only.## Scope and availabilityMarkdown-only detection does not certify a complete package as safe; performance on other distributions is unverified.Adapter/head release terms are being reviewed. OpenJev is labelled MIT; third-party training texts retain their upstream terms. No skill payloads or TrendAI data are hosted here.**Team:** Jerrold Huang (Lead), Junwei Quan, HaoXuan Huang, Shiyi Yang.12345678910111213141516171819202122232425262728293031323334353637383940414243444546---library_name: transformerspipeline_tag: text-classificationbase_model: AlexWortega/openjevtags:- agent-security- nli- skilljev- researchdatasets:- ProtectSkills/MaliciousSkillBench---# SkillJev-2B**SkillJev-Direct v1** scores malicious AI-agent skills from `SKILL.md`, using [OpenJev 2B](https://huggingface.co/AlexWortega/openjev/tree/a20448012c213128955ca0c693e7c943865cab77/qwen3.5-2b-nli-v5), LoRA and a trained classification head. The scoring pipeline returns a calibrated score without generating text.University of Toronto MScAC AI team, in collaboration with TrendAI.## UseThe **complete merged model** is at the repository root; the original adapter and head are in [`adapter/`](https://huggingface.co/SkillJev/SkillJev-2B/blob/v1/adapter/README.md). Download version **`v1`**. See [the loading and scoring recipe](https://huggingface.co/SkillJev/SkillJev-2B/blob/v1/USAGE.md) and [`score.py`](https://huggingface.co/SkillJev/SkillJev-2B/blob/v1/score.py).Premise: `SKILL.md`. Fixed hypothesis:> This AI agent skill is malicious.The 8,192-token input retains the Markdown prefix and complete hypothesis. Use [`scoring_config.json`](https://huggingface.co/SkillJev/SkillJev-2B/blob/v1/scoring_config.json) for calibration and the frozen review threshold; native entailment softmax is not the calibrated probability.## Results[MaliciousSkillBench](https://huggingface.co/datasets/ProtectSkills/MaliciousSkillBench/tree/d4b42ce5766a6e0359c987cf59c1007cb3795a90), official **Source-Balanced Random** protocol: 6,812 train / 973 validation / 1,950 test.| Method | Test recall | Benign false-positive rate ||---|---:|---:|| **SkillJev-Direct merged v1** | **99.13%** | **5.57%** || Word-SVM | 99.40% | 40.98% || Untuned OpenJev-2B | 99.47% | 99.78% |Thresholds were frozen on validation, targeting 99% recall. Merged Direct has 159 fewer false positives and 4 additional misses than Word-SVM. One epoch, one seed; sources are shared across partitions. [Export verification](https://huggingface.co/SkillJev/SkillJev-2B/blob/v1/merge_verification.json) compares the merged model with the selected adapter using unchanged settings.## ScopeMarkdown-only detection does not certify a complete package as safe; performance on other distributions is unverified. OpenJev is labelled MIT; third-party training texts retain their upstream terms. No skill payloads or TrendAI data are hosted here.**Team:** Jerrold Huang (Lead), Junwei Quan, HaoXuan Huang, Shiyi Yang.
1234567891011121314151617181920212223242526272829303132# Using SkillJev-2B
The repository root contains the complete merged SkillJev-Direct model. No PEFT attachment or separate base-model download is needed. The original LoRA adapter and trained head are retained in [`adapter/`](https://huggingface.co/SkillJev/SkillJev-2B/blob/v1/adapter/README.md).
The verified recipe uses Python 3.12, PyTorch 2.11.0, Transformers 5.17.0, PEFT 0.21.2 and huggingface_hub 1.33.0 on CUDA/BF16, batch size 1. PEFT is needed only for the adapter route. The scorer limits GPU allocation to 8 GiB.
```bashpip install torch==2.11.0 transformers==5.17.0 huggingface_hub==1.33.0hf download SkillJev/SkillJev-2B score.py --revision v1 --local-dir skilljevpython skilljev/score.py path/to/SKILL.md```
The helper downloads the versioned full model and returns a JSON object with the calibrated malicious probability, threshold, review decision and truncation flag. It reads the supplied file as inert text.
For direct model loading:
```pythonimport torchfrom transformers import AutoModelForSequenceClassification, AutoTokenizer
tokenizer = AutoTokenizer.from_pretrained("SkillJev/SkillJev-2B", revision="v1")model = AutoModelForSequenceClassification.from_pretrained( "SkillJev/SkillJev-2B", revision="v1", dtype=torch.bfloat16, attn_implementation="sdpa", trust_remote_code=False,)```
Apply the input policy and scoring settings from [`scoring_config.json`](https://huggingface.co/SkillJev/SkillJev-2B/blob/v1/scoring_config.json), as implemented in [`score.py`](https://huggingface.co/SkillJev/SkillJev-2B/blob/v1/score.py). The exact input is `Premise: {SKILL.md}\nHypothesis: This AI agent skill is malicious.` Long inputs retain the prefix plus the complete hypothesis within 8,192 tokens. No generation or chat template is used.
The native labels are contradiction=0, entailment=1 and neutral=2. Compute `z = entailment - logaddexp(contradiction, neutral)`, then `p = sigmoid(0.76127103215625*z + 0.3934838733671388)`. The frozen review gate is `z >= -2.515625536875148`; its equivalent calibrated probability threshold is `0.17922765383653141`. Native entailment softmax is not the calibrated probability. The unused neutral class is not a validated uncertainty estimate.
[`merge_verification.json`](https://huggingface.co/SkillJev/SkillJev-2B/blob/v1/merge_verification.json) records a fresh-process native reload and comparisons with the unmerged selected adapter across all validation and test records, using unchanged calibration and thresholds. A score below the gate does not certify the full skill package as safe.1234567# SkillJev-Direct v1 adapter
The original selected LoRA weights and trained classification head are retained here. Use the [explicit pinned-base loading recipe](USAGE.md), including OpenJev's checkpoint subfolder. The complete merged model is available at the repository root.
Base: AlexWortega/openjev, subfolder qwen3.5-2b-nli-v5, revision a20448012c213128955ca0c693e7c943865cab77.
The weight bytes match the frozen direct-r002 update-426 export. Only portable adapter metadata and documentation changed.12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455# Loading SkillJev-Direct-2B
This is a LoRA adapter with its trained classification head, not a standalone copy of OpenJev's base weights. Load the pinned base **with its checkpoint subfolder**, then attach this adapter. A generic one-line `AutoPeftModel` call does not supply that subfolder.
The evaluated environment uses Python 3.12, PyTorch 2.11.0, Transformers 5.17.0, PEFT 0.21.2 and huggingface_hub 1.33.0. The frozen run uses CUDA/BF16 and batch size 1.
After downloading the release files into a local directory, use that directory as `release` below. `SKILL.md` is read as text.
```pythonimport jsonfrom pathlib import Pathimport torchfrom peft import PeftModelfrom transformers import AutoModelForSequenceClassification, AutoTokenizer
release = Path('.') # directory containing adapter weights and scoring_config.jsonsettings = json.loads((release / 'scoring_config.json').read_text())base = settings['base_model']tokenizer = AutoTokenizer.from_pretrained(release, trust_remote_code=False)assert tokenizer.num_special_tokens_to_add(False) == 0model = AutoModelForSequenceClassification.from_pretrained( base['repo_id'], subfolder=base['subfolder'], revision=base['revision'], dtype=torch.bfloat16, attn_implementation='sdpa', trust_remote_code=False,)assert model.config.label2id == settings['label2id']model.config.use_cache = model.config.text_config.use_cache = Falsemodel = PeftModel.from_pretrained(model.cuda(), release).eval()
text = Path('SKILL.md').read_text(encoding='utf-8')suffix = '\nHypothesis: ' + settings['input']['hypothesis']suffix_ids = tokenizer.encode(suffix, add_special_tokens=False)ids = tokenizer.encode('Premise: ' + text + suffix, add_special_tokens=False)original_tokens = len(ids)limit = settings['input']['max_length']if len(ids) > limit: ids = ids[:limit - len(suffix_ids)] + suffix_idsinput_ids = torch.tensor([ids], device='cuda')with torch.inference_mode(), torch.autocast('cuda', dtype=torch.bfloat16): logits = model(input_ids=input_ids, attention_mask=torch.ones_like(input_ids)).logits[0]logits = logits.float().cpu().double()assert torch.isfinite(logits).all()z = logits[1] - torch.logsumexp(logits[[0, 2]], dim=0)calibration = settings['calibration']p = torch.sigmoid(calibration['slope'] * z + calibration['intercept']).item()decision = settings['decision']print(json.dumps({ 'malicious_probability': p, 'threshold': decision['calibrated_probability_threshold'], 'review': z.item() >= decision['raw_log_odds_threshold'], 'truncated': original_tokens > limit,}))```
The decision uses the exact frozen raw-log-odds gate; the displayed probability uses its validation-fitted calibration. Native entailment softmax is not the calibrated probability. A score below the gate does not certify the full skill package as safe. No generation or chat template is used.
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152{ "alora_invocation_tokens": null, "alpha_pattern": {}, "arrow_config": null, "auto_mapping": null, "base_model_name_or_path": "AlexWortega/openjev", "bias": "none", "corda_config": null, "ensure_weight_tying": false, "eva_config": null, "exclude_modules": null, "fan_in_fan_out": false, "inference_mode": true, "init_lora_weights": true, "kasa_config": null, "layer_replication": null, "layers_pattern": null, "layers_to_transform": null, "loftq_config": {}, "lora_alpha": 16, "lora_bias": false, "lora_dropout": 0.0, "lora_ga_config": null, "megatron_config": null, "megatron_core": "megatron.core", "modules_to_save": [ "score", "classifier", "score" ], "monteclora_config": null, "peft_type": "LORA", "peft_version": "0.21.2", "qalora_group_size": 16, "r": 8, "rank_pattern": {}, "revision": "a20448012c213128955ca0c693e7c943865cab77", "target_modules": [ "in_proj_qkv", "v_proj", "q_proj", "out_proj" ], "target_parameters": null, "task_type": "SEQ_CLS", "trainable_token_indices": null, "use_bdlora": null, "use_dora": false, "use_qalora": false, "use_rslora": false, "velora_config": null}123version https://git-lfs.github.com/spec/v1oid sha256:a065bd76fbdd1c89958937211d8b1e00c5ac5aad33dcefbd2c3e6e1551364131size 8775920123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154{%- set image_count = namespace(value=0) %}{%- set video_count = namespace(value=0) %}{%- macro render_content(content, do_vision_count, is_system_content=false) %} {%- if content is string %} {{- content }} {%- elif content is iterable and content is not mapping %} {%- for item in content %} {%- if 'image' in item or 'image_url' in item or item.type == 'image' %} {%- if is_system_content %} {{- raise_exception('System message cannot contain images.') }} {%- endif %} {%- if do_vision_count %} {%- set image_count.value = image_count.value + 1 %} {%- endif %} {%- if add_vision_id %} {{- 'Picture ' ~ image_count.value ~ ': ' }} {%- endif %} {{- '<|vision_start|><|image_pad|><|vision_end|>' }} {%- elif 'video' in item or item.type == 'video' %} {%- if is_system_content %} {{- raise_exception('System message cannot contain videos.') }} {%- endif %} {%- if do_vision_count %} {%- set video_count.value = video_count.value + 1 %} {%- endif %} {%- if add_vision_id %} {{- 'Video ' ~ video_count.value ~ ': ' }} {%- endif %} {{- '<|vision_start|><|video_pad|><|vision_end|>' }} {%- elif 'text' in item %} {{- item.text }} {%- else %} {{- raise_exception('Unexpected item type in content.') }} {%- endif %} {%- endfor %} {%- elif content is none or content is undefined %} {{- '' }} {%- else %} {{- raise_exception('Unexpected content type.') }} {%- endif %}{%- endmacro %}{%- if not messages %} {{- raise_exception('No messages provided.') }}{%- endif %}{%- if tools and tools is iterable and tools is not mapping %} {{- '<|im_start|>system\n' }} {{- "# Tools\n\nYou have access to the following functions:\n\n<tools>" }} {%- for tool in tools %} {{- "\n" }} {{- tool | tojson }} {%- endfor %} {{- "\n</tools>" }} {{- '\n\nIf you choose to call a function ONLY reply in the following format with NO suffix:\n\n<tool_call>\n<function=example_function_name>\n<parameter=example_parameter_1>\nvalue_1\n</parameter>\n<parameter=example_parameter_2>\nThis is the value for the second parameter\nthat can span\nmultiple lines\n</parameter>\n</function>\n</tool_call>\n\n<IMPORTANT>\nReminder:\n- Function calls MUST follow the specified format: an inner <function=...></function> block must be nested within <tool_call></tool_call> XML tags\n- Required parameters MUST be specified\n- You may provide optional reasoning for your function call in natural language BEFORE the function call, but NOT after\n- If there is no function call available, answer the question like normal with your current knowledge and do not tell the user about function calls\n</IMPORTANT>' }} {%- if messages[0].role == 'system' %} {%- set content = render_content(messages[0].content, false, true)|trim %} {%- if content %} {{- '\n\n' + content }} {%- endif %} {%- endif %} {{- '<|im_end|>\n' }}{%- else %} {%- if messages[0].role == 'system' %} {%- set content = render_content(messages[0].content, false, true)|trim %} {{- '<|im_start|>system\n' + content + '<|im_end|>\n' }} {%- endif %}{%- endif %}{%- set ns = namespace(multi_step_tool=true, last_query_index=messages|length - 1) %}{%- for message in messages[::-1] %} {%- set index = (messages|length - 1) - loop.index0 %} {%- if ns.multi_step_tool and message.role == "user" %} {%- set content = render_content(message.content, false)|trim %} {%- if not(content.startswith('<tool_response>') and content.endswith('</tool_response>')) %} {%- set ns.multi_step_tool = false %} {%- set ns.last_query_index = index %} {%- endif %} {%- endif %}{%- endfor %}{%- if ns.multi_step_tool %} {{- raise_exception('No user query found in messages.') }}{%- endif %}{%- for message in messages %} {%- set content = render_content(message.content, true)|trim %} {%- if message.role == "system" %} {%- if not loop.first %} {{- raise_exception('System message must be at the beginning.') }} {%- endif %} {%- elif message.role == "user" %} {{- '<|im_start|>' + message.role + '\n' + content + '<|im_end|>' + '\n' }} {%- elif message.role == "assistant" %} {%- set reasoning_content = '' %} {%- if message.reasoning_content is string %} {%- set reasoning_content = message.reasoning_content %} {%- else %} {%- if '</think>' in content %} {%- set reasoning_content = content.split('</think>')[0].rstrip('\n').split('<think>')[-1].lstrip('\n') %} {%- set content = content.split('</think>')[-1].lstrip('\n') %} {%- endif %} {%- endif %} {%- set reasoning_content = reasoning_content|trim %} {%- if loop.index0 > ns.last_query_index %} {{- '<|im_start|>' + message.role + '\n<think>\n' + reasoning_content + '\n</think>\n\n' + content }} {%- else %} {{- '<|im_start|>' + message.role + '\n' + content }} {%- endif %} {%- if message.tool_calls and message.tool_calls is iterable and message.tool_calls is not mapping %} {%- for tool_call in message.tool_calls %} {%- if tool_call.function is defined %} {%- set tool_call = tool_call.function %} {%- endif %} {%- if loop.first %} {%- if content|trim %} {{- '\n\n<tool_call>\n<function=' + tool_call.name + '>\n' }} {%- else %} {{- '<tool_call>\n<function=' + tool_call.name + '>\n' }} {%- endif %} {%- else %} {{- '\n<tool_call>\n<function=' + tool_call.name + '>\n' }} {%- endif %} {%- if tool_call.arguments is defined %} {%- for args_name, args_value in tool_call.arguments|items %} {{- '<parameter=' + args_name + '>\n' }} {%- set args_value = args_value | tojson | safe if args_value is mapping or (args_value is sequence and args_value is not string) else args_value | string %} {{- args_value }} {{- '\n</parameter>\n' }} {%- endfor %} {%- endif %} {{- '</function>\n</tool_call>' }} {%- endfor %} {%- endif %} {{- '<|im_end|>\n' }} {%- elif message.role == "tool" %} {%- if loop.previtem and loop.previtem.role != "tool" %} {{- '<|im_start|>user' }} {%- endif %} {{- '\n<tool_response>\n' }} {{- content }} {{- '\n</tool_response>' }} {%- if not loop.last and loop.nextitem.role != "tool" %} {{- '<|im_end|>\n' }} {%- elif loop.last %} {{- '<|im_end|>\n' }} {%- endif %} {%- else %} {{- raise_exception('Unexpected message role.') }} {%- endif %}{%- endfor %}{%- if add_generation_prompt %} {{- '<|im_start|>assistant\n' }} {%- if enable_thinking is defined and enable_thinking is true %} {{- '<think>\n' }} {%- else %} {{- '<think>\n\n</think>\n\n' }} {%- endif %}{%- endif %}1234567891011121314151617181920212223242526272829303132{ "run_id": "direct-r002", "base_model": { "repo_id": "AlexWortega/openjev", "subfolder": "qwen3.5-2b-nli-v5", "revision": "a20448012c213128955ca0c693e7c943865cab77" }, "input": { "scope": "SKILL.md only", "max_length": 8192, "hypothesis": "This AI agent skill is malicious.", "template": "Premise: {skill_text}\nHypothesis: {hypothesis}", "truncation": "Premise prefix plus complete fixed hypothesis" }, "label2id": { "contradiction": 0, "entailment": 1, "neutral": 2 }, "calibration": { "method": "positive_sigmoid_log_odds", "slope": 0.76127103215625, "intercept": 0.3934838733671388, "fit_partition": "validation", "formula": "p = sigmoid(slope * (entailment - logaddexp(contradiction, neutral)) + intercept)" }, "decision": { "comparator": ">=", "raw_log_odds_threshold": -2.515625536875148, "calibrated_probability_threshold": 0.17922765383653141 }}123version https://git-lfs.github.com/spec/v1oid sha256:f399b3cd12fa270d51457bb749fb30863521e8359b8a27059c71b6c2f7d6dd6csize 19989424123456789101112131415161718192021222324252627282930313233343536{ "add_prefix_space": false, "audio_bos_token": "<|audio_start|>", "audio_eos_token": "<|audio_end|>", "audio_token": "<|audio_pad|>", "backend": "tokenizers", "bos_token": null, "clean_up_tokenization_spaces": false, "eos_token": "<|im_end|>", "errors": "replace", "image_token": "<|image_pad|>", "is_local": true, "local_files_only": true, "max_length": 1024, "model_max_length": 262144, "model_specific_special_tokens": { "audio_bos_token": "<|audio_start|>", "audio_eos_token": "<|audio_end|>", "audio_token": "<|audio_pad|>", "image_token": "<|image_pad|>", "video_token": "<|video_pad|>", "vision_bos_token": "<|vision_start|>", "vision_eos_token": "<|vision_end|>" }, "pad_token": "<|endoftext|>", "pretokenize_regex": "(?i:'s|'t|'re|'ve|'m|'ll|'d)|[^\\r\\n\\p{L}\\p{N}]?[\\p{L}\\p{M}]+|\\p{N}| ?[^\\s\\p{L}\\p{M}\\p{N}]+[\\r\\n]*|\\s*[\\r\\n]+|\\s+(?!\\S)|\\s+", "split_special_tokens": false, "stride": 0, "tokenizer_class": "Qwen2Tokenizer", "truncation_side": "right", "truncation_strategy": "longest_first", "unk_token": null, "video_token": "<|video_pad|>", "vision_bos_token": "<|vision_start|>", "vision_eos_token": "<|vision_end|>"}12345678910111213141516171819202122232425262728293031323334353637383940{ "fresh_process_native_load": true, "frozen_calibration_and_threshold_unchanged": true, "partitions": { "validation": { "records": 973, "max_logit_difference": 0.1875, "max_raw_log_odds_difference": 0.3281247489544863, "max_calibrated_probability_difference": 0.061614418874079147, "review_disagreements": 1, "tp": 742, "fp": 17, "tn": 206, "fn": 8, "recall": 0.9893333333333333, "fpr": 0.07623318385650224 }, "test": { "records": 1950, "max_logit_difference": 0.1875, "max_raw_log_odds_difference": 0.21874973440485856, "max_calibrated_probability_difference": 0.023134370893243994, "review_disagreements": 0, "tp": 1488, "fp": 25, "tn": 424, "fn": 13, "recall": 0.9913391072618255, "fpr": 0.0556792873051225 } }, "peak_gpu_allocated_gib": 5.09755802154541, "elapsed_seconds": 804.6106737367809, "public_scoring_helper": { "fresh_process_passed": true, "validation_index": 0, "probability_difference": 0.0, "review_decision_matches": true }}12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758"""Score one SKILL.md with the full SkillJev-2B model; never execute its text."""import argparseimport jsonfrom pathlib import Path
import torchfrom huggingface_hub import hf_hub_downloadfrom transformers import AutoModelForSequenceClassification, AutoTokenizer
def main(): parser = argparse.ArgumentParser(description=__doc__) parser.add_argument("skill", type=Path) parser.add_argument("--model", default="SkillJev/SkillJev-2B") parser.add_argument("--revision", default="v1") args = parser.parse_args() if not torch.cuda.is_available(): raise RuntimeError("This release recipe requires CUDA with BF16 support") total = torch.cuda.get_device_properties(0).total_memory torch.cuda.set_per_process_memory_fraction(min(1., 8 * 1024**3 / total)) local = Path(args.model).is_dir() config = Path(args.model) / "scoring_config.json" if local else Path( hf_hub_download(args.model, "scoring_config.json", revision=args.revision)) settings = json.loads(config.read_text()) options = {"local_files_only": True} if local else {"revision": args.revision} tokenizer = AutoTokenizer.from_pretrained(args.model, trust_remote_code=False, **options) model = AutoModelForSequenceClassification.from_pretrained(args.model, dtype=torch.bfloat16, attn_implementation="sdpa", trust_remote_code=False, **options) assert model.config.label2id == settings["label2id"] assert tokenizer.num_special_tokens_to_add(False) == 0 tokenizer.pad_token_id = model.config.pad_token_id model.config.use_cache = model.config.text_config.use_cache = False model = model.cuda().eval() text = args.skill.read_text(encoding="utf-8") suffix = "\nHypothesis: " + settings["input"]["hypothesis"] suffix_ids = tokenizer.encode(suffix, add_special_tokens=False) ids = tokenizer.encode("Premise: " + text + suffix, add_special_tokens=False) original_tokens = len(ids) limit = settings["input"]["max_length"] if len(ids) > limit: ids = ids[:limit - len(suffix_ids)] + suffix_ids inputs = torch.tensor([ids], device="cuda") with torch.inference_mode(), torch.autocast("cuda", dtype=torch.bfloat16): logits = model(input_ids=inputs, attention_mask=torch.ones_like(inputs)).logits[0] logits = logits.float().cpu().double() assert torch.isfinite(logits).all() z = logits[1] - torch.logsumexp(logits[[0, 2]], dim=0) calibration = settings["calibration"] p = torch.sigmoid(calibration["slope"] * z + calibration["intercept"]).item() decision = settings["decision"] print(json.dumps({"skill_id": args.skill.name, "malicious_probability": p, "threshold": decision["calibrated_probability_threshold"], "review": z.item() >= decision["raw_log_odds_threshold"], "truncated": original_tokens > limit}, indent=2))
if __name__ == "__main__": main()1234567891011121314151617181920212223242526272829303132{ "run_id": "direct-r002", "base_model": { "repo_id": "AlexWortega/openjev", "subfolder": "qwen3.5-2b-nli-v5", "revision": "a20448012c213128955ca0c693e7c943865cab77" }, "input": { "scope": "SKILL.md only", "max_length": 8192, "hypothesis": "This AI agent skill is malicious.", "template": "Premise: {skill_text}\nHypothesis: {hypothesis}", "truncation": "Premise prefix plus complete fixed hypothesis" }, "label2id": { "contradiction": 0, "entailment": 1, "neutral": 2 }, "calibration": { "method": "positive_sigmoid_log_odds", "slope": 0.76127103215625, "intercept": 0.3934838733671388, "fit_partition": "validation", "formula": "p = sigmoid(slope * (entailment - logaddexp(contradiction, neutral)) + intercept)" }, "decision": { "comparator": ">=", "raw_log_odds_threshold": -2.515625536875148, "calibrated_probability_threshold": 0.17922765383653141 }}123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990{ "README.md": { "bytes": 2510, "sha256": "e5c55d1d47c0ab471b32ffb70e685479444673868744434a1d6caaaefb947bec" }, "USAGE.md": { "bytes": 2579, "sha256": "a642b40fd844a4302600f4158d1bb2e98a3d5bb2f161edac778bfac0bac535c2" }, "adapter/README.md": { "bytes": 510, "sha256": "924c6f0c184e3f77dc7b033c934c1a2ce66a58c6519cf26bd815560ecf801924" }, "adapter/USAGE.md": { "bytes": 2883, "sha256": "03eadb8f48934f604e1386354d0af7e958427be898fcb7760bda0c18fcb97040" }, "adapter/adapter_config.json": { "bytes": 1212, "sha256": "a9b842d3d9e80de133c92b571a1c05c9dadc611a8e49b10d6f820bdc4e754344" }, "adapter/adapter_model.safetensors": { "bytes": 8775920, "sha256": "a065bd76fbdd1c89958937211d8b1e00c5ac5aad33dcefbd2c3e6e1551364131" }, "adapter/chat_template.jinja": { "bytes": 7755, "sha256": "273d8e0e683b885071fb17e08d71e5f2a5ddfb5309756181681de4f5a1822d80" }, "adapter/scoring_config.json": { "bytes": 955, "sha256": "3fcc51fd072005806778f9d00e7247af3b9e4a5dfb93b16c37d2ff6012c1eaba" }, "adapter/tokenizer.json": { "bytes": 19989424, "sha256": "f399b3cd12fa270d51457bb749fb30863521e8359b8a27059c71b6c2f7d6dd6c" }, "adapter/tokenizer_config.json": { "bytes": 1232, "sha256": "1b4aa963b7ff602051283ab9d794c44e4a3b65a806668a66e2312f1b641c0caa" }, "chat_template.jinja": { "bytes": 7755, "sha256": "273d8e0e683b885071fb17e08d71e5f2a5ddfb5309756181681de4f5a1822d80" }, "config.json": { "bytes": 3051, "sha256": "2ff7404369a6c8efbef3da39842aeceaf91d5eeb053df51b38b0c68be07320e3" }, "export_provenance.json": { "bytes": 756, "sha256": "0b8e8433b1a3d53da399a04a87091fe63ceb91ae68fb7c7cd6fe80a035b2a6e0" }, "merge_verification.json": { "bytes": 1125, "sha256": "0229b650267793bf503322770f127898cf02ae5788df966892940d2e10ce52f4" }, "model-00001-of-00003.safetensors": { "bytes": 1999936744, "sha256": "92ce5f9398a5f5bd66e9795fc6ce828c1e2e6bfe147fa6df832b4777700c5569" }, "model-00002-of-00003.safetensors": { "bytes": 1998904824, "sha256": "3a04c5844dd925bcb7169351375284955dcff3cfe4cd4ff6b0744e7d555e09aa" }, "model-00003-of-00003.safetensors": { "bytes": 427728976, "sha256": "c04a8541fc1c59c4c69903666e0eb642a194af6cd6f089de5bf011e13c92e917" }, "model.safetensors.index.json": { "bytes": 55828, "sha256": "f32e6ba64583661c012316227a4a9b764fd663c430060886bfee4776d3d516c6" }, "score.py": { "bytes": 2906, "sha256": "6afc99a1d984a5a7d87314322df46518297e4b033eb27d42ee4af2fe15610923" }, "scoring_config.json": { "bytes": 955, "sha256": "3fcc51fd072005806778f9d00e7247af3b9e4a5dfb93b16c37d2ff6012c1eaba" }, "tokenizer.json": { "bytes": 19989424, "sha256": "f399b3cd12fa270d51457bb749fb30863521e8359b8a27059c71b6c2f7d6dd6c" }, "tokenizer_config.json": { "bytes": 1232, "sha256": "1b4aa963b7ff602051283ab9d794c44e4a3b65a806668a66e2312f1b641c0caa" }}README.md+13-59
USAGE.mdAdded+32
adapter/README.mdAdded+7
adapter/USAGE.mdAdded+55
adapter/adapter_config.jsonAdded+52
adapter/adapter_model.safetensorsAdded+3
adapter/chat_template.jinjaAdded+154
adapter/scoring_config.jsonAdded+32
adapter/tokenizer.jsonAdded+3
adapter/tokenizer_config.jsonAdded+36
merge_verification.jsonAdded+40
score.pyAdded+58
scoring_config.jsonAdded+32
weights_manifest.jsonAdded+90