M

← Back to Projects
Project 01v1.0.0-beta

RaceJudge

F1 Stewards' Precedent Engine: Semantic Search, Penalty Prediction & Live Race Intelligence

1,085
FIA Decision PDFs
7
Seasons Covered
< 5s
Live Precedent Delivery
132
Pytest Tests Passing
7-class
Penalty Predictor
20+
API Endpoints
The Problem

F1 stewardship decisions are inconsistent and opaque — fans, journalists, and teams have no way to query historical precedents, understand why a penalty was or wasn't issued, or predict outcomes from incident descriptions. The FIA publishes decisions as individual PDFs with no cross-referencing, no searchability, and no link to the race data that caused the incident.

The Solution

RaceJudge ingests every FIA stewards' decision PDF across 7 seasons, links each incident to race control messages, team radio (ASR-transcribed and speaker-diarised), and lap telemetry — building the only searchable, evidence-linked FIA decision corpus in existence. A hybrid retrieval stack (BM25 + BGE-M3 dense embeddings, RRF fusion) returns the most relevant precedents for any incident description. A calibrated XGBoost model predicts the most likely penalty across 7 classes. A RAG layer generates per-prediction rationales grounded in actual precedent text. A live WebSocket mode listens for investigation flags and surfaces top-5 precedents in real time during a race.

Architecture

Data pipeline: Playwright scraper → pdfplumber PDF parser → SHA-256 dedup → PostgreSQL corpus store → Faster-Whisper ASR + pyannote diarisation for team radio → OpenF1 + FastF1 telemetry linker → pgvector HNSW index (BGE-M3 embeddings, vector(1024), m=16, ef_construction=200). Prediction stack: BM25 index + pgvector ANN search → RRF fusion (k=60) → XGBoost 7-class classifier → MAPIE calibration → claude-haiku RAG rationale. Live mode: FastAPI WebSocket endpoint → Redis Pub/Sub → retrieval query → top-5 results streamed to client in < 5s. Orchestration: Prefect for pipeline scheduling, GitHub Actions CI (ruff + mypy + tsc + pytest 132 tests), Terraform + Fly.io deployment. Frontend: Next.js 15 App Router, 10+ pages, TypeScript, Tailwind CSS.

Key Features
1,085-Document FIA Corpus with Evidence Linking

A Playwright + pdfplumber pipeline scraped, parsed, and structured every FIA stewards' decision PDF across 7 seasons (2019–2025) with SHA-256 deduplication. Each decision is linked to its race control messages, team radio transcripts (Faster-Whisper ASR + pyannote speaker diarisation), and lap telemetry via OpenF1 and FastF1 APIs — building the only searchable, multi-modal FIA decision corpus in existence.

Hybrid Semantic Search: BM25 + BGE-M3 + RRF

Retrieval fuses BM25 keyword scoring with BGE-M3 1024-dimensional dense embeddings over a pgvector HNSW index (m=16, ef_construction=200) using Reciprocal Rank Fusion (k=60). Targeting Recall@10 ≥ 0.80. Any incident description returns the most relevant historical precedents ranked by hybrid relevance score.

Calibrated XGBoost 7-Class Penalty Predictor

A time-split cross-validated XGBoost classifier predicts the most likely stewards' outcome across 7 penalty classes. Trained with ECE and Macro-F1 validation gates (target: Macro-F1 ≥ 0.65, ECE < 0.05). Isotonic calibration applied post-training. MAPIE conformal prediction intervals provide uncertainty-aware outputs on every prediction.

RAG Precedent Rationale Layer

A retrieval-augmented generation layer (claude-haiku) takes the top-k retrieved precedents and the predicted penalty class and generates a structured explanation grounded in actual FIA decision text — telling the user not just what the likely outcome is, but why, with citations to specific historical cases.

Live Race Mode: WebSocket + Redis Pub/Sub

A WebSocket endpoint backed by Redis Pub/Sub listens for live investigation flags during a race. On trigger, the system queries the retrieval stack and returns the top-5 most relevant historical precedents in under 5 seconds — giving analysts and broadcasters real-time stewardship context as incidents unfold.

Full Next.js 15 App Router Web Platform

10+ pages including live race mode, precedent search, penalty prediction form, consistency heat-maps across drivers and teams, driver profiles, and an FIA guideline browser. Backed by a FastAPI service with 9 routers and 20+ endpoints. 132 pytest tests passing with green CI across ruff, mypy, tsc, and Next.js build. Tiered monetisation architecture: Free / $29 Pro / $499 Team / Enterprise.

Tech Stack
Python 3.11FastAPICeleryWebSocket + Redis Pub/SubPlaywrightpdfplumberNext.js 15 App RouterTypeScriptTailwind CSSPostgreSQL + pgvector HNSWRedisFaster-Whisper ASRpyannote (diarisation)BGE-M3 (dense embeddings)BM25 + RRF (k=60)XGBoost (7-class)MAPIE (calibration)LayoutLMv3RAG (claude-haiku)TerraformFly.ioPrefectGitHub Actions CI
backendfrontendmldbinframobile