birgermoell commited on
Commit
4ab7986
·
verified ·
1 Parent(s): 0a3582a

Upload trace-loop-classifier (distilroberta-base) with ID & OOD benchmark card

Browse files
Files changed (8) hide show
  1. README.md +111 -0
  2. config.json +35 -0
  3. merges.txt +0 -0
  4. model.safetensors +3 -0
  5. special_tokens_map.json +15 -0
  6. tokenizer.json +0 -0
  7. tokenizer_config.json +58 -0
  8. vocab.json +0 -0
README.md ADDED
@@ -0,0 +1,111 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: apache-2.0
3
+ base_model: distilroberta-base
4
+ datasets:
5
+ - open-thoughts/AgentTrove
6
+ - Agent-Ark/Toucan-1.5M
7
+ - openbmb/UltraData-SFT-Agent-2609
8
+ - jupyter-agent/jupyter-agent-dataset
9
+ - FineEnvs/SmolDataEnvs-sft
10
+ - jedisct1/security-audits
11
+ - SWE-bench/SWE-smith-trajectories
12
+ - Lego-X/LegoFlow-SWE
13
+ language:
14
+ - en
15
+ tags:
16
+ - text-classification
17
+ - agent-traces
18
+ - post-training
19
+ - sft-filter
20
+ - rl-rollouts
21
+ - renaissancelabs
22
+ library_name: transformers
23
+ ---
24
+
25
+ # trace-loop-classifier
26
+
27
+ A fast, lightweight (82M-parameter `distilroberta-base`) binary classifier trained by [Renaissance Labs](https://renaissancelabs.eu) to detect **agent stall loops and semantic repetition** in multi-turn tool-calling and coding-agent trajectories — built to complement exact-match regex filters in SFT data curation and RL rollout monitoring (motivated by [Marin `#12264`](https://github.com/marin-community/marin/issues/12264)).
28
+
29
+ Labels:
30
+ - `0` (`clean`): normal multi-turn progress (including legitimate single-retry-then-succeed recoveries)
31
+ - `1` (`loop_or_stall`): consecutive stalls, argument-jittered retries, A-B-A-B oscillations, circular apology/plan-restate stalls, or doom-loop suffix repetition
32
+
33
+ ---
34
+
35
+ ## Benchmark results (vs. exact-match regex baselines)
36
+
37
+ Evaluated on both **in-distribution held-out trajectories** (`test_id`, 217 traces from 6 permissive sources) and **unseen-source OOD trajectories** (`test_ood`, 500 traces from `SWE-bench/SWE-smith-trajectories` and `Lego-X/LegoFlow-SWE`, never seen during training):
38
+
39
+ ### In-distribution test (`test_id`, `n = 217`)
40
+
41
+ | Detector | F1 | Precision | Recall | Accuracy | AUROC | Latency |
42
+ |---|---:|---:|---:|---:|---:|---:|
43
+ | Regex: consecutive exact stall (`>=3x`) | `0.3762` | `1.0000` | `0.2317` | `0.7097` | `0.6159` | `<0.1 ms` |
44
+ | Regex: spread exact duplicate (`>=30%`) | `0.5487` | `1.0000` | `0.3780` | `0.7650` | `0.6890` | `<0.1 ms` |
45
+ | Regex: combined (`exact OR spread`) | `0.6102` | `1.0000` | `0.4390` | `0.7880` | `0.7195` | `<0.1 ms` |
46
+ | **`RenaissanceLabsEU/trace-loop-classifier`** | **`0.9487`** | **`1.0000`** | **`0.9024`** | **`0.9631`** | **`0.9587`** | **`17.7 ms/trace` (M5 MPS)** |
47
+
48
+ ### Unseen-source OOD test (`test_ood`, `n = 500`: `SWE-smith` + `LegoFlow-SWE`)
49
+
50
+ | Detector | F1 | Precision | Recall | Accuracy | AUROC | Latency |
51
+ |---|---:|---:|---:|---:|---:|---:|
52
+ | Regex: consecutive exact stall (`>=3x`) | `0.4266` | `1.0000` | `0.2711` | `0.6720` | `0.6356` | `<0.1 ms` |
53
+ | Regex: spread exact duplicate (`>=30%`) | `0.0769` | `1.0000` | `0.0400` | `0.5680` | `0.5200` | `<0.1 ms` |
54
+ | Regex: combined (`exact OR spread`) | `0.4483` | `1.0000` | `0.2889` | `0.6800` | `0.6444` | `<0.1 ms` |
55
+ | **`RenaissanceLabsEU/trace-loop-classifier`** | **`0.9933`** | **`1.0000`** | **`0.9867`** | **`0.9940`** | **`0.9912`** | **`18.1 ms/trace` (M5 MPS)** |
56
+
57
+ ### OOD breakdown by subtype (`test_ood`)
58
+
59
+ | Subtype | True label | Count | Accuracy |
60
+ |---|---:|---:|---:|
61
+ | `clean` (real unseen SWE traces) | `0` | `225` | `100.0%` |
62
+ | `hard_neg_single_retry` (1 retry → success) | `0` | `50` | `100.0%` |
63
+ | `exact_stall` (3–5× consecutive repeat) | `1` | `54` | `100.0%` |
64
+ | `jitter_retry` (argument/comment-tweaked retries) | `1` | `36` | `100.0%` |
65
+ | `ab_oscillation` (A-B-A-B cycle) | `1` | `42` | `100.0%` |
66
+ | `apology_stall` (circular plan-restate / apology) | `1` | `40` | `100.0%` |
67
+ | `doom_suffix` (repeated tail chunk) | `1` | `50` | `100.0%` |
68
+ | `real_loop` (natural spread-out repeats in 99-turn `LegoFlow-SWE` runs) | `1` | `3` | **`0.0%`** *(see Limits)* |
69
+
70
+ ---
71
+
72
+ ## Run Card
73
+
74
+ - **Base model:** `distilroberta-base` (82M params, Apache-2.0)
75
+ - **Splits:** `1,346` train / `209` val / `217` ID test (from 6 Apache-2.0 / MIT HF trace datasets: `AgentTrove`, `Toucan-1.5M`, `UltraData-SFT-Agent-2609`, `jupyter-agent-dataset`, `SmolDataEnvs-sft`, `security-audits`) + `500` unseen-source OOD test (`SWE-smith-trajectories`, `LegoFlow-SWE`).
76
+ - **Truncation:** `max_length=512`, `truncation_side="left"` (always preserves the tail of the trajectory where stalls occur).
77
+ - **Hyperparameters:** full fine-tune in fp32, `AdamW`, `lr=3e-5`, cosine warmup, `batch_size=8`, `grad_accum=2` (eff batch 16), `4` epochs, best checkpoint selected by validation F1 (`0.9867`, val AUROC `0.9999`).
78
+ - **Hardware & wall-clock:** Apple M5 (MPS), `429.5s` (~7 minutes total).
79
+
80
+ ---
81
+
82
+ ## Quick start
83
+
84
+ ```python
85
+ from transformers import pipeline
86
+
87
+ clf = pipeline(
88
+ "text-classification",
89
+ model="RenaissanceLabsEU/trace-loop-classifier",
90
+ truncation=True,
91
+ max_length=512,
92
+ )
93
+ # Format trajectory as [ROLE] content lines (keep the tail for long runs)
94
+ trace = "[USER] Fix failing tests\n[ASSISTANT] Running pytest...\n[TOOL] Exit code 1\n..."
95
+ print(clf(trace))
96
+ ```
97
+
98
+ ---
99
+
100
+ ## Honest limits & recommended usage
101
+
102
+ 1. **512-token tail window misses early-episode spread-out repeats:** On the 3 natural `real_loop` traces in `test_ood` (`LegoFlow-SWE`, averaging ~99 turns), the repeated actions happened earlier than the final 512 tokens, so the model scored `0/3`. **Recommended production setup:** run this classifier **together with** a cheap whole-episode exact-duplicate counter (`spread_repeat >= 30%` OR `trace-loop-classifier >= 0.5`).
103
+ 2. **Synthetic semantic-loop positives:** Because natural permissive trace datasets contain relatively few labeled semantic loops, the `jitter_retry`, `ab_oscillation`, `apology_stall`, and `doom_suffix` positives were injected onto real clean trajectories. Real-world semantic loops outside those templates should be audited before relying on this model as a sole gate.
104
+ 3. **English-primary:** Trained on English-dominant coding and tool-calling traces.
105
+
106
+ ## Links & license
107
+
108
+ - **Agentic Traces Audit & Shortlist:** [RenaissanceLabs-EU/datasets/agentic-traces](https://github.com/RenaissanceLabs-EU/datasets/blob/main/agentic-traces/SHORTLIST.md)
109
+ - **Open Agent Skills:** [skills.renaissancelabs.eu](https://skills.renaissancelabs.eu)
110
+ - **Lab:** [renaissancelabs.eu](https://renaissancelabs.eu)
111
+ - **License:** Apache 2.0.
config.json ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "architectures": [
3
+ "RobertaForSequenceClassification"
4
+ ],
5
+ "attention_probs_dropout_prob": 0.1,
6
+ "bos_token_id": 0,
7
+ "classifier_dropout": null,
8
+ "dtype": "float32",
9
+ "eos_token_id": 2,
10
+ "hidden_act": "gelu",
11
+ "hidden_dropout_prob": 0.1,
12
+ "hidden_size": 768,
13
+ "id2label": {
14
+ "0": "clean",
15
+ "1": "loop_or_stall"
16
+ },
17
+ "initializer_range": 0.02,
18
+ "intermediate_size": 3072,
19
+ "label2id": {
20
+ "clean": 0,
21
+ "loop_or_stall": 1
22
+ },
23
+ "layer_norm_eps": 1e-05,
24
+ "max_position_embeddings": 514,
25
+ "model_type": "roberta",
26
+ "num_attention_heads": 12,
27
+ "num_hidden_layers": 6,
28
+ "pad_token_id": 1,
29
+ "position_embedding_type": "absolute",
30
+ "problem_type": "single_label_classification",
31
+ "transformers_version": "4.57.3",
32
+ "type_vocab_size": 1,
33
+ "use_cache": true,
34
+ "vocab_size": 50265
35
+ }
merges.txt ADDED
The diff for this file is too large to render. See raw diff
 
model.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:8a707519011ceced7d775d1cbda3444000965c1ae3bcb5747161b039ef90ef42
3
+ size 328492280
special_tokens_map.json ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "bos_token": "<s>",
3
+ "cls_token": "<s>",
4
+ "eos_token": "</s>",
5
+ "mask_token": {
6
+ "content": "<mask>",
7
+ "lstrip": true,
8
+ "normalized": false,
9
+ "rstrip": false,
10
+ "single_word": false
11
+ },
12
+ "pad_token": "<pad>",
13
+ "sep_token": "</s>",
14
+ "unk_token": "<unk>"
15
+ }
tokenizer.json ADDED
The diff for this file is too large to render. See raw diff
 
tokenizer_config.json ADDED
@@ -0,0 +1,58 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "add_prefix_space": false,
3
+ "added_tokens_decoder": {
4
+ "0": {
5
+ "content": "<s>",
6
+ "lstrip": false,
7
+ "normalized": true,
8
+ "rstrip": false,
9
+ "single_word": false,
10
+ "special": true
11
+ },
12
+ "1": {
13
+ "content": "<pad>",
14
+ "lstrip": false,
15
+ "normalized": true,
16
+ "rstrip": false,
17
+ "single_word": false,
18
+ "special": true
19
+ },
20
+ "2": {
21
+ "content": "</s>",
22
+ "lstrip": false,
23
+ "normalized": true,
24
+ "rstrip": false,
25
+ "single_word": false,
26
+ "special": true
27
+ },
28
+ "3": {
29
+ "content": "<unk>",
30
+ "lstrip": false,
31
+ "normalized": true,
32
+ "rstrip": false,
33
+ "single_word": false,
34
+ "special": true
35
+ },
36
+ "50264": {
37
+ "content": "<mask>",
38
+ "lstrip": true,
39
+ "normalized": false,
40
+ "rstrip": false,
41
+ "single_word": false,
42
+ "special": true
43
+ }
44
+ },
45
+ "bos_token": "<s>",
46
+ "clean_up_tokenization_spaces": false,
47
+ "cls_token": "<s>",
48
+ "eos_token": "</s>",
49
+ "errors": "replace",
50
+ "extra_special_tokens": {},
51
+ "mask_token": "<mask>",
52
+ "model_max_length": 512,
53
+ "pad_token": "<pad>",
54
+ "sep_token": "</s>",
55
+ "tokenizer_class": "RobertaTokenizer",
56
+ "trim_offsets": true,
57
+ "unk_token": "<unk>"
58
+ }
vocab.json ADDED
The diff for this file is too large to render. See raw diff