nlp pipeline - VforVitorio/F1_Strat_Manager GitHub Wiki

NLP Pipeline

VforVitorio/F1_Strat_Manager

powered by

Devin

NLP Pipeline

This document describes the Natural Language Processing (NLP) pipeline used in the F1 Strategy Manager system to analyze team radio communications. The pipeline extracts structured information from radio messages that can be used by the strategy engine to make informed race decisions. For information about how these insights are used in the expert system, see Expert System.

Purpose and Scope

The NLP pipeline processes Formula 1 team radio messages to extract:

  • Overall sentiment (positive, negative, neutral)
  • Communication intent (orders, information, questions, etc.)
  • Specific racing entities (actions, incidents, track conditions, etc.)

The pipeline transforms unstructured audio or text into structured JSON data that can be directly used by the F1 Strategy Engine's rule system.

Pipeline Architecture

NLP Pipeline Flow

The pipeline consists of four main components that can be used together or independently:

  1. Radio Transcription: Converts audio files to text using Whisper model
  2. Sentiment Analysis: Classifies message sentiment using RoBERTa
  3. Intent Classification: Categorizes message purpose using RoBERTa
  4. Named Entity Recognition: Extracts specific entities using BERT

These components are integrated into a unified pipeline that produces a standardized JSON output used by the expert system.

Radio Transcription Component

The transcription component converts team radio audio files to text using OpenAI's Whisper model.

Architecture and Implementation

The transcription component uses Whisper Turbo, a speech-to-text model that balances accuracy and performance. Key implementation details include:

  • Model Size: Turbo variant (809M parameters) optimized for speed
  • Memory Usage: ~6GB VRAM, using FP16 precision to reduce memory requirements
  • Audio Processing: Handles multiple audio formats (MP3, WAV, M4A, OGG)
  • Batch Processing: Can transcribe multiple files and maintain driver metadata

Example transcription:

"Max, we've currently got yellows in turn 7. Ferrari in the wall, no? Yes, that's Charles stopped. 
We are expecting the potential of an aborted start, but just keep to your protocol at the moment."

Sentiment Analysis Component

The sentiment analysis component classifies the emotional tone of radio messages into three categories: positive, negative, or neutral.

Model Architecture

The sentiment analyzer uses a fine-tuned RoBERTa-base model trained on labeled F1 radio messages. Key details:

  • Base Model: RoBERTa with 125M parameters
  • Fine-tuning: Trained on ~500 labeled team radio messages
  • Output: 3-class classification with confidence score
  • Integration: Deployed within predict_sentiment() function

Example output:

{
  "text": "Great move Oscar",
  "sentiment": "positive",
  "confidence": 59.62
}

Intent Classification Component

The intent classification component identifies the communicative purpose of radio messages, categorizing them into functional types.

Intent Categories

Intent Description Example
ORDER Direct instructions requiring action "Box this lap", "Push now"
INFORMATION Factual updates about race conditions "Hamilton is 2 seconds behind"
PROBLEM Driver-reported issues "Losing grip on the rear"
WARNING Alerts about potential issues "Yellow flag in sector 2"
QUESTION Queries requiring driver input "How are the tyres feeling?"

Model Architecture

The intent classifier uses a fine-tuned RoBERTa-large model with:

  • Base Model: RoBERTa Large (355M parameters)
  • Fine-tuning: Trained on manually labeled intent data
  • Function: predict_intent() provides intent classification with confidence scores

Named Entity Recognition Component

The Named Entity Recognition (NER) component extracts specific racing-related entities from radio messages, providing structured information about actions, situations, incidents, and more.

Entity Types

The NER component processes text by:

  1. Tokenizing the input text
  2. Applying BERT-based token classification
  3. Converting token predictions to entity spans
  4. Formatting entities as a structured list

Each entity is tagged with its type and the extracted text, enabling strategic analysis of specific racing elements.

BIO Tagging Approach

The NER model uses BIO (Beginning-Inside-Outside) tagging to identify multi-word entities:

  • B- tags mark the first word of an entity (e.g., B-ACTION)
  • I- tags mark words continuing an entity (e.g., I-ACTION)
  • O tags mark words not part of any entity

Example BIO tagging:

"Max,"            -> O
"we've"           -> B-SITUATION
"currently"       -> I-SITUATION
"got"             -> I-SITUATION
"yellows"         -> I-SITUATION
"in"              -> I-SITUATION
"turn"            -> I-SITUATION
"7."              -> I-SITUATION
"Ferrari"         -> B-INCIDENT
"in"              -> I-INCIDENT
"the"             -> I-INCIDENT
"wall,"           -> I-INCIDENT

Pipeline Integration

The pipeline components are integrated into a unified analysis system that can process either audio or text input and produce standardized JSON output.

Integrated Pipeline Architecture

The integrated pipeline:

  1. Loads all three models (sentiment, intent, NER)
  2. Processes input through each model in parallel
  3. Combines predictions into a standardized format
  4. Outputs structured JSON with timestamp

Standardized JSON Output

The pipeline produces a JSON structure that captures all aspects of radio message analysis:

This structured output is stored with timestamps and can be directly consumed by the F1 Strategy Engine to inform race decisions.

Usage and Integration with Strategy Engine

The NLP pipeline's output is designed to integrate seamlessly with the F1 Strategy Engine as RadioFact objects. These facts are used by the expert system to trigger rules based on radio communications.

Data Flow to Expert System

The expert system uses the structured radio analysis to:

  • Identify driver complaints about tires or car handling
  • Detect weather changes reported via radio
  • Monitor competitor strategies mentioned in communications
  • Combine radio insights with telemetry data for comprehensive race strategy

The NLP pipeline acts as a crucial bridge between unstructured communication and actionable race strategy intelligence.

On this page