File size: 4,489 Bytes
f98dc3e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
<p align="center">
  <img src="./img/logo.png" alt="Visual Agentic Memory logo" width="60%" />
</p>

<h1 align="center">Visual Agentic Memory (VAM)</h1>

<p align="center">
  Transforms unconstrained video streams into hierarchical visual memory, supports query-driven agentic retrieval, and grounds answers through visual inspection.
</p>

## Motivation

VAM is designed for settings where relevant evidence is sparse, temporally distant, and difficult to localize with single-pass video reasoning. Rather than repeatedly scanning the full video, VAM performs online indexing into a persistent memory structure and retrieves only the most relevant evidence for downstream reasoning and verification.

<p align="center">
  <img src="./img/teaser.png" alt="Visual Agentic Memory teaser" width="100%" />
</p>

## Key Components

- **Online Indexing with Adaptive Deduplication**: A memory construction pipeline that identifies boundary-sensitive moments under strict online streaming constraints using an adaptive thresholding mechanism.
- **Hierarchical Memory with Parallel Representation**: A structured memory architecture that organizes moments and events across temporal tiers, balancing scalable storage with the preservation of recoverable visual details.
- **Agentic Retrieval for Grounded Reasoning**: A multi-turn retrieval loop in which an MLLM acts as a retrieval agent to search, inspect, and summarize evidence for auditable reasoning over distant events.
- **Training-free End-to-end Framework**: An integrated system that supports streaming perception and long-horizon retrieval using pre-trained multimodal components without task-specific retraining.

## Project Layout

- `vam/video.py`: video indexing pipeline used by both the TUI and the server.
- `vam/retrieval/`: memory store, indexing, search, and persistence.
- `vam/agent.py`: planning and response orchestration.
- `vam/vision/`: embedding client integration.
- `vam/tui.py`: packaged terminal interface.
- `vam/server/`: optional FastAPI and WebSocket entry points.
- `vam/cli.py`: console entry points for `vam-tui` and `vam-server`.

## Requirements

- Python `3.10+`
- FFmpeg installed on the host system

Install FFmpeg before running VAM:

```bash
# macOS
brew install ffmpeg

# Ubuntu / Debian
sudo apt update && sudo apt install -y ffmpeg

# Windows (Chocolatey)
choco install ffmpeg
```

If you do not use Chocolatey on Windows, install FFmpeg manually from [ffmpeg.org](https://ffmpeg.org/download.html).

## Installation

Clone the repository and install the package:

```bash
pip install .
```

This installs the Python dependencies and exposes two console commands:

- `vam-tui`
- `vam-server`

If you prefer `uv`, run the packaged entry points through an ephemeral install:

```bash
uv run --with . --python 3.11 vam-tui
uv run --with . --python 3.11 vam-server
```

## Configuration

Create a local environment file:

```bash
cp .env.example .env
```

Set at least:

- `OPENROUTER_API_KEY`

Common optional variables:

- `LLM_MODEL` default: `google/gemini-3-flash-preview`
- `EMBEDDING_MODEL` default: `google/gemini-embedding-2-preview`
- `VIDEO_FPS` default: `0.5`
- `FRAME_STORE_PATH` default: `data/frame_store.sqlite3`

## Usage

### Terminal TUI

Start the local terminal interface:

```bash
vam-tui
```

The TUI supports:

- indexing a video from a local path
- asking retrieval questions over stored memory
- generating summaries over selected time ranges
- browsing indexed memory and recent event documents

### Optional API Server

Start the server:

```bash
vam-server
```

Default endpoints:

- HTTP root: `http://localhost:8000/`
- Swagger docs: `http://localhost:8000/docs`
- WebSocket agent: `ws://localhost:8000/ws/agent`

You can override the port with `PORT`:

```bash
PORT=8011 vam-server
```

## Example Queries

After indexing a video, example questions include:

- "What happened right after I left the kitchen?"
- "Find the scene where I was sitting on the sofa but not watching TV."
- "How many times did I pick up a cup?"
- "Summarize the first 30 minutes, focusing on kitchen activity."

## Notes

- The package requires Python `3.10+`. A system `python3` on macOS may still point to `3.9`, which is not supported.
- FFmpeg is an external system dependency and is not installed by `pyproject.toml`.
- The TUI is the primary interface. The server is optional rather than the core product surface.

## License

This project is released under the [MIT License](LICENSE).