Biddy Bears
Urban traffic congestion degrades commute times, increases emissions, and strains infrastructure, primarily because fixed-cycle traffic lights can't adapt to real-time conditions.
Core trick
Blends a DQN phase-selection policy with a fine-tuned Llama 3.1 8B that reasons over signal context to pick traffic-light phases.
Tags
Description
Urban traffic congestion degrades commute times, increases emissions, and strains infrastructure, primarily because fixed-cycle traffic lights can't adapt to real-time conditions. Agentic Traffic combines deep reinforcement learning with a fine-tuned LLM to control intersections across procedurally generated city networks. A dueling Double DQN with prioritized replay learns phase-selection across diverse scenarios (rush hour, accidents, construction), augmented by a fine-tuned Llama 3.1 8B model that guides action selection through contextual reasoning and awareness of surrounding signals. The hybrid system achieves ~30% improvement over the standalone DQN baseline in wait times and throughput, outperforming fixed-cycle and random baselines by a wider margin. The project includes CityFlow, a simulation environment with district-aware policy variants and a multi-policy comparison dashboard for visualizing replay behavior side-by-side.
README excerpt
---
title: Agentic Traffic
emoji: 🏢
colorFrom: green
colorTo: purple
sdk: docker
pinned: false
short_description: Agentic AI to control traffic lights
app_port: 7860
---
# traffic-llm
CityFlow-based traffic-control project with intersection-level multi-agent DQN training and district-aware policy variants.
Full model weights and files can be found here: https://huggingface.co/Aditya2162/agentic-traffic
## OpenEnv UI
For the deployed OpenEnv web interface:
- Click `Reset` before using `Step`.
- Leave `Use Llm` unchecked for the fast, stable DQN-only path.
- Use `District Actions` = `{}` for a valid no-op step payload.
- Only enable `Use Llm` when you explicitly want district-level LLM guidance on top of the DQN executor.
## Training
The default local-policy trainer now uses parameter-shared dueling Double DQN with prioritized replay and n-step returns:
```bash
python3 -m training.train_local_policy train
```
That trains against `data/generated`, uses `data/splits`, writes checkpoints to `artifacts/dqn_shared`, enables TensorBoard logging, uses parallel CPU rollout workers by default, shows `tqdm` progress bars, and now validates plus checkpoints every 40 updates by default.
For a broader but still manageable validation pass:
```bash
python3 -m training.train_local_policy train --max-val-cities 3 --val-scenarios-per-city 7
```
That evaluates 3 validation cities across all 7 scenario types. This gives 21 learned-policy validation episodes per eval, or 63 total episo