ProCreations commited on
Commit
72e859f
·
verified ·
1 Parent(s): 7c1e4b6

Upload folder using huggingface_hub

Browse files
Files changed (8) hide show
  1. .gitattributes +1 -0
  2. README.md +71 -0
  3. labels.json +11 -0
  4. model.onnx +3 -0
  5. model.onnx_data +3 -0
  6. model_int8.onnx +3 -0
  7. tokenizer.json +0 -0
  8. tokenizer_config.json +24 -0
.gitattributes CHANGED
@@ -33,3 +33,4 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
 
 
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
36
+ model.onnx_data filter=lfs diff=lfs merge=lfs -text
README.md ADDED
@@ -0,0 +1,71 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: apache-2.0
3
+ base_model: ProCreations/auto-1b
4
+ pipeline_tag: text-classification
5
+ library_name: onnx
6
+ tags:
7
+ - agent-safety
8
+ - tool-calling
9
+ - guardrails
10
+ - onnx
11
+ ---
12
+
13
+ # auto-1b — ONNX
14
+
15
+ ONNX exports of [`ProCreations/auto-1b`](https://huggingface.co/ProCreations/auto-1b), a 1B
16
+ encoder that decides whether an AI agent's next tool call is safe to run (**96.40%** on
17
+ [approve-or-deny](https://huggingface.co/datasets/ProCreations/approve-or-deny)).
18
+
19
+ | file | precision | size |
20
+ |---|---|---|
21
+ | `model.onnx` + `model.onnx_data` | fp32 | 3,935 MiB |
22
+ | `model_int8.onnx` | dynamic int8 | 985 MiB |
23
+
24
+ ## Verified against PyTorch
25
+
26
+ Both exports were checked against the original model on real benchmark rows:
27
+
28
+ | export | max abs difference in P(deny) | decision agreement |
29
+ |---|---|---|
30
+ | fp32 | 2.4e-07 | 100% |
31
+ | int8 | 7.5e-01 | 92% |
32
+
33
+ ## Usage
34
+
35
+ ```python
36
+ import numpy as np, onnxruntime as ort
37
+ from transformers import AutoTokenizer
38
+
39
+ tok = AutoTokenizer.from_pretrained("ProCreations/auto-1b-ONNX")
40
+ sess = ort.InferenceSession("model_int8.onnx", providers=["CPUExecutionProvider"])
41
+
42
+ def build_input(user_request, history, call):
43
+ parts = ["### PROPOSED TOOL CALL", f"tool: {call['tool']}", f"args: {call['args']}", "",
44
+ "### USER REQUEST", user_request, "", "### AGENT HISTORY"]
45
+ if not history:
46
+ parts.append("(no prior actions)")
47
+ else:
48
+ for i, h in enumerate(history):
49
+ parts.append(f"[{i+1}] {h['tool']}({h['args']})\n-> {h.get('result','')}")
50
+ return "\n".join(parts)
51
+
52
+ text = build_input("clean up build artifacts", [], {"tool": "Bash", "args": "rm -rf node_modules"})
53
+ enc = tok(text, return_tensors="np", truncation=True, max_length=8192)
54
+ logits = sess.run(None, {"input_ids": enc["input_ids"].astype(np.int64),
55
+ "attention_mask": enc["attention_mask"].astype(np.int64)})[0]
56
+ p = np.exp(logits[0]) / np.exp(logits[0]).sum()
57
+ print("DENY" if p[1] > 0.5 else "APPROVE", f"P(deny)={p[1]:.3f}")
58
+ ```
59
+
60
+ `logits[:, 1]` after softmax is `P(deny)`. Labels: `0 = approve`, `1 = deny`.
61
+
62
+ **The input format matters** — the proposed call and user request come first so they survive
63
+ truncation. Use the exact section headers above.
64
+
65
+ ## Context limit
66
+
67
+ **Practical to ~8k tokens.** The non-flash attention path materialises a dense `(B, 1, L, L)`
68
+ sliding-window mask, so memory grows quadratically with sequence length. That covers the great
69
+ majority of real tool calls (a call plus recent history), but for the full 64k context use the
70
+ PyTorch + flash-attention path in
71
+ [`ProCreations/auto-1b`](https://huggingface.co/ProCreations/auto-1b).
labels.json ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "id2label": {
3
+ "0": "approve",
4
+ "1": "deny"
5
+ },
6
+ "label2id": {
7
+ "approve": 0,
8
+ "deny": 1
9
+ },
10
+ "note": "logits[:,1] is P(deny) after softmax"
11
+ }
model.onnx ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:d7158b278cf554b728bfad67580d1b9f8ed2ff4a6e213d5653fe7639470e0afc
3
+ size 1051174
model.onnx_data ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:b3592b3777fc26cb6b327fbb2aed12c1248634d26d79823791422e52cc28c643
3
+ size 4125069312
model_int8.onnx ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:00e06001991b18779185d873c533762be4cc0fef8506eb38dda7fdea06ed04eb
3
+ size 1033022296
tokenizer.json ADDED
The diff for this file is too large to render. See raw diff
 
tokenizer_config.json ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "backend": "tokenizers",
3
+ "clean_up_tokenization_spaces": true,
4
+ "cls_token": "[CLS]",
5
+ "is_local": true,
6
+ "local_files_only": false,
7
+ "mask_token": "[MASK]",
8
+ "max_length": 4096,
9
+ "model_input_names": [
10
+ "input_ids",
11
+ "attention_mask"
12
+ ],
13
+ "model_max_length": 65536,
14
+ "pad_to_multiple_of": null,
15
+ "pad_token": "[PAD]",
16
+ "pad_token_type_id": 0,
17
+ "padding_side": "right",
18
+ "sep_token": "[SEP]",
19
+ "stride": 0,
20
+ "tokenizer_class": "TokenizersBackend",
21
+ "truncation_side": "right",
22
+ "truncation_strategy": "longest_first",
23
+ "unk_token": "[UNK]"
24
+ }