Skip to content

Latest commit

 

History

History
249 lines (210 loc) · 6.38 KB

software-architecture.md

File metadata and controls

249 lines (210 loc) · 6.38 KB

Automotive LLM System - Software Architecture

Operating System

Raspberry Pi OS (64-bit)

  • Debian-based Linux optimized for Pi hardware
  • Custom automotive boot configuration
  • Read-only root filesystem for reliability
  • Systemd services for automotive processes

Local LLM Selection

Primary Model Options:

  1. Llama 3.1 8B Instruct (Recommended)

    • 8 billion parameters
    • Excellent instruction following
    • Automotive domain fine-tuning potential
    • ~5GB model size
  2. Phi-3 Medium (14B)

    • Microsoft's efficient model
    • Good reasoning capabilities
    • Optimized for edge deployment
    • ~8GB model size
  3. Mistral 7B Instruct

    • Fast inference speed
    • Good automotive knowledge
    • Commercial use friendly
    • ~4GB model size

Inference Engine

Ollama

  • Local LLM serving platform
  • Optimized for edge devices
  • Model quantization support (Q4_K_M recommended)
  • REST API for integration
  • Automatic model management

Hailo Optimization

  • Hailo Runtime integration
  • Neural network acceleration
  • Optimized model compilation
  • Real-time inference performance

Core Software Stack

Voice Processing Pipeline

Speech-to-Text (STT)

  • OpenAI Whisper (base model)
  • Hailo-optimized for real-time processing
  • Offline operation capability
  • Automotive noise filtering

Text-to-Speech (TTS)

  • Piper TTS (lightweight)
  • Natural voice synthesis
  • Low latency for real-time response
  • Multiple voice options

Wake Word Detection

  • Picovoice Porcupine
  • Custom wake words: "Hey Car", "Vehicle Assistant"
  • Always-on listening with low power
  • Hardware acceleration support

Vehicle Integration Layer

OBD-II Interface

  • Python-OBD library
  • Real-time diagnostic data
  • Fault code interpretation
  • Performance monitoring

CAN Bus Communication

  • python-can library
  • Vehicle-specific protocol adapters
  • Message filtering and parsing
  • Safety-critical communication

Control Systems

HVAC Management

  • Temperature control logic
  • Fan speed adjustment
  • Mode selection (heat/cool/auto)
  • Zone-based control for multi-zone systems

Engine Management

  • Performance parameter monitoring
  • Tuning parameter adjustment
  • Safety limit enforcement
  • Real-time diagnostics

Lighting Control

  • Interior lighting automation
  • Exterior lighting management
  • Ambient lighting customization
  • Emergency lighting protocols

Application Architecture

Core Services

┌─────────────────────────────────────────┐
│             Main Controller             │
├─────────────────────────────────────────┤
│  Voice Manager  │  Vehicle Interface    │
│  LLM Controller │  Safety Monitor       │
│  Device Manager │  System Health        │
└─────────────────────────────────────────┘

Main Controller

  • Central orchestration service
  • Inter-service communication
  • State management
  • Error handling and recovery

Voice Manager

  • Audio capture and processing
  • Wake word detection
  • STT/TTS pipeline management
  • Conversation context handling

LLM Controller

  • Model loading and management
  • Prompt engineering for automotive context
  • Response generation and filtering
  • Context-aware conversations

Vehicle Interface

  • OBD-II/CAN bus communication
  • Vehicle state monitoring
  • Command execution
  • Data logging

Safety Monitor

  • Critical system oversight
  • Emergency protocols
  • Fail-safe mechanisms
  • Driver attention monitoring

Data Flow

  1. Voice Input → Wake Word Detection → STT
  2. Text Processing → Intent Recognition → LLM Processing
  3. Command Generation → Safety Validation → Vehicle Control
  4. Response Generation → TTS → Audio Output
  5. Continuous Monitoring → Vehicle State → Context Updates

Development Framework

Primary Language: Python 3.11+ Key Libraries:

  • asyncio - Asynchronous processing
  • fastapi - REST API framework
  • pydantic - Data validation
  • sqlalchemy - Database ORM
  • redis - Caching and message queue

Container Architecture:

  • Docker containers for service isolation
  • Docker Compose for multi-service orchestration
  • Volume mounting for persistent data
  • Health checks and auto-restart

Database Architecture

SQLite (Primary)

  • Vehicle configuration
  • User preferences
  • Command history
  • System logs

Redis (Cache/Queue)

  • Real-time vehicle state
  • Message queuing
  • Session management
  • Performance metrics

Security Architecture

Authentication

  • Voice biometrics (optional)
  • PIN-based access for sensitive functions
  • Multi-factor authentication for setup

Authorization

  • Role-based access control
  • Command-level permissions
  • Safety-critical function restrictions
  • Emergency override protocols

Data Protection

  • Local data encryption at rest
  • Secure communication protocols
  • No cloud data transmission
  • Privacy-focused design

Configuration Management

Vehicle Profiles

  • Make/model-specific configurations
  • Custom command mappings
  • Performance parameter limits
  • Safety protocol definitions

User Preferences

  • Voice recognition training
  • Personalized responses
  • Comfort settings
  • Usage patterns

Monitoring and Logging

System Health

  • Resource utilization monitoring
  • Temperature and performance metrics
  • Error rate tracking
  • Predictive maintenance alerts

Audit Logging

  • All voice commands logged
  • Vehicle control actions recorded
  • System access events
  • Safety incident documentation

Update and Maintenance

Over-the-Air Updates

  • Secure update delivery
  • Rollback capability
  • Staged deployment
  • Minimal downtime updates

Model Updates

  • LLM model versioning
  • A/B testing framework
  • Performance regression detection
  • Automated rollback on failure

Performance Optimization

Model Quantization

  • INT4/INT8 quantization for speed
  • Dynamic quantization during inference
  • Memory usage optimization
  • Batch processing for efficiency

Caching Strategy

  • Frequent command caching
  • Vehicle state caching
  • Response template caching
  • Predictive loading

Development Tools

  • Testing: pytest, automotive simulation
  • Monitoring: Prometheus, Grafana
  • Debugging: Remote debugging capability
  • Documentation: Automated API documentation