# internrobotics/streamvln architecture

> Architecture diagram of the GitHub repository internrobotics/streamvln, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-07-21). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/internrobotics/streamvln
- Repository: https://github.com/internrobotics/streamvln
- Video tour (about a minute): https://gitdiagram.com/internrobotics/streamvln/video

## Overview

#### Purpose and Entry Points
StreamVLN is an online vision-and-language navigation system: it consumes continuous visual observations plus navigation instructions and emits action tokens in a multi-turn dialogue loop. Primary workflows are training (`streamvln/streamvln_train.py`), simulation evaluation (`streamvln/streamvln_eval.py`), DAgger collection (`streamvln/streamvln_dagger.py`), trajectory generation (`streamvln/streamvln_trajectory_generation.py`), and real-world serving (`streamvln/http_realworld_server.py`).

#### Streaming Navigation Agent
`streamvln/streamvln_agent.py` is the runtime controller between an environment/robot and the model. It maintains the observation/action dialogue state, requests incremental model outputs, and feeds emitted actions back to navigation. `streamvln/model/stream_video_vln.py` adapts the Video-LLM for StreamVLN’s slow-fast context behavior: fast streaming context uses a sliding-window KV cache, while slow memory is updated through token pruning.

#### Multimodal Model Stack
The vendored LLaVA stack provides the base multimodal architecture and model loading boundary. `llava/model/llava_arch.py` integrates image/video features with language-model token streams; `llava/model/builder.py` constructs checkpoints, tokenizers, and processors; `llava/model/language_model/llava_qwen.py` is a supported Qwen language-model backend. Conversation formatting and image/token handling are centralized in `llava/conversation.py` and `llava/mm_utils.py`.

#### Vision Encoding and Token Adaptation
Visual frames cross a distinct encoder-to-language boundary. Encoder selection is dispatched by `llava/model/multimodal_encoder/builder.py`, with CLIP/EVA/Hugging Face, SigLIP, ImageBind, and related implementations available. Encoded visual tokens are resized or filtered by resamplers such as `llava/model/multimodal_resampler/perceiver.py` and `llava/model/multimodal_resampler/masked_drop.py`, then mapped into the LLM embedding space by `llava/model/multimodal_projector/builder.py`. This is the principal place where token-budget and slow-memory mechanisms can be shaped.

#### Data and Training Pipelines
Navigation trajectories are loaded from observation/action annotations by `streamvln/dataset/vln_action_dataset.py`; general interleaved multimodal co-training uses `streamvln/dataset/mmc4_dataset.py`. Stage-one and stage-two training are configured through `config/vln_r2r.yaml` and `config/co-training_data.yaml`, with distributed launch wrappers in `scripts/streamvln_train_slurm.sh` and `scripts/streamvln_stage_two_train_slurm.sh`. Core LLaVA optimization behavior is supplied by `llava/train/llava_trainer.py`; DPO-related paths are available through `llava/train/train_dpo.py` and the local `trl/` package.

#### Simulation, Evaluation, and Demonstrations
Habitat is the simulator/runtime dependency for VLN-CE episodes and MP3D/HM3D scenes. Evaluation drives the agent over simulator episodes and records navigation measures via `streamvln/streamvln_eval.py` and `streamvln/habitat_extensions/measures.py`. DAgger collection executes policy rollouts to produce additional image/action supervision in `streamvln/streamvln_dagger.py`; generated trajectories feed later training stages.

#### Serving and Real-World Boundary
For physical deployment, `realworld/go2_vln_client.py` connects model decisions to a Unitree Go2-oriented client, while `realworld/pid_controller.py` converts high-level movement intent into control behavior. `streamvln/http_realworld_server.py` exposes the model side over HTTP. This boundary separates GPU Python inference from robot transport/control and should preserve action validation, latency handling, and safety behavior.

#### Runtimes and External Assets
The intended runtime is Python 3.9, PyTorch 2.1.2, CUDA 12.4, plus Habitat-Sim/Habitat-Lab for simulation. Checkpoints and datasets are external, notably Hugging Face-hosted StreamVLN weights and trajectory data; required scene data are Matterport3D and HM3D. Multi-node/multi-GPU execution is expected through Slurm scripts and distributed helpers in `streamvln/utils/dist.py`.

Main entry points: [`streamvln/streamvln_train.py`](https://github.com/internrobotics/streamvln/blob/main/streamvln/streamvln_train.py) (Training entry point), [`streamvln/streamvln_agent.py`](https://github.com/internrobotics/streamvln/blob/main/streamvln/streamvln_agent.py) (Streaming navigation agent), [`streamvln/model/stream_video_vln.py`](https://github.com/internrobotics/streamvln/blob/main/streamvln/model/stream_video_vln.py) (Stream video VLN model), [`llava/model/llava_arch.py`](https://github.com/internrobotics/streamvln/blob/main/llava/model/llava_arch.py) (LLaVA multimodal architecture)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_model["Streaming model"]
  node_agent["Streaming navigation agent<br/>runtime controller<br/>[streamvln_agent.py]"]
  node_stream_model["Stream video VLN model<br/>Video-LLM adaptation"]
  node_llava_arch["LLaVA multimodal architecture<br/>multimodal token fusion<br/>[llava_arch.py]"]
  node_vision_encoder["Vision encoder selection<br/>encoder factory<br/>[builder.py]"]
  node_resampler["Visual token resampler<br/>token budget layer<br/>[perceiver.py]"]
  node_projector["Multimodal projector<br/>embedding adapter<br/>[builder.py]"]
  node_qwen["Qwen language backend<br/>language model backend<br/>[llava_qwen.py]"]
  node_model_builder["Model loader<br/>checkpoint loader<br/>[builder.py]"]
end

subgraph group_training["Data and training"]
  node_train["Training entry point<br/>Python entry point<br/>[streamvln_train.py]"]
  node_train_configs["Training configs<br/>YAML configuration<br/>[vln_r2r.yaml]"]
  node_slurm["Slurm launchers<br/>distributed launcher"]
  node_dist["Distributed helpers<br/>Python utility<br/>[dist.py]"]
  node_vln_data["VLN action dataset<br/>trajectory dataset"]
  node_mmc4_data["Interleaved multimodal data<br/>co-training dataset<br/>[mmc4_dataset.py]"]
  node_trainer["LLaVA trainer<br/>optimization engine<br/>[llava_trainer.py]"]
end

subgraph group_simulation["Simulation and evaluation"]
  node_eval["Simulation evaluation<br/>evaluation entry point<br/>[streamvln_eval.py]"]
  node_dagger["DAgger collection<br/>rollout collector"]
  node_habitat_measures["Habitat measures<br/>navigation metrics<br/>[measures.py]"]
end

subgraph group_deployment["Real-world serving"]
  node_http_server["Real-world HTTP server<br/>inference service"]
  node_go2_client["Go2 robot client<br/>robot transport<br/>[go2_vln_client.py]"]
  node_pid["PID controller<br/>motion controller<br/>[pid_controller.py]"]
end

node_slurm -->|"launches"| node_train
node_train_configs -->|"configures"| node_train
node_dist -->|"distributes"| node_train
node_vln_data -->|"supervision"| node_train
node_mmc4_data -->|"co-training data"| node_train
node_train -->|"optimizes with"| node_trainer
node_trainer -->|"trains"| node_stream_model
node_model_builder -->|"loads weights"| node_stream_model
node_agent -->|"requests outputs"| node_stream_model
node_stream_model -->|"adapts"| node_llava_arch
node_vision_encoder -->|"visual tokens"| node_resampler
node_resampler -->|"reduced tokens"| node_projector
node_projector -->|"visual embeddings"| node_llava_arch
node_qwen -->|"language backbone"| node_llava_arch
node_eval -->|"drives episodes"| node_agent
node_eval -->|"records"| node_habitat_measures
node_dagger -->|"policy rollouts"| node_agent
node_dagger -.->|"adds trajectories"| node_vln_data
node_http_server -->|"serves inference"| node_agent
node_go2_client -->|"action requests"| node_http_server
node_go2_client -->|"movement intent"| node_pid

click node_train "https://github.com/internrobotics/streamvln/blob/main/streamvln/streamvln_train.py"
click node_train_configs "https://github.com/internrobotics/streamvln/blob/main/config/vln_r2r.yaml"
click node_slurm "https://github.com/internrobotics/streamvln/blob/main/scripts/streamvln_train_slurm.sh"
click node_dist "https://github.com/internrobotics/streamvln/blob/main/streamvln/utils/dist.py"
click node_vln_data "https://github.com/internrobotics/streamvln/blob/main/streamvln/dataset/vln_action_dataset.py"
click node_mmc4_data "https://github.com/internrobotics/streamvln/blob/main/streamvln/dataset/mmc4_dataset.py"
click node_trainer "https://github.com/internrobotics/streamvln/blob/main/llava/train/llava_trainer.py"
click node_agent "https://github.com/internrobotics/streamvln/blob/main/streamvln/streamvln_agent.py"
click node_stream_model "https://github.com/internrobotics/streamvln/blob/main/streamvln/model/stream_video_vln.py"
click node_llava_arch "https://github.com/internrobotics/streamvln/blob/main/llava/model/llava_arch.py"
click node_vision_encoder "https://github.com/internrobotics/streamvln/blob/main/llava/model/multimodal_encoder/builder.py"
click node_resampler "https://github.com/internrobotics/streamvln/blob/main/llava/model/multimodal_resampler/perceiver.py"
click node_projector "https://github.com/internrobotics/streamvln/blob/main/llava/model/multimodal_projector/builder.py"
click node_qwen "https://github.com/internrobotics/streamvln/blob/main/llava/model/language_model/llava_qwen.py"
click node_model_builder "https://github.com/internrobotics/streamvln/blob/main/llava/model/builder.py"
click node_eval "https://github.com/internrobotics/streamvln/blob/main/streamvln/streamvln_eval.py"
click node_dagger "https://github.com/internrobotics/streamvln/blob/main/streamvln/streamvln_dagger.py"
click node_habitat_measures "https://github.com/internrobotics/streamvln/blob/main/streamvln/habitat_extensions/measures.py"
click node_http_server "https://github.com/internrobotics/streamvln/blob/main/streamvln/http_realworld_server.py"
click node_go2_client "https://github.com/internrobotics/streamvln/blob/main/realworld/go2_vln_client.py"
click node_pid "https://github.com/internrobotics/streamvln/blob/main/realworld/pid_controller.py"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_agent,node_stream_model,node_llava_arch,node_vision_encoder,node_resampler,node_projector,node_qwen,node_model_builder toneBlue
class node_train,node_train_configs,node_slurm,node_dist,node_vln_data,node_mmc4_data,node_trainer toneAmber
class node_eval,node_dagger,node_habitat_measures toneMint
class node_http_server,node_go2_client,node_pid toneRose
```

## Components

### Streaming model

Online multimodal inference and token adaptation.

- [Streaming navigation agent](https://github.com/internrobotics/streamvln/blob/main/streamvln/streamvln_agent.py): runtime controller · Maintains dialogue state and returns incremental navigation actions. · `streamvln/streamvln_agent.py`
- [Stream video VLN model](https://github.com/internrobotics/streamvln/blob/main/streamvln/model/stream_video_vln.py): Video-LLM adaptation · Uses sliding-window KV cache and pruned slow memory. · `streamvln/model/stream_video_vln.py`
- [LLaVA multimodal architecture](https://github.com/internrobotics/streamvln/blob/main/llava/model/llava_arch.py): multimodal token fusion · Combines visual features with language-model token streams. · `llava/model/llava_arch.py`
- [Vision encoder selection](https://github.com/internrobotics/streamvln/blob/main/llava/model/multimodal_encoder/builder.py): encoder factory · Selects CLIP, EVA, SigLIP, ImageBind, or Hugging Face encoders. · `llava/model/multimodal_encoder/builder.py`
- [Visual token resampler](https://github.com/internrobotics/streamvln/blob/main/llava/model/multimodal_resampler/perceiver.py): token budget layer · Resizes or filters encoded visual tokens. · `llava/model/multimodal_resampler/perceiver.py`
- [Multimodal projector](https://github.com/internrobotics/streamvln/blob/main/llava/model/multimodal_projector/builder.py): embedding adapter · Maps visual tokens into the LLM embedding space. · `llava/model/multimodal_projector/builder.py`
- [Qwen language backend](https://github.com/internrobotics/streamvln/blob/main/llava/model/language_model/llava_qwen.py): language model backend · `llava/model/language_model/llava_qwen.py`
- [Model loader](https://github.com/internrobotics/streamvln/blob/main/llava/model/builder.py): checkpoint loader · Constructs checkpoints, tokenizers, and processors. · `llava/model/builder.py`

### Data and training

Supervision, optimization, and distributed training.

- [Training entry point](https://github.com/internrobotics/streamvln/blob/main/streamvln/streamvln_train.py): Python entry point · `streamvln/streamvln_train.py`
- [Training configs](https://github.com/internrobotics/streamvln/blob/main/config/vln_r2r.yaml): YAML configuration · Defines stage-one VLN and stage-two co-training inputs. · `config/vln_r2r.yaml`
- [Slurm launchers](https://github.com/internrobotics/streamvln/blob/main/scripts/streamvln_train_slurm.sh): distributed launcher · `scripts/streamvln_train_slurm.sh`
- [Distributed helpers](https://github.com/internrobotics/streamvln/blob/main/streamvln/utils/dist.py): Python utility · `streamvln/utils/dist.py`
- [VLN action dataset](https://github.com/internrobotics/streamvln/blob/main/streamvln/dataset/vln_action_dataset.py): trajectory dataset · Loads observation and action annotations. · `streamvln/dataset/vln_action_dataset.py`
- [Interleaved multimodal data](https://github.com/internrobotics/streamvln/blob/main/streamvln/dataset/mmc4_dataset.py): co-training dataset · `streamvln/dataset/mmc4_dataset.py`
- [LLaVA trainer](https://github.com/internrobotics/streamvln/blob/main/llava/train/llava_trainer.py): optimization engine · `llava/train/llava_trainer.py`

### Simulation and evaluation

Habitat-based rollout, evaluation, and data collection.

- [Simulation evaluation](https://github.com/internrobotics/streamvln/blob/main/streamvln/streamvln_eval.py): evaluation entry point · Runs episodes and records navigation metrics. · `streamvln/streamvln_eval.py`
- [DAgger collection](https://github.com/internrobotics/streamvln/blob/main/streamvln/streamvln_dagger.py): rollout collector · Produces additional image/action supervision. · `streamvln/streamvln_dagger.py`
- [Habitat measures](https://github.com/internrobotics/streamvln/blob/main/streamvln/habitat_extensions/measures.py): navigation metrics · `streamvln/habitat_extensions/measures.py`

### Real-world serving

HTTP inference boundary and robot control.

- [Real-world HTTP server](https://github.com/internrobotics/streamvln/blob/main/streamvln/http_realworld_server.py): inference service · Separates GPU inference from robot transport. · `streamvln/http_realworld_server.py`
- [Go2 robot client](https://github.com/internrobotics/streamvln/blob/main/realworld/go2_vln_client.py): robot transport · `realworld/go2_vln_client.py`
- [PID controller](https://github.com/internrobotics/streamvln/blob/main/realworld/pid_controller.py): motion controller · Converts high-level movement intent into control behavior. · `realworld/pid_controller.py`

## Connections

- Slurm launchers → Training entry point: launches
- Training configs → Training entry point: configures
- Distributed helpers → Training entry point: distributes
- VLN action dataset → Training entry point: supervision
- Interleaved multimodal data → Training entry point: co-training data
- Training entry point → LLaVA trainer: optimizes with
- LLaVA trainer → Stream video VLN model: trains
- Model loader → Stream video VLN model: loads weights
- Streaming navigation agent → Stream video VLN model: requests outputs
- Stream video VLN model → LLaVA multimodal architecture: adapts
- Vision encoder selection → Visual token resampler: visual tokens
- Visual token resampler → Multimodal projector: reduced tokens
- Multimodal projector → LLaVA multimodal architecture: visual embeddings
- Qwen language backend → LLaVA multimodal architecture: language backbone
- Simulation evaluation → Streaming navigation agent: drives episodes
- Simulation evaluation → Habitat measures: records
- DAgger collection → Streaming navigation agent: policy rollouts
- DAgger collection → VLN action dataset: adds trajectories
- Real-world HTTP server → Streaming navigation agent: serves inference
- Go2 robot client → Real-world HTTP server: action requests
- Go2 robot client → PID controller: movement intent
