VSG: Visual-State Graph Memory for Streaming Video Understanding

Writing 
Video streamThe writer reads the last clip every 10 s, before any question exists.
Video frame at the current write 0:10 memory write
Visual-state graph 
created at this writemergednot seen now
Reader input if asked nowTokens per question
Every frame so far (1 fps)0
VSG≤ 3.5K
0:002:50 wrench5:30 screwdriver6:49 question

Abstract

In streaming video understanding, the evidence needed to answer a question may have already left the recent-frame window. Keeping all frames does not scale with video length, while dropping older frames limits the model's ability to reason about the past. We propose Visual-State Graph (VSG), a training-free memory that stores the state of a stream rather than the raw sequence of frames. VSG represents the stream as a graph of objects and their relations, together with a log of events, similar to a dynamically evolving scene graph. An object observed repeatedly is represented by one persistent node, with a timestamped history of how its state changes. To determine whether a newly mentioned object already exists in the graph, we compare the relations it takes part in with those of stored objects. We build this memory as the video arrives, before the questions are known. When a question arrives, we retrieve relevant objects and events alongside recent frames under a fixed input budget. Our evaluation spans four streaming-video benchmarks and seven open-source vision-language models ranging from 7B to 32B parameters. Under matched input budgets, VSG improves reasoning about the past while preserving real-time understanding.

Method

VSG overview: a causal writer produces triplets, object descriptions and captions; relational consolidation merges repeated mentions into persistent nodes with state histories and an event log; a VLM reader answers within a fixed token budget. Proactive mode writes an instruction-guided memory and checks a trigger every second.
Reactive (top): before any question, a frozen writer describes each clip; relational consolidation keeps one persistent node per object, and captions form the event log. The frozen reader answers from memory text, object crops and recent frames within budget tokens. Proactive (bottom): a per-instruction memory is written every second and checked by a yes/no trigger.

Relational consolidation

A mention is represented by the relations it takes part in. It is matched only against stored nodes of the same label class, and merged when the relational similarity exceeds \(\theta = 0.55\).

\[\mathbf{r}_k(\ell) = \frac{1}{|G_k(\ell)|}\sum_{(s,p,o)\in G_k(\ell)} \phi(s,p,o), \qquad \mathrm{resolve}_k(\ell) = \begin{cases} v^\star & \cos\!\big(\mathbf{r}_k(\ell), \bar{\mathbf{r}}_{v^\star}\big) > \theta \\ v_{\text{new}} & \text{otherwise} \end{cases}\]

Budgeted reading

Memory text is placed first, object crops second, and the remaining tokens go to frames. Try it with the reference budget \(B = 3{,}510\) (a frame costs about 195 tokens, a crop about 216).

\[n_f = \max\!\Big(0,\; \min\!\Big(n_{\max},\; \Big\lfloor \tfrac{B - |\sigma_T| - |q| - n_c\kappa_c}{\kappa_f} \Big\rfloor\Big)\Big)\]
970
2
memory textcropsframes

Code

The memory is written once per video and can be read by any number of questions and readers. Both models are frozen.

# install
git clone https://github.com/ailarmhz/VSG.git
cd VSG && pip install -r requirements.txt

# write the memory (no question)
python scripts/write_memory.py \
    --video clip.mp4 --out memory/clip

# answer at T = 409 s, B = 3,510 tokens
python scripts/answer.py --video clip.mp4 \
    --memory memory/clip --time 409 \
    --question "What tool did I use to tighten the screw?" \
    --options "A. screwdriver" "B. hammer" \
              "C. pliers" "D. wrench"
vsg/
  memory.py      graph, consolidation, write log
  writer.py      question-agnostic writer
  reader.py      retrieval and budgeted reading
  proactive.py   instruction-guided memory, trigger
  grounding.py   OWLv2 boxes and crops
  prompts.py     writer and reader prompts
  labels.py      label classes
scripts/
  write_memory.py
  answer.py