SLM for Route Management

Compiled: 2025-10-05 • Small Language Models (SLMs) as the control plane between humans, sensors, and your routing engine.

Use the solver (OR‑Tools/OSRM/Valhalla) as the optimizer, and an SLM as the orchestration layer that cleans inputs, handles exceptions, explains decisions, and drafts human‑readable actions.

What SLMs do well for routing

Architecture (fast & cheap)

TierWhat runs hereNotes
Edge (on‑truck) 1–3B SLM (quantized) for triage, SOP lookups (local RAG), driver messages; sensor fusion with GNSS/IMU, cameras, scales, VOC, CO, temp. Low latency; privacy‑preserving (event clips & features only).
Cloud/Depot Bigger SLM optional: clean backlogs, what‑if analysis, post‑shift summaries; long‑horizon planning & analytics. Batch workloads; integrates CRM/311.
Optimizer + Maps CVRP/VRPTW solving, ETAs, routing on OSRM/Valhalla; LNS/local search. SLM calls these tools; it doesn’t replace them.
Comms MQTT/HTTPS telemetry, depot Wi‑Fi offload, LTE/5G for live patches. Idempotent, auditable APIs.

Handoff JSON Schemas (SLM ↔ Optimizer)

1) Stop schema (normalized)

{
  "id": "STOP-12345",
  "address": "412 Oak St, Springfield",
  "lat": 37.7712,
  "lon": -122.4312,
  "service_type": "organics",                // trash | recycling | organics | bulky | special
  "duration_min": 4,
  "time_window": ["08:00", "10:00"],        // local time, 24h
  "priority": "high",                        // low | normal | high
  "hard": true,                              // hard = must‑serve in window
  "constraints": {
    "access": ["alley"],                     // alley | school_zone | gated | ...
    "noise_window": ["07:00", "21:00"],
    "axle_weight_max_kg": 9000
  },
  "attachments": [
    {"type":"note","text":"Behind the clinic"},
    {"type":"photo","url":"https://…/ticket123.jpg"}
  ]
}

2) Vehicle schema (excerpt)

{
  "id": "TRUCK-12",
  "start_depot": "DEPOT-A",
  "capacity_kg": 9500,
  "streams": ["trash","recycling","organics"],
  "payload_kg": {"trash": 1800, "recycling": 400, "organics": 0},
  "shift_window": ["06:00","15:00"],
  "features": ["split_body","rfid_reader","hopper_cam"]
}

3) Patch schema (small reroute)

{
  "patch_id": "PATCH-2025-10-05-1",
  "vehicle_id": "TRUCK-12",
  "type": "insert_stop",                     // insert_stop | skip_stop | reorder | swap_vehicle | block_edge
  "payload": {
    "stop": <STOP JSON>,
    "position_hint": "after:STOP-9876",
    "valid_for_min": 30
  },
  "audit": {"reason":"blocked alley","source":"driver_voice","evidence":["photo:..."]}
}

Tool API pattern (called by the SLM)

Example prompts (drop‑in)

A) Free‑text ticket → normalized stop

System: You convert messages into a normalized JSON “stop” using the Stop schema. If info is missing, set nulls and add a note.

User: "Urgent: overflowing green cart behind the community clinic at 412 Oak St. please pick up before 10am. Use the alley."

Assistant (JSON only): {...}

B) Exception triage → patch

System: Create a small reroute patch. If policy conflicts exist, set type="swap_vehicle" and explain in the audit.

User: "Alley blocked at 102 Pine — grabbed photo. Can’t reach STOP-7781."

Assistant (JSON only): {...}

C) Driver copilot (voice)

System: Answer briefly. Use tool calls for ETAs/policy. Include a single actionable sentence for the driver.

User: "Can I hit 412 Oak before school starts?"

Assistant: "Yes—arrive 07:42, within noise window. Reordering two stops now; you’ll see it in the cab."

D) After‑action explanation

System: Summarize why Route 12 exceeded plan by <delta>. Correlate traffic, contamination inserts, and compactor cycles; propose two fixes.

KPIs you can move

Sources & Building Blocks