aac6fef commited on
Commit
ea98f4f
Β·
verified Β·
1 Parent(s): cfd1527

Model card, demo GIF and independence check (RTX A6000: rules and boxes bit-identical)

Browse files
Files changed (3) hide show
  1. README.md +210 -0
  2. assets/demo.gif +3 -0
  3. checks/independence.json +13 -0
README.md ADDED
@@ -0,0 +1,210 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: cc-by-nc-4.0
3
+ base_model: Qwen/Qwen3.5-4B
4
+ pipeline_tag: video-text-to-text
5
+ language:
6
+ - en
7
+ - zh
8
+ tags:
9
+ - video
10
+ - streaming
11
+ - video-understanding
12
+ - monitoring
13
+ - visual-grounding
14
+ - lora
15
+ - qwen3.5
16
+ ---
17
+
18
+ # Glance-Stream-4B
19
+
20
+ **The 4B sibling of [Glance-Stream-0.8B](https://huggingface.co/Vision-Decision/Glance-Stream-0.8B): the same standing
21
+ yes/no rules over a live video stream, checked together every half second, including rules about what happened before,
22
+ plus a box for the person a rule is about. Same package, same API, same recipe on Qwen3.5-4B.**
23
+
24
+ [GitHub (code, docs)](https://github.com/Vision-Decision/Glance-Stream) Β· [Usage](#usage) Β· [Results](#results) Β·
25
+ [Limitations](#limitations) Β· [0.8B or 4B?](#08b-or-4b) Β· [Training data](#training-data) Β· [License](#license)
26
+
27
+ You attach rules to a 30 fps video stream: "is someone cutting vegetables right now", "whenever the fridge is opened it
28
+ must be closed within 30 seconds", "cutting is only allowed if hands were washed in the minute before". Every 0.5 s the
29
+ model answers all of them at once with p(yes) for "is this rule violated right now", from one shared state of the
30
+ stream; an alert fires after two consecutive readouts above the threshold. For rules that carry a person description it
31
+ also returns that person's box in the current frame.
32
+
33
+ ![Glance-Stream-4B on a kitchen clip: four standing rules, alerts and a box (real model outputs)](assets/demo.gif)
34
+
35
+ <sub>Real model outputs on the same Pexels clip as the 0.8B demo (Anna Shvets, [Pexels License](https://www.pexels.com/license/)),
36
+ rendered by [`examples/make_demo.py`](https://github.com/Vision-Decision/Glance-Stream/blob/main/examples/make_demo.py); raw
37
+ readouts in [`assets/demo_predictions_4B.json`](https://github.com/Vision-Decision/Glance-Stream/blob/main/assets/demo_predictions_4B.json).
38
+ Against the 0.8B demo it drops the wrong "holding a knife" alert at 11.5 s and finds the person far more often, but it
39
+ misses a brief return to cutting at about 6.5 s.</sub>
40
+
41
+ ## What is in this repository
42
+
43
+ | File | Content |
44
+ |---|---|
45
+ | `text_lora.safetensors` | rule-question adapter: LoRA r=16, alpha=32 on the attention, Gated-DeltaNet and MLP projections of the Qwen3.5-4B language model, fp32 (30.5 M parameters) |
46
+ | `box_lora.safetensors` | box-question adapter, same shape, used only for box questions |
47
+ | `box_head.safetensors` | box head: presence, choice of patch, four ordinal edge distributions, IoU; one latent token read at layer 32 |
48
+ | `config.json` | base model id, adapter files, stream shape (256Γ—256, 64 tokens per frame group), memory window, readout period, alert defaults |
49
+ | `checks/independence.json` | the check that the two adapters do not interact (see below) |
50
+
51
+ The base weights are **not** included; they load from [Qwen/Qwen3.5-4B](https://huggingface.co/Qwen/Qwen3.5-4B)
52
+ (Apache-2.0, about 9 GB). The weights need the [`glance_stream`](https://github.com/Vision-Decision/Glance-Stream) package:
53
+ the streaming state, the forked question blocks and the box head are not part of `transformers`.
54
+
55
+ ## Model description
56
+
57
+ The architecture and streaming policy are those of
58
+ [Glance-Stream-0.8B](https://huggingface.co/Vision-Decision/Glance-Stream-0.8B); only the base model is larger.
59
+
60
+ - **Stream.** Each frame group (two consecutive frames through the Qwen3.5 vision tower's 2-frame tubelet, 64 tokens at
61
+ 256Γ—256, plus a text timestamp every 0.5 s) is written once into the model's state. The Gated-DeltaNet layers carry
62
+ their recurrent state through the whole video; the full-attention layers keep a bounded window (every group
63
+ of the last 4 s and older groups up to 600 s on a 2 s grid, about 30k tokens), with positions re-based so hour-long
64
+ streams stay in the trained range.
65
+ - **Questions never write back.** Every rule is a short question block forked from the current state and discarded
66
+ after the answer, so adding a rule never changes the other answers or the stream. All rules of one readout are one
67
+ batched forward.
68
+ - **Answers.** p(yes) from the first answer token, restricted to the yes/no tokens; no text is generated.
69
+ - **Adapters only on questions.** The LoRA adapters are active only on question tokens. The video path runs the
70
+ unchanged base model, so rule questions and box questions can use separate adapters without interacting: on a 36 s
71
+ clip with four rules and one box, the released model's rule probabilities are bit-identical to the rule checkpoint
72
+ alone and its boxes bit-identical to the box checkpoint alone (`checks/independence.json`).
73
+ - **Cross-time rules end to end.** "After A, B is not allowed", "B only if A in the last T s", "A must be followed by B
74
+ within T s", "at most N times in T s" and "B not allowed between A and C" are answered by the model from the stream
75
+ state. There is no event detector or state machine at inference time.
76
+
77
+ ## Usage
78
+
79
+ ```bash
80
+ pip install "glance-stream @ git+https://github.com/Vision-Decision/Glance-Stream"
81
+ pip install flash-linear-attention # optional, CUDA only: fast Gated-DeltaNet kernels
82
+ ```
83
+
84
+ ```python
85
+ from glance_stream import GlanceStream, Rule
86
+
87
+ gs = GlanceStream.from_pretrained("Vision-Decision/Glance-Stream-4B") # CUDA if available
88
+ mon = gs.monitor([
89
+ Rule.now("someone is cutting vegetables"),
90
+ Rule.must_follow("someone opens the fridge", "someone closes the fridge", within=30),
91
+ Rule.now("someone is holding a knife", box="the woman holding a knife"),
92
+ ])
93
+ def on_readout(r): # called every 0.5 s of video, as the stream is processed
94
+ for name in r.alerts:
95
+ print(f"{r.t:.1f}s ALERT {name} p={r.p[name]:.2f}", r.boxes.get(name))
96
+
97
+ readouts = mon.run("kitchen.mp4", fps=30, callback=on_readout) # all readouts, also returned at the end
98
+ ```
99
+
100
+ Command line: `python examples/run_rules.py my_video.mp4 --model Vision-Decision/Glance-Stream-4B --rules examples/kitchen_rules.json --out readouts.json`.
101
+
102
+ On a 36 s clip with four rules and one box the peak GPU memory was 12.5 GB (bf16 base, RTX A6000), so a 16 GB GPU is
103
+ enough; CPU works but is far from real time.
104
+
105
+ ## Results
106
+
107
+ Only final results are listed. Protocols are in
108
+ [docs/EVALUATION.md](https://github.com/Vision-Decision/Glance-Stream/blob/main/docs/EVALUATION.md). The comparison is
109
+ against **the same recipe on Qwen3.5-4B without rule training** (the 4B baseline), both evaluated on the same hardware.
110
+ Differences are means over participants, tested with an exact paired sign-flip test; the tests were fixed before the
111
+ 4B results existed.
112
+
113
+ | What | Data | Result |
114
+ |---|---|---|
115
+ | False alarms per rule-hour on cross-time rules, at 80% event recall (**pre-registered primary test: not met**) | 8 EPIC-KITCHENS-100 streams, 6 participants (never trained on) | 152.8 β†’ 76.5, a mean drop of 74 over participants, 5 of 6 lower; **p = 0.0625, above the 0.05 the test required** |
116
+ | Ranking of cross-time rule readouts, macro AUROC over rule types (co-primary test: met) | same 8 streams | 0.701 β†’ 0.793; paired mean +0.073 (p = 0.031) |
117
+ | False alarms per rule-hour on cross-time rules, at 80% event recall (secondary) | 22 EPIC-KITCHENS-100 streams, 10 participants | 162.8 β†’ 93.3; paired mean βˆ’72, 9 of 10 lower (p = 0.004) |
118
+ | Macro AUROC on cross-time rules (secondary) | same 22 streams | 0.687 β†’ 0.793; paired mean +0.106 (p = 0.002) |
119
+ | No forgetting: false alarms on "is X happening now" rules, ratio to the baseline (non-inferiority margin 1.10) | 48 ten-minute deployment streams | 0.876 [0.771, 0.998]: met |
120
+ | No forgetting: event presence AUROC / temporal grounding mIoU (Charades-STA) | short-clip probes, 2 fps | βˆ’0.002 / βˆ’0.9: both within their margins (0.01 / 2) |
121
+ | Box Acc@0.5 (person descriptions) | HC-STVG v2 test, 267 clips, 2 fps | **45.7** |
122
+
123
+ - **The primary result was not met.** The pre-registered primary test for 4B was the drop in false alarms on the
124
+ original 8 streams. False alarms halved, but one of the six participants went the other way (+12.6), and with six
125
+ participants the exact test cannot reach p ≀ 0.05 unless all six agree. On the 22-stream set used as the main result
126
+ for 0.8B (a secondary analysis here), the drop is significant.
127
+ - The false-alarm results use a threshold chosen for 80% event recall on held-out participants, alerts after 2
128
+ consecutive readouts and a 5 s cooldown, every rule asked every 0.5 s at 30 fps with the 600 s window.
129
+ - Speed: no latency number is reported for this release.
130
+
131
+ ## 0.8B or 4B?
132
+
133
+ | | 0.8B | 4B |
134
+ |---|---|---|
135
+ | Cross-time false alarms per rule-hour, 22 streams, rule-trained | 173.4 | 93.3 |
136
+ | Same, baseline of the same size | 289.9 | 162.8 |
137
+ | Box Acc@0.5, HC-STVG v2, 267 clips | **48.5** | 45.7 |
138
+ | "Now" rules: no-forgetting test against its baseline | not established (on par, upper bound above the margin) | met (0.876 [0.771, 0.998]) |
139
+ | Peak GPU memory, demo clip (bf16) | not measured | 12.5 GB |
140
+
141
+ The two sizes were evaluated in separate runs with the same evaluator and protocol, but not on the same hardware, and
142
+ no test compares them directly: read the cross-size rows as levels, not as a measured difference. The 4B model raises
143
+ fewer false alarms on cross-time rules; the 0.8B model boxes people better. Neither is an alert-free monitor.
144
+
145
+ ## Limitations
146
+
147
+ - **The primary 4B result was not met** (see [Results](#results)): the false-alarm drop on the pre-registered
148
+ 6-participant set is not significant (p = 0.0625).
149
+ - **Count rules lean towards firing.** The 4B model over-counts: on counting questions with true counts of 1–7 its
150
+ mean signed error is +0.96 (the baseline's is βˆ’0.24), the same direction that makes the 0.8B model's "at most N
151
+ times in T seconds" rules fire too often.
152
+ - **"A must be followed by B within T s" is the weakest rule type.** Its ranking AUROC is 0.63 on the 22 streams (the
153
+ baseline is at 0.47, below chance); the model does not reliably tell "B already came" from "B has not come yet". Do
154
+ not rely on this rule type.
155
+ - **Boxes are worse than 0.8B.** Acc@0.5 45.7 against 48.5. The box head was trained and tested on person descriptions
156
+ (HC-STVG) at 2 fps; boxes for objects are untested, and it reads a 256Γ—256 frame, so small people are coarse.
157
+ - **Thresholds are not tuned for you.** The default threshold 0.5 is a starting point; the benchmark chose thresholds
158
+ on held-out data. Probabilities for cross-time rules are not calibrated. Set thresholds per rule on your own footage.
159
+ - **Domain.** Trained on indoor home clips (Charades) and evaluated on kitchens; outdoor, industrial or surveillance
160
+ footage is untested. Only the template wording was evaluated; Chinese and free-form rules were in training but are
161
+ not evaluated.
162
+ - No timestamps or counts as answers in this release (yes/no and boxes only).
163
+
164
+ ## Training
165
+
166
+ The same recipe as 0.8B, with only the model size changed; no hyperparameter was tuned for 4B.
167
+
168
+ - **Rule adapter.** From the frozen base model, 1,200 steps with a global batch of 4 clips, streamed in the inference
169
+ shape (bounded window, no gradient through the video path); questions are forked at random times and answered as
170
+ text (yes/no, spans, counts, options) on Charades, Charades-STA and RepCount-A. 35% of the batches are long training
171
+ streams (5–10 min of spliced Charades train clips) with about 16 rules each, labelled at every readout time by the
172
+ rule engine from the human annotations. Trained on 4 GPUs (data parallel, one clip per GPU); the 4B baseline was
173
+ trained on one GPU with the same global batch.
174
+ - **Box adapter and box head.** A separate 1,500-step run on HC-STVG v2 box questions only, started from the 4B
175
+ baseline checkpoint: the box adapter began as a copy of that checkpoint's question adapter, the box head from its box
176
+ head. Both runs write the video with the unchanged base model, which is why the box parts can be combined with the
177
+ rule adapter.
178
+
179
+ ## Training data
180
+
181
+ | Source | Used for | Licence / terms |
182
+ |---|---|---|
183
+ | Charades (train), Charades-STA | "now", temporal, which-one and count questions; long training streams for cross-time rules | Allen Institute for AI, non-commercial research use |
184
+ | RepCount-A (train) | counting | no explicit licence found; treated as research use only |
185
+ | HC-STVG v2 (train) | boxes | no explicit licence found; treated as research use only |
186
+ | Rule wordings | English and Chinese wordings of the training rules, written by Claude Opus 5.5 from the structured rule and kept only if a blind back-parse matched; labels come from the rule engine, never from a language model | generated |
187
+ | Box head initialisation | box head of a 4B image Glance model (RefCOCO/+/g, gRefCOCO, COCO-based grounding data) | includes non-commercial sources |
188
+
189
+ Evaluation only: EPIC-KITCHENS-100 (CC BY-NC 4.0), HC-STVG v2 test.
190
+
191
+ ## License
192
+
193
+ - **Weights** (the two adapters and the box head): **CC BY-NC 4.0, non-commercial use only.** The training data
194
+ includes non-commercial sources (Charades, gRefCOCO via the box-head initialisation) and sources without an explicit
195
+ licence that we treat as research use only (RepCount-A, HC-STVG).
196
+ - **Code** ([GitHub](https://github.com/Vision-Decision/Glance-Stream)): Apache-2.0.
197
+ - **Base model** [Qwen/Qwen3.5-4B](https://huggingface.co/Qwen/Qwen3.5-4B): Apache-2.0, downloaded from its own
198
+ repository.
199
+
200
+ ## Citation
201
+
202
+ ```bibtex
203
+ @misc{glancestream2026,
204
+ title = {Glance-Stream: Standing Rules over a Live Video Stream},
205
+ author = {Vision-Decision},
206
+ year = {2026},
207
+ url = {https://github.com/Vision-Decision/Glance-Stream},
208
+ note = {Glance-Stream-0.8B and Glance-Stream-4B, https://huggingface.co/Vision-Decision}
209
+ }
210
+ ```
assets/demo.gif ADDED

Git LFS Details

  • SHA256: 967355aa6d5d1cb644e2e96f05cf609592d3775704a99b063179729a753f3ac9
  • Pointer size: 132 Bytes
  • Size of remote file: 6.66 MB
checks/independence.json ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "what": "Release composite (rule adapter + box adapter + box head) vs each training checkpoint alone, reference engine, NVIDIA RTX A6000, bf16, one 36.5 s clip at 30 fps (Pexels 6617422), 600 s memory window, 73 readouts, 4 rule questions, one of them with a box question; weights loaded from this repository (sha256 checked)",
3
+ "release_tensors_equal_training_checkpoints": {
4
+ "rule_adapter": true,
5
+ "box_adapter": true,
6
+ "box_head": true
7
+ },
8
+ "rule_p_yes_bit_identical_to_rule_checkpoint_alone": true,
9
+ "rule_p_yes_max_abs_diff": 0.0,
10
+ "boxes_bit_identical_to_box_checkpoint_alone": true,
11
+ "box_max_abs_diff": 0.0,
12
+ "peak_gpu_memory_gb_composite_4_rules_1_box": 12.48
13
+ }