04 nlp pipeline - VforVitorio/F1_Strat_Manager GitHub Wiki

Radio Message Rules

Relevant source files

2.1. Sentiment Analysis Model

The sentiment model classifies radio messages into three categories:

  • Positive
  • Negative
  • Neutral

2.2. Intent Classification Model

The intent model categorizes messages into five types:

  • INFORMATION: Factual updates about race conditions
  • PROBLEM: Driver-reported issues
  • ORDER: Direct instructions to the driver
  • WARNING: Alerts about potential issues
  • QUESTION: Queries requiring driver input

2.3. Named Entity Recognition

The NER model identifies key entities in radio messages using the BIO (Beginning-Inside-Outside) tagging scheme:

Entity Type Description
ACTION Direct commands or actions
SITUATION Racing context descriptions
INCIDENT Accidents or on-track events
STRATEGY_INSTRUCTION Strategic directives
POSITION_CHANGE References to positions
PIT_CALL Calls for pit stops
TRACK_CONDITION Track state mentions
TECHNICAL_ISSUE Car-related problems
WEATHER Weather conditions

2.4. Pipeline Integration

The complete pipeline combines these models to produce structured data:

Example structured output:

3. Radio Rules Implementation

The F1RadioRules class extends the base F1StrategyEngine and implements three main rules that trigger specific strategy recommendations based on radio analysis.

3.1. Grip Issue Response Rule

This rule detects when a driver reports grip problems or technical issues with the car. Conditions:

  • Radio message has negative sentiment
  • Contains grip-related terms or TECHNICAL_ISSUE entities Action:
  • Recommends prioritizing a pit stop with 85% confidence
  • Medium-high priority (2 out of 3)

3.2. Weather Information Adjustment Rule

This rule identifies when weather changes are reported that might require strategy adjustments. Conditions:

  • Contains WEATHER entities
  • OR contains TRACK_CONDITION entities mentioning "wet" Action:
  • Recommends preparing rain tires with 90% confidence
  • High priority (3 out of 3)

3.3. Incident Reaction Rule

This rule detects safety car deployments or yellow flag situations. Conditions:

  • Contains INCIDENT entities with "safety" reference
  • OR contains SITUATION entities with "yellow" reference Action:
  • Recommends reevaluating pit window with 85% confidence
  • High priority (3 out of 3)

4. Integration Flow

The following diagram illustrates how radio messages are processed by the system, from input to strategy recommendation:

5. Example Usage and Testing

The system can be tested with different radio message scenarios to verify rule activation:

The test_radio_rules function demonstrates the full pipeline:

  1. Analyze the radio message using NLP
  2. Create a RadioFact from the analysis
  3. Run the F1RadioRules engine with the fact
  4. Return strategy recommendations

6. Transcription Capability

For processing audio radio communications, the system includes a transcription module based on OpenAI's Whisper model:

The transcription process converts audio messages to text before running them through the same analysis pipeline. Example usage:

7. Performance and Limitations

The Radio Message Rules system has the following characteristics:

  1. Strengths:
    • Integrates qualitative driver feedback into quantitative strategy
    • Handles both text and audio inputs
    • Rapidly identifies critical race conditions (weather, incidents)
  2. Limitations:
    • Effectiveness depends on NLP model accuracy
    • Relies on specific linguistic patterns and keywords
    • May miss nuanced or complex communications
  3. Error Handling:
    • Confidence scores indicate rule certainty