Glance-Stream-4B
The 4B sibling of Glance-Stream-0.8B: the same standing yes/no rules over a live video stream, checked together every half second, including rules about what happened before, plus a box for the person a rule is about. Same package, same API, same recipe on Qwen3.5-4B.
GitHub (code, docs) · Usage · Results · Limitations · 0.8B or 4B? · Training data · License
You attach rules to a 30 fps video stream: "is someone cutting vegetables right now", "whenever the fridge is opened it must be closed within 30 seconds", "cutting is only allowed if hands were washed in the minute before". Every 0.5 s the model answers all of them at once with p(yes) for "is this rule violated right now", from one shared state of the stream; an alert fires after two consecutive readouts above the threshold. For rules that carry a person description it also returns that person's box in the current frame.
Real model outputs on the same Pexels clip as the 0.8B demo (Anna Shvets, Pexels License),
rendered by examples/make_demo.py; raw
readouts in assets/demo_predictions_4B.json.
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
misses a brief return to cutting at about 6.5 s.
What is in this repository
| File | Content |
|---|---|
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) |
box_lora.safetensors |
box-question adapter, same shape, used only for box questions |
box_head.safetensors |
box head: presence, choice of patch, four ordinal edge distributions, IoU; one latent token read at layer 32 |
config.json |
base model id, adapter files, stream shape (256×256, 64 tokens per frame group), memory window, readout period, alert defaults |
checks/independence.json |
the check that the two adapters do not interact (see below) |
The base weights are not included; they load from Qwen/Qwen3.5-4B
(Apache-2.0, about 9 GB). The weights need the glance_stream package:
the streaming state, the forked question blocks and the box head are not part of transformers.
Model description
The architecture and streaming policy are those of Glance-Stream-0.8B; only the base model is larger.
- Stream. Each frame group (two consecutive frames through the Qwen3.5 vision tower's 2-frame tubelet, 64 tokens at 256×256, plus a text timestamp every 0.5 s) is written once into the model's state. The Gated-DeltaNet layers carry their recurrent state through the whole video; the full-attention layers keep a bounded window (every group 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 streams stay in the trained range.
- Questions never write back. Every rule is a short question block forked from the current state and discarded after the answer, so adding a rule never changes the other answers or the stream. All rules of one readout are one batched forward.
- Answers. p(yes) from the first answer token, restricted to the yes/no tokens; no text is generated.
- Adapters only on questions. The LoRA adapters are active only on question tokens. The video path runs the
unchanged base model, so rule questions and box questions can use separate adapters without interacting: on a 36 s
clip with four rules and one box, the released model's rule probabilities are bit-identical to the rule checkpoint
alone and its boxes bit-identical to the box checkpoint alone (
checks/independence.json). - 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 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 state. There is no event detector or state machine at inference time.
Usage
pip install "glance-stream @ git+https://github.com/Vision-Decision/Glance-Stream"
pip install flash-linear-attention # optional, CUDA only: fast Gated-DeltaNet kernels
from glance_stream import GlanceStream, Rule
gs = GlanceStream.from_pretrained("Vision-Decision/Glance-Stream-4B") # CUDA if available
mon = gs.monitor([
Rule.now("someone is cutting vegetables"),
Rule.must_follow("someone opens the fridge", "someone closes the fridge", within=30),
Rule.now("someone is holding a knife", box="the woman holding a knife"),
])
def on_readout(r): # called every 0.5 s of video, as the stream is processed
for name in r.alerts:
print(f"{r.t:.1f}s ALERT {name} p={r.p[name]:.2f}", r.boxes.get(name))
readouts = mon.run("kitchen.mp4", fps=30, callback=on_readout) # all readouts, also returned at the end
Command line: python examples/run_rules.py my_video.mp4 --model Vision-Decision/Glance-Stream-4B --rules examples/kitchen_rules.json --out readouts.json.
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 enough; CPU works but is far from real time.
Results
Only final results are listed. Protocols are in docs/EVALUATION.md. The comparison is against the same recipe on Qwen3.5-4B without rule training (the 4B baseline), both evaluated on the same hardware. Differences are means over participants, tested with an exact paired sign-flip test; the tests were fixed before the 4B results existed.
| What | Data | Result |
|---|---|---|
| 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 |
| 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) |
| 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) |
| Macro AUROC on cross-time rules (secondary) | same 22 streams | 0.687 → 0.793; paired mean +0.106 (p = 0.002) |
| 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 |
| 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) |
| Box Acc@0.5 (person descriptions) | HC-STVG v2 test, 267 clips, 2 fps | 45.7 |
- The primary result was not met. The pre-registered primary test for 4B was the drop in false alarms on the original 8 streams. False alarms halved, but one of the six participants went the other way (+12.6), and with six participants the exact test cannot reach p ≤ 0.05 unless all six agree. On the 22-stream set used as the main result for 0.8B (a secondary analysis here), the drop is significant.
- The false-alarm results use a threshold chosen for 80% event recall on held-out participants, alerts after 2 consecutive readouts and a 5 s cooldown, every rule asked every 0.5 s at 30 fps with the 600 s window.
- Speed: no latency number is reported for this release.
0.8B or 4B?
| 0.8B | 4B | |
|---|---|---|
| Cross-time false alarms per rule-hour, 22 streams, rule-trained | 173.4 | 93.3 |
| Same, baseline of the same size | 289.9 | 162.8 |
| Box Acc@0.5, HC-STVG v2, 267 clips | 48.5 | 45.7 |
| "Now" rules: no-forgetting test against its baseline | not established (on par, upper bound above the margin) | met (0.876 [0.771, 0.998]) |
| Peak GPU memory, demo clip (bf16) | not measured | 12.5 GB |
The two sizes were evaluated in separate runs with the same evaluator and protocol, but not on the same hardware, and no test compares them directly: read the cross-size rows as levels, not as a measured difference. The 4B model raises fewer false alarms on cross-time rules; the 0.8B model boxes people better. Neither is an alert-free monitor.
Limitations
- The primary 4B result was not met (see Results): the false-alarm drop on the pre-registered 6-participant set is not significant (p = 0.0625).
- Count rules lean towards firing. The 4B model over-counts: on counting questions with true counts of 1–7 its 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 times in T seconds" rules fire too often.
- "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 baseline is at 0.47, below chance); the model does not reliably tell "B already came" from "B has not come yet". Do not rely on this rule type.
- Boxes are worse than 0.8B. Acc@0.5 45.7 against 48.5. The box head was trained and tested on person descriptions (HC-STVG) at 2 fps; boxes for objects are untested, and it reads a 256×256 frame, so small people are coarse.
- Thresholds are not tuned for you. The default threshold 0.5 is a starting point; the benchmark chose thresholds on held-out data. Probabilities for cross-time rules are not calibrated. Set thresholds per rule on your own footage.
- Domain. Trained on indoor home clips (Charades) and evaluated on kitchens; outdoor, industrial or surveillance footage is untested. Only the template wording was evaluated; Chinese and free-form rules were in training but are not evaluated.
- No timestamps or counts as answers in this release (yes/no and boxes only).
Training
The same recipe as 0.8B, with only the model size changed; no hyperparameter was tuned for 4B.
- Rule adapter. From the frozen base model, 1,200 steps with a global batch of 4 clips, streamed in the inference shape (bounded window, no gradient through the video path); questions are forked at random times and answered as text (yes/no, spans, counts, options) on Charades, Charades-STA and RepCount-A. 35% of the batches are long training streams (5–10 min of spliced Charades train clips) with about 16 rules each, labelled at every readout time by the rule engine from the human annotations. Trained on 4 GPUs (data parallel, one clip per GPU); the 4B baseline was trained on one GPU with the same global batch.
- Box adapter and box head. A separate 1,500-step run on HC-STVG v2 box questions only, started from the 4B baseline checkpoint: the box adapter began as a copy of that checkpoint's question adapter, the box head from its box head. Both runs write the video with the unchanged base model, which is why the box parts can be combined with the rule adapter.
Training data
| Source | Used for | Licence / terms |
|---|---|---|
| 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 |
| RepCount-A (train) | counting | no explicit licence found; treated as research use only |
| HC-STVG v2 (train) | boxes | no explicit licence found; treated as research use only |
| 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 |
| Box head initialisation | box head of a 4B image Glance model (RefCOCO/+/g, gRefCOCO, COCO-based grounding data) | includes non-commercial sources |
Evaluation only: EPIC-KITCHENS-100 (CC BY-NC 4.0), HC-STVG v2 test.
License
- Weights (the two adapters and the box head): CC BY-NC 4.0, non-commercial use only. The training data includes non-commercial sources (Charades, gRefCOCO via the box-head initialisation) and sources without an explicit licence that we treat as research use only (RepCount-A, HC-STVG).
- Code (GitHub): Apache-2.0.
- Base model Qwen/Qwen3.5-4B: Apache-2.0, downloaded from its own repository.
Citation
@misc{glancestream2026,
title = {Glance-Stream: Standing Rules over a Live Video Stream},
author = {Vision-Decision},
year = {2026},
url = {https://github.com/Vision-Decision/Glance-Stream},
note = {Glance-Stream-0.8B and Glance-Stream-4B, https://huggingface.co/Vision-Decision}
}
- Downloads last month
- -
