JerroldH commited on
Commit
0979056
·
verified ·
1 Parent(s): f862ba5

Release SkillJev-Direct v1 full model and original adapter

Browse files
README.md CHANGED
@@ -1,92 +1,46 @@
1
  ---
 
2
  pipeline_tag: text-classification
 
3
  tags:
4
  - agent-security
5
  - nli
6
- - lora
7
  - skilljev
8
  - research
9
  datasets:
10
  - ProtectSkills/MaliciousSkillBench
11
  ---
12
 
 
13
 
14
-
15
-
16
- # SkillJev-Direct-2B
17
-
18
-
19
-
20
-
21
- SkillJev-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.
22
-
23
-
24
-
25
 
26
  University of Toronto MScAC AI team, in collaboration with TrendAI.
27
 
 
28
 
 
29
 
 
30
 
31
- **Research preview:** training and frozen evaluation are complete; weights are not yet published here.
32
-
33
-
34
 
 
35
 
36
  ## Results
37
 
38
-
39
-
40
-
41
  [MaliciousSkillBench](https://huggingface.co/datasets/ProtectSkills/MaliciousSkillBench/tree/d4b42ce5766a6e0359c987cf59c1007cb3795a90), official **Source-Balanced Random** protocol: 6,812 train / 973 validation / 1,950 test.
42
 
43
-
44
-
45
-
46
  | Method | Test recall | Benign false-positive rate |
47
  |---|---:|---:|
48
- | **SkillJev-Direct-2B** | **99.13%** | **5.57%** |
49
  | Word-SVM | 99.40% | 40.98% |
50
  | Untuned OpenJev-2B | 99.47% | 99.78% |
51
 
 
52
 
 
53
 
54
-
55
- 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.
56
-
57
-
58
-
59
-
60
- ## Model input
61
-
62
-
63
-
64
-
65
- Premise: `SKILL.md`. Fixed hypothesis:
66
-
67
-
68
-
69
-
70
- > This AI agent skill is malicious.
71
-
72
-
73
-
74
-
75
- 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.
76
-
77
-
78
-
79
-
80
- ## Scope and availability
81
-
82
-
83
-
84
-
85
- Markdown-only detection does not certify a complete package as safe; performance on other distributions is unverified.
86
-
87
-
88
-
89
-
90
- 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.
91
 
92
  **Team:** Jerrold Huang (Lead), Junwei Quan, HaoXuan Huang, Shiyi Yang.
 
1
  ---
2
+ library_name: transformers
3
  pipeline_tag: text-classification
4
+ base_model: AlexWortega/openjev
5
  tags:
6
  - agent-security
7
  - nli
 
8
  - skilljev
9
  - research
10
  datasets:
11
  - ProtectSkills/MaliciousSkillBench
12
  ---
13
 
14
+ # SkillJev-2B
15
 
16
+ **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.
 
 
 
 
 
 
 
 
 
 
17
 
18
  University of Toronto MScAC AI team, in collaboration with TrendAI.
19
 
20
+ ## Use
21
 
22
+ The **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).
23
 
24
+ Premise: `SKILL.md`. Fixed hypothesis:
25
 
26
+ > This AI agent skill is malicious.
 
 
27
 
28
+ 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.
29
 
30
  ## Results
31
 
 
 
 
32
  [MaliciousSkillBench](https://huggingface.co/datasets/ProtectSkills/MaliciousSkillBench/tree/d4b42ce5766a6e0359c987cf59c1007cb3795a90), official **Source-Balanced Random** protocol: 6,812 train / 973 validation / 1,950 test.
33
 
 
 
 
34
  | Method | Test recall | Benign false-positive rate |
35
  |---|---:|---:|
36
+ | **SkillJev-Direct merged v1** | **99.13%** | **5.57%** |
37
  | Word-SVM | 99.40% | 40.98% |
38
  | Untuned OpenJev-2B | 99.47% | 99.78% |
39
 
40
+ 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.
41
 
42
+ ## Scope
43
 
44
+ Markdown-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.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
45
 
46
  **Team:** Jerrold Huang (Lead), Junwei Quan, HaoXuan Huang, Shiyi Yang.
USAGE.md ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Using SkillJev-2B
2
+
3
+ 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).
4
+
5
+ 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.
6
+
7
+ ```bash
8
+ pip install torch==2.11.0 transformers==5.17.0 huggingface_hub==1.33.0
9
+ hf download SkillJev/SkillJev-2B score.py --revision v1 --local-dir skilljev
10
+ python skilljev/score.py path/to/SKILL.md
11
+ ```
12
+
13
+ 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.
14
+
15
+ For direct model loading:
16
+
17
+ ```python
18
+ import torch
19
+ from transformers import AutoModelForSequenceClassification, AutoTokenizer
20
+
21
+ tokenizer = AutoTokenizer.from_pretrained("SkillJev/SkillJev-2B", revision="v1")
22
+ model = AutoModelForSequenceClassification.from_pretrained(
23
+ "SkillJev/SkillJev-2B", revision="v1",
24
+ dtype=torch.bfloat16, attn_implementation="sdpa", trust_remote_code=False,
25
+ )
26
+ ```
27
+
28
+ 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.
29
+
30
+ 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.
31
+
32
+ [`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.
adapter/README.md ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
 
1
+ # SkillJev-Direct v1 adapter
2
+
3
+ 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.
4
+
5
+ Base: AlexWortega/openjev, subfolder qwen3.5-2b-nli-v5, revision a20448012c213128955ca0c693e7c943865cab77.
6
+
7
+ The weight bytes match the frozen direct-r002 update-426 export. Only portable adapter metadata and documentation changed.
adapter/USAGE.md ADDED
@@ -0,0 +1,55 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Loading SkillJev-Direct-2B
2
+
3
+ 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.
4
+
5
+ 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.
6
+
7
+ After downloading the release files into a local directory, use that directory as `release` below. `SKILL.md` is read as text.
8
+
9
+ ```python
10
+ import json
11
+ from pathlib import Path
12
+ import torch
13
+ from peft import PeftModel
14
+ from transformers import AutoModelForSequenceClassification, AutoTokenizer
15
+
16
+ release = Path('.') # directory containing adapter weights and scoring_config.json
17
+ settings = json.loads((release / 'scoring_config.json').read_text())
18
+ base = settings['base_model']
19
+ tokenizer = AutoTokenizer.from_pretrained(release, trust_remote_code=False)
20
+ assert tokenizer.num_special_tokens_to_add(False) == 0
21
+ model = AutoModelForSequenceClassification.from_pretrained(
22
+ base['repo_id'], subfolder=base['subfolder'], revision=base['revision'],
23
+ dtype=torch.bfloat16, attn_implementation='sdpa', trust_remote_code=False,
24
+ )
25
+ assert model.config.label2id == settings['label2id']
26
+ model.config.use_cache = model.config.text_config.use_cache = False
27
+ model = PeftModel.from_pretrained(model.cuda(), release).eval()
28
+
29
+ text = Path('SKILL.md').read_text(encoding='utf-8')
30
+ suffix = '\nHypothesis: ' + settings['input']['hypothesis']
31
+ suffix_ids = tokenizer.encode(suffix, add_special_tokens=False)
32
+ ids = tokenizer.encode('Premise: ' + text + suffix, add_special_tokens=False)
33
+ original_tokens = len(ids)
34
+ limit = settings['input']['max_length']
35
+ if len(ids) > limit:
36
+ ids = ids[:limit - len(suffix_ids)] + suffix_ids
37
+ input_ids = torch.tensor([ids], device='cuda')
38
+ with torch.inference_mode(), torch.autocast('cuda', dtype=torch.bfloat16):
39
+ logits = model(input_ids=input_ids, attention_mask=torch.ones_like(input_ids)).logits[0]
40
+ logits = logits.float().cpu().double()
41
+ assert torch.isfinite(logits).all()
42
+ z = logits[1] - torch.logsumexp(logits[[0, 2]], dim=0)
43
+ calibration = settings['calibration']
44
+ p = torch.sigmoid(calibration['slope'] * z + calibration['intercept']).item()
45
+ decision = settings['decision']
46
+ print(json.dumps({
47
+ 'malicious_probability': p,
48
+ 'threshold': decision['calibrated_probability_threshold'],
49
+ 'review': z.item() >= decision['raw_log_odds_threshold'],
50
+ 'truncated': original_tokens > limit,
51
+ }))
52
+ ```
53
+
54
+ 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.
55
+
adapter/adapter_config.json ADDED
@@ -0,0 +1,52 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "alora_invocation_tokens": null,
3
+ "alpha_pattern": {},
4
+ "arrow_config": null,
5
+ "auto_mapping": null,
6
+ "base_model_name_or_path": "AlexWortega/openjev",
7
+ "bias": "none",
8
+ "corda_config": null,
9
+ "ensure_weight_tying": false,
10
+ "eva_config": null,
11
+ "exclude_modules": null,
12
+ "fan_in_fan_out": false,
13
+ "inference_mode": true,
14
+ "init_lora_weights": true,
15
+ "kasa_config": null,
16
+ "layer_replication": null,
17
+ "layers_pattern": null,
18
+ "layers_to_transform": null,
19
+ "loftq_config": {},
20
+ "lora_alpha": 16,
21
+ "lora_bias": false,
22
+ "lora_dropout": 0.0,
23
+ "lora_ga_config": null,
24
+ "megatron_config": null,
25
+ "megatron_core": "megatron.core",
26
+ "modules_to_save": [
27
+ "score",
28
+ "classifier",
29
+ "score"
30
+ ],
31
+ "monteclora_config": null,
32
+ "peft_type": "LORA",
33
+ "peft_version": "0.21.2",
34
+ "qalora_group_size": 16,
35
+ "r": 8,
36
+ "rank_pattern": {},
37
+ "revision": "a20448012c213128955ca0c693e7c943865cab77",
38
+ "target_modules": [
39
+ "in_proj_qkv",
40
+ "v_proj",
41
+ "q_proj",
42
+ "out_proj"
43
+ ],
44
+ "target_parameters": null,
45
+ "task_type": "SEQ_CLS",
46
+ "trainable_token_indices": null,
47
+ "use_bdlora": null,
48
+ "use_dora": false,
49
+ "use_qalora": false,
50
+ "use_rslora": false,
51
+ "velora_config": null
52
+ }
adapter/adapter_model.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:a065bd76fbdd1c89958937211d8b1e00c5ac5aad33dcefbd2c3e6e1551364131
3
+ size 8775920
adapter/chat_template.jinja ADDED
@@ -0,0 +1,154 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {%- set image_count = namespace(value=0) %}
2
+ {%- set video_count = namespace(value=0) %}
3
+ {%- macro render_content(content, do_vision_count, is_system_content=false) %}
4
+ {%- if content is string %}
5
+ {{- content }}
6
+ {%- elif content is iterable and content is not mapping %}
7
+ {%- for item in content %}
8
+ {%- if 'image' in item or 'image_url' in item or item.type == 'image' %}
9
+ {%- if is_system_content %}
10
+ {{- raise_exception('System message cannot contain images.') }}
11
+ {%- endif %}
12
+ {%- if do_vision_count %}
13
+ {%- set image_count.value = image_count.value + 1 %}
14
+ {%- endif %}
15
+ {%- if add_vision_id %}
16
+ {{- 'Picture ' ~ image_count.value ~ ': ' }}
17
+ {%- endif %}
18
+ {{- '<|vision_start|><|image_pad|><|vision_end|>' }}
19
+ {%- elif 'video' in item or item.type == 'video' %}
20
+ {%- if is_system_content %}
21
+ {{- raise_exception('System message cannot contain videos.') }}
22
+ {%- endif %}
23
+ {%- if do_vision_count %}
24
+ {%- set video_count.value = video_count.value + 1 %}
25
+ {%- endif %}
26
+ {%- if add_vision_id %}
27
+ {{- 'Video ' ~ video_count.value ~ ': ' }}
28
+ {%- endif %}
29
+ {{- '<|vision_start|><|video_pad|><|vision_end|>' }}
30
+ {%- elif 'text' in item %}
31
+ {{- item.text }}
32
+ {%- else %}
33
+ {{- raise_exception('Unexpected item type in content.') }}
34
+ {%- endif %}
35
+ {%- endfor %}
36
+ {%- elif content is none or content is undefined %}
37
+ {{- '' }}
38
+ {%- else %}
39
+ {{- raise_exception('Unexpected content type.') }}
40
+ {%- endif %}
41
+ {%- endmacro %}
42
+ {%- if not messages %}
43
+ {{- raise_exception('No messages provided.') }}
44
+ {%- endif %}
45
+ {%- if tools and tools is iterable and tools is not mapping %}
46
+ {{- '<|im_start|>system\n' }}
47
+ {{- "# Tools\n\nYou have access to the following functions:\n\n<tools>" }}
48
+ {%- for tool in tools %}
49
+ {{- "\n" }}
50
+ {{- tool | tojson }}
51
+ {%- endfor %}
52
+ {{- "\n</tools>" }}
53
+ {{- '\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>' }}
54
+ {%- if messages[0].role == 'system' %}
55
+ {%- set content = render_content(messages[0].content, false, true)|trim %}
56
+ {%- if content %}
57
+ {{- '\n\n' + content }}
58
+ {%- endif %}
59
+ {%- endif %}
60
+ {{- '<|im_end|>\n' }}
61
+ {%- else %}
62
+ {%- if messages[0].role == 'system' %}
63
+ {%- set content = render_content(messages[0].content, false, true)|trim %}
64
+ {{- '<|im_start|>system\n' + content + '<|im_end|>\n' }}
65
+ {%- endif %}
66
+ {%- endif %}
67
+ {%- set ns = namespace(multi_step_tool=true, last_query_index=messages|length - 1) %}
68
+ {%- for message in messages[::-1] %}
69
+ {%- set index = (messages|length - 1) - loop.index0 %}
70
+ {%- if ns.multi_step_tool and message.role == "user" %}
71
+ {%- set content = render_content(message.content, false)|trim %}
72
+ {%- if not(content.startswith('<tool_response>') and content.endswith('</tool_response>')) %}
73
+ {%- set ns.multi_step_tool = false %}
74
+ {%- set ns.last_query_index = index %}
75
+ {%- endif %}
76
+ {%- endif %}
77
+ {%- endfor %}
78
+ {%- if ns.multi_step_tool %}
79
+ {{- raise_exception('No user query found in messages.') }}
80
+ {%- endif %}
81
+ {%- for message in messages %}
82
+ {%- set content = render_content(message.content, true)|trim %}
83
+ {%- if message.role == "system" %}
84
+ {%- if not loop.first %}
85
+ {{- raise_exception('System message must be at the beginning.') }}
86
+ {%- endif %}
87
+ {%- elif message.role == "user" %}
88
+ {{- '<|im_start|>' + message.role + '\n' + content + '<|im_end|>' + '\n' }}
89
+ {%- elif message.role == "assistant" %}
90
+ {%- set reasoning_content = '' %}
91
+ {%- if message.reasoning_content is string %}
92
+ {%- set reasoning_content = message.reasoning_content %}
93
+ {%- else %}
94
+ {%- if '</think>' in content %}
95
+ {%- set reasoning_content = content.split('</think>')[0].rstrip('\n').split('<think>')[-1].lstrip('\n') %}
96
+ {%- set content = content.split('</think>')[-1].lstrip('\n') %}
97
+ {%- endif %}
98
+ {%- endif %}
99
+ {%- set reasoning_content = reasoning_content|trim %}
100
+ {%- if loop.index0 > ns.last_query_index %}
101
+ {{- '<|im_start|>' + message.role + '\n<think>\n' + reasoning_content + '\n</think>\n\n' + content }}
102
+ {%- else %}
103
+ {{- '<|im_start|>' + message.role + '\n' + content }}
104
+ {%- endif %}
105
+ {%- if message.tool_calls and message.tool_calls is iterable and message.tool_calls is not mapping %}
106
+ {%- for tool_call in message.tool_calls %}
107
+ {%- if tool_call.function is defined %}
108
+ {%- set tool_call = tool_call.function %}
109
+ {%- endif %}
110
+ {%- if loop.first %}
111
+ {%- if content|trim %}
112
+ {{- '\n\n<tool_call>\n<function=' + tool_call.name + '>\n' }}
113
+ {%- else %}
114
+ {{- '<tool_call>\n<function=' + tool_call.name + '>\n' }}
115
+ {%- endif %}
116
+ {%- else %}
117
+ {{- '\n<tool_call>\n<function=' + tool_call.name + '>\n' }}
118
+ {%- endif %}
119
+ {%- if tool_call.arguments is defined %}
120
+ {%- for args_name, args_value in tool_call.arguments|items %}
121
+ {{- '<parameter=' + args_name + '>\n' }}
122
+ {%- 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 %}
123
+ {{- args_value }}
124
+ {{- '\n</parameter>\n' }}
125
+ {%- endfor %}
126
+ {%- endif %}
127
+ {{- '</function>\n</tool_call>' }}
128
+ {%- endfor %}
129
+ {%- endif %}
130
+ {{- '<|im_end|>\n' }}
131
+ {%- elif message.role == "tool" %}
132
+ {%- if loop.previtem and loop.previtem.role != "tool" %}
133
+ {{- '<|im_start|>user' }}
134
+ {%- endif %}
135
+ {{- '\n<tool_response>\n' }}
136
+ {{- content }}
137
+ {{- '\n</tool_response>' }}
138
+ {%- if not loop.last and loop.nextitem.role != "tool" %}
139
+ {{- '<|im_end|>\n' }}
140
+ {%- elif loop.last %}
141
+ {{- '<|im_end|>\n' }}
142
+ {%- endif %}
143
+ {%- else %}
144
+ {{- raise_exception('Unexpected message role.') }}
145
+ {%- endif %}
146
+ {%- endfor %}
147
+ {%- if add_generation_prompt %}
148
+ {{- '<|im_start|>assistant\n' }}
149
+ {%- if enable_thinking is defined and enable_thinking is true %}
150
+ {{- '<think>\n' }}
151
+ {%- else %}
152
+ {{- '<think>\n\n</think>\n\n' }}
153
+ {%- endif %}
154
+ {%- endif %}
adapter/scoring_config.json ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "run_id": "direct-r002",
3
+ "base_model": {
4
+ "repo_id": "AlexWortega/openjev",
5
+ "subfolder": "qwen3.5-2b-nli-v5",
6
+ "revision": "a20448012c213128955ca0c693e7c943865cab77"
7
+ },
8
+ "input": {
9
+ "scope": "SKILL.md only",
10
+ "max_length": 8192,
11
+ "hypothesis": "This AI agent skill is malicious.",
12
+ "template": "Premise: {skill_text}\nHypothesis: {hypothesis}",
13
+ "truncation": "Premise prefix plus complete fixed hypothesis"
14
+ },
15
+ "label2id": {
16
+ "contradiction": 0,
17
+ "entailment": 1,
18
+ "neutral": 2
19
+ },
20
+ "calibration": {
21
+ "method": "positive_sigmoid_log_odds",
22
+ "slope": 0.76127103215625,
23
+ "intercept": 0.3934838733671388,
24
+ "fit_partition": "validation",
25
+ "formula": "p = sigmoid(slope * (entailment - logaddexp(contradiction, neutral)) + intercept)"
26
+ },
27
+ "decision": {
28
+ "comparator": ">=",
29
+ "raw_log_odds_threshold": -2.515625536875148,
30
+ "calibrated_probability_threshold": 0.17922765383653141
31
+ }
32
+ }
adapter/tokenizer.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:f399b3cd12fa270d51457bb749fb30863521e8359b8a27059c71b6c2f7d6dd6c
3
+ size 19989424
adapter/tokenizer_config.json ADDED
@@ -0,0 +1,36 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "add_prefix_space": false,
3
+ "audio_bos_token": "<|audio_start|>",
4
+ "audio_eos_token": "<|audio_end|>",
5
+ "audio_token": "<|audio_pad|>",
6
+ "backend": "tokenizers",
7
+ "bos_token": null,
8
+ "clean_up_tokenization_spaces": false,
9
+ "eos_token": "<|im_end|>",
10
+ "errors": "replace",
11
+ "image_token": "<|image_pad|>",
12
+ "is_local": true,
13
+ "local_files_only": true,
14
+ "max_length": 1024,
15
+ "model_max_length": 262144,
16
+ "model_specific_special_tokens": {
17
+ "audio_bos_token": "<|audio_start|>",
18
+ "audio_eos_token": "<|audio_end|>",
19
+ "audio_token": "<|audio_pad|>",
20
+ "image_token": "<|image_pad|>",
21
+ "video_token": "<|video_pad|>",
22
+ "vision_bos_token": "<|vision_start|>",
23
+ "vision_eos_token": "<|vision_end|>"
24
+ },
25
+ "pad_token": "<|endoftext|>",
26
+ "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+",
27
+ "split_special_tokens": false,
28
+ "stride": 0,
29
+ "tokenizer_class": "Qwen2Tokenizer",
30
+ "truncation_side": "right",
31
+ "truncation_strategy": "longest_first",
32
+ "unk_token": null,
33
+ "video_token": "<|video_pad|>",
34
+ "vision_bos_token": "<|vision_start|>",
35
+ "vision_eos_token": "<|vision_end|>"
36
+ }
merge_verification.json ADDED
@@ -0,0 +1,40 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "fresh_process_native_load": true,
3
+ "frozen_calibration_and_threshold_unchanged": true,
4
+ "partitions": {
5
+ "validation": {
6
+ "records": 973,
7
+ "max_logit_difference": 0.1875,
8
+ "max_raw_log_odds_difference": 0.3281247489544863,
9
+ "max_calibrated_probability_difference": 0.061614418874079147,
10
+ "review_disagreements": 1,
11
+ "tp": 742,
12
+ "fp": 17,
13
+ "tn": 206,
14
+ "fn": 8,
15
+ "recall": 0.9893333333333333,
16
+ "fpr": 0.07623318385650224
17
+ },
18
+ "test": {
19
+ "records": 1950,
20
+ "max_logit_difference": 0.1875,
21
+ "max_raw_log_odds_difference": 0.21874973440485856,
22
+ "max_calibrated_probability_difference": 0.023134370893243994,
23
+ "review_disagreements": 0,
24
+ "tp": 1488,
25
+ "fp": 25,
26
+ "tn": 424,
27
+ "fn": 13,
28
+ "recall": 0.9913391072618255,
29
+ "fpr": 0.0556792873051225
30
+ }
31
+ },
32
+ "peak_gpu_allocated_gib": 5.09755802154541,
33
+ "elapsed_seconds": 804.6106737367809,
34
+ "public_scoring_helper": {
35
+ "fresh_process_passed": true,
36
+ "validation_index": 0,
37
+ "probability_difference": 0.0,
38
+ "review_decision_matches": true
39
+ }
40
+ }
score.py ADDED
@@ -0,0 +1,58 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Score one SKILL.md with the full SkillJev-2B model; never execute its text."""
2
+ import argparse
3
+ import json
4
+ from pathlib import Path
5
+
6
+ import torch
7
+ from huggingface_hub import hf_hub_download
8
+ from transformers import AutoModelForSequenceClassification, AutoTokenizer
9
+
10
+
11
+ def main():
12
+ parser = argparse.ArgumentParser(description=__doc__)
13
+ parser.add_argument("skill", type=Path)
14
+ parser.add_argument("--model", default="SkillJev/SkillJev-2B")
15
+ parser.add_argument("--revision", default="v1")
16
+ args = parser.parse_args()
17
+ if not torch.cuda.is_available():
18
+ raise RuntimeError("This release recipe requires CUDA with BF16 support")
19
+ total = torch.cuda.get_device_properties(0).total_memory
20
+ torch.cuda.set_per_process_memory_fraction(min(1., 8 * 1024**3 / total))
21
+ local = Path(args.model).is_dir()
22
+ config = Path(args.model) / "scoring_config.json" if local else Path(
23
+ hf_hub_download(args.model, "scoring_config.json", revision=args.revision))
24
+ settings = json.loads(config.read_text())
25
+ options = {"local_files_only": True} if local else {"revision": args.revision}
26
+ tokenizer = AutoTokenizer.from_pretrained(args.model, trust_remote_code=False, **options)
27
+ model = AutoModelForSequenceClassification.from_pretrained(args.model,
28
+ dtype=torch.bfloat16, attn_implementation="sdpa", trust_remote_code=False, **options)
29
+ assert model.config.label2id == settings["label2id"]
30
+ assert tokenizer.num_special_tokens_to_add(False) == 0
31
+ tokenizer.pad_token_id = model.config.pad_token_id
32
+ model.config.use_cache = model.config.text_config.use_cache = False
33
+ model = model.cuda().eval()
34
+ text = args.skill.read_text(encoding="utf-8")
35
+ suffix = "\nHypothesis: " + settings["input"]["hypothesis"]
36
+ suffix_ids = tokenizer.encode(suffix, add_special_tokens=False)
37
+ ids = tokenizer.encode("Premise: " + text + suffix, add_special_tokens=False)
38
+ original_tokens = len(ids)
39
+ limit = settings["input"]["max_length"]
40
+ if len(ids) > limit:
41
+ ids = ids[:limit - len(suffix_ids)] + suffix_ids
42
+ inputs = torch.tensor([ids], device="cuda")
43
+ with torch.inference_mode(), torch.autocast("cuda", dtype=torch.bfloat16):
44
+ logits = model(input_ids=inputs, attention_mask=torch.ones_like(inputs)).logits[0]
45
+ logits = logits.float().cpu().double()
46
+ assert torch.isfinite(logits).all()
47
+ z = logits[1] - torch.logsumexp(logits[[0, 2]], dim=0)
48
+ calibration = settings["calibration"]
49
+ p = torch.sigmoid(calibration["slope"] * z + calibration["intercept"]).item()
50
+ decision = settings["decision"]
51
+ print(json.dumps({"skill_id": args.skill.name, "malicious_probability": p,
52
+ "threshold": decision["calibrated_probability_threshold"],
53
+ "review": z.item() >= decision["raw_log_odds_threshold"],
54
+ "truncated": original_tokens > limit}, indent=2))
55
+
56
+
57
+ if __name__ == "__main__":
58
+ main()
scoring_config.json ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "run_id": "direct-r002",
3
+ "base_model": {
4
+ "repo_id": "AlexWortega/openjev",
5
+ "subfolder": "qwen3.5-2b-nli-v5",
6
+ "revision": "a20448012c213128955ca0c693e7c943865cab77"
7
+ },
8
+ "input": {
9
+ "scope": "SKILL.md only",
10
+ "max_length": 8192,
11
+ "hypothesis": "This AI agent skill is malicious.",
12
+ "template": "Premise: {skill_text}\nHypothesis: {hypothesis}",
13
+ "truncation": "Premise prefix plus complete fixed hypothesis"
14
+ },
15
+ "label2id": {
16
+ "contradiction": 0,
17
+ "entailment": 1,
18
+ "neutral": 2
19
+ },
20
+ "calibration": {
21
+ "method": "positive_sigmoid_log_odds",
22
+ "slope": 0.76127103215625,
23
+ "intercept": 0.3934838733671388,
24
+ "fit_partition": "validation",
25
+ "formula": "p = sigmoid(slope * (entailment - logaddexp(contradiction, neutral)) + intercept)"
26
+ },
27
+ "decision": {
28
+ "comparator": ">=",
29
+ "raw_log_odds_threshold": -2.515625536875148,
30
+ "calibrated_probability_threshold": 0.17922765383653141
31
+ }
32
+ }
weights_manifest.json ADDED
@@ -0,0 +1,90 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "README.md": {
3
+ "bytes": 2510,
4
+ "sha256": "e5c55d1d47c0ab471b32ffb70e685479444673868744434a1d6caaaefb947bec"
5
+ },
6
+ "USAGE.md": {
7
+ "bytes": 2579,
8
+ "sha256": "a642b40fd844a4302600f4158d1bb2e98a3d5bb2f161edac778bfac0bac535c2"
9
+ },
10
+ "adapter/README.md": {
11
+ "bytes": 510,
12
+ "sha256": "924c6f0c184e3f77dc7b033c934c1a2ce66a58c6519cf26bd815560ecf801924"
13
+ },
14
+ "adapter/USAGE.md": {
15
+ "bytes": 2883,
16
+ "sha256": "03eadb8f48934f604e1386354d0af7e958427be898fcb7760bda0c18fcb97040"
17
+ },
18
+ "adapter/adapter_config.json": {
19
+ "bytes": 1212,
20
+ "sha256": "a9b842d3d9e80de133c92b571a1c05c9dadc611a8e49b10d6f820bdc4e754344"
21
+ },
22
+ "adapter/adapter_model.safetensors": {
23
+ "bytes": 8775920,
24
+ "sha256": "a065bd76fbdd1c89958937211d8b1e00c5ac5aad33dcefbd2c3e6e1551364131"
25
+ },
26
+ "adapter/chat_template.jinja": {
27
+ "bytes": 7755,
28
+ "sha256": "273d8e0e683b885071fb17e08d71e5f2a5ddfb5309756181681de4f5a1822d80"
29
+ },
30
+ "adapter/scoring_config.json": {
31
+ "bytes": 955,
32
+ "sha256": "3fcc51fd072005806778f9d00e7247af3b9e4a5dfb93b16c37d2ff6012c1eaba"
33
+ },
34
+ "adapter/tokenizer.json": {
35
+ "bytes": 19989424,
36
+ "sha256": "f399b3cd12fa270d51457bb749fb30863521e8359b8a27059c71b6c2f7d6dd6c"
37
+ },
38
+ "adapter/tokenizer_config.json": {
39
+ "bytes": 1232,
40
+ "sha256": "1b4aa963b7ff602051283ab9d794c44e4a3b65a806668a66e2312f1b641c0caa"
41
+ },
42
+ "chat_template.jinja": {
43
+ "bytes": 7755,
44
+ "sha256": "273d8e0e683b885071fb17e08d71e5f2a5ddfb5309756181681de4f5a1822d80"
45
+ },
46
+ "config.json": {
47
+ "bytes": 3051,
48
+ "sha256": "2ff7404369a6c8efbef3da39842aeceaf91d5eeb053df51b38b0c68be07320e3"
49
+ },
50
+ "export_provenance.json": {
51
+ "bytes": 756,
52
+ "sha256": "0b8e8433b1a3d53da399a04a87091fe63ceb91ae68fb7c7cd6fe80a035b2a6e0"
53
+ },
54
+ "merge_verification.json": {
55
+ "bytes": 1125,
56
+ "sha256": "0229b650267793bf503322770f127898cf02ae5788df966892940d2e10ce52f4"
57
+ },
58
+ "model-00001-of-00003.safetensors": {
59
+ "bytes": 1999936744,
60
+ "sha256": "92ce5f9398a5f5bd66e9795fc6ce828c1e2e6bfe147fa6df832b4777700c5569"
61
+ },
62
+ "model-00002-of-00003.safetensors": {
63
+ "bytes": 1998904824,
64
+ "sha256": "3a04c5844dd925bcb7169351375284955dcff3cfe4cd4ff6b0744e7d555e09aa"
65
+ },
66
+ "model-00003-of-00003.safetensors": {
67
+ "bytes": 427728976,
68
+ "sha256": "c04a8541fc1c59c4c69903666e0eb642a194af6cd6f089de5bf011e13c92e917"
69
+ },
70
+ "model.safetensors.index.json": {
71
+ "bytes": 55828,
72
+ "sha256": "f32e6ba64583661c012316227a4a9b764fd663c430060886bfee4776d3d516c6"
73
+ },
74
+ "score.py": {
75
+ "bytes": 2906,
76
+ "sha256": "6afc99a1d984a5a7d87314322df46518297e4b033eb27d42ee4af2fe15610923"
77
+ },
78
+ "scoring_config.json": {
79
+ "bytes": 955,
80
+ "sha256": "3fcc51fd072005806778f9d00e7247af3b9e4a5dfb93b16c37d2ff6012c1eaba"
81
+ },
82
+ "tokenizer.json": {
83
+ "bytes": 19989424,
84
+ "sha256": "f399b3cd12fa270d51457bb749fb30863521e8359b8a27059c71b6c2f7d6dd6c"
85
+ },
86
+ "tokenizer_config.json": {
87
+ "bytes": 1232,
88
+ "sha256": "1b4aa963b7ff602051283ab9d794c44e4a3b65a806668a66e2312f1b641c0caa"
89
+ }
90
+ }