--- title: Match Decoded emoji: โฝ colorFrom: indigo colorTo: blue sdk: streamlit sdk_version: "1.52.0" app_file: frontend/app.py pinned: false license: apache-2.0 --- # โฝ Match Decoded ### AI-powered football match explainability โ powered by IBM Granite + LangChain + Docling **IBM AI Builders Challenge 2026 ยท June Football Challenge** [](https://ibm.com/granite) [](https://python.langchain.com/) [](https://github.com/IBM/docling) [](https://bob.ibm.com/) [](https://python.org) [](https://streamlit.io) --- ## ๐๏ธ The Problem **49,000 international football matches. 215 teams. 154 years of data.** And yet, when a fan watches a match, they hear commentary about *what* happened โ but rarely *why*. > *"Brazil lost to Argentina. But was it because of form? Venue? Historical matchup? Tournament pressure?"* Fans deserve to understand the invisible forces shaping every match. Teams have million-dollar analytics departments. Fans have bias and guesswork. **Match Decoded bridges that gap.** --- ## ๐ง The Solution Match Decoded is an AI-powered football explainability platform that transforms raw match data into **Granite-generated tactical narratives**, **what-if simulations**, and **fully traceable decision explanations**. | Fan Experience | Match Decoded | |---|---| | "Who do you think will win?" | **"Here's WHY โ based on 8 factors from 49K historical matches"** | | "What if it was a home game?" | **Real-time what-if simulator with AI analysis of the delta** | | "Was Brazil 1970 better than Spain 2010?" | **Legends Matchup โ cross-era Granite-powered comparison** | | "The pundit says X. Is that right?" | **Full decision trace with feature importance โ no black box** | ### Key Insight: Explainability Over Prediction This is NOT a score predictor. This is a **match decoder** โ an AI that explains *why* outcomes are likely, so every fan understands the game at a deeper level. --- ## ๐ง IBM Technologies Used | # | Technology | How We Use It | Status | |---|---|---|---| | 1 | **IBM Granite 3.1-2B** | Core AI engine โ generates tactical previews, decision explanations, momentum analysis, legends matchups, and match report analysis via HuggingFace Inference API | โ Live | | 2 | **LangChain** | `ChatPromptTemplate` for all 5 prompt types (preview, explain, momentum, legends, docling analysis) โ structured, type-safe prompt engineering | โ Live | | 3 | **IBM Docling** | PDF match report parser โ extracts structured text from football report PDFs, feeds parsed data to Granite for AI analysis | โ Integrated | | 4 | **IBM Bob** | AI code assistant used throughout development โ architecture design, debugging, deployment setup | โ Documented | ### IBM Granite is the Star Unlike projects where AI is a wrapper around a deterministic engine, Match Decoded puts Granite at the center: - Every tactical preview is **Granite-generated**, not templated - Every decision trace includes **Granite's natural language reasoning** - Every momentum analysis is **Granite explaining probabilities in context** - Every legends matchup is **Granite's take on historical football debate** - Every match report analysis uses **Granite to extract tactical insight from raw text** --- ## โจ Features ### ๐ฎ Pre-Match Preview Select any two teams from 215 international sides. See the predicted outcome with probability breakdown, then read a **Granite-generated tactical preview** explaining WHY one team has the edge. ### ๐ What-If Simulator Change venue (neutral/home) and tournament type (major/friendly). Watch the prediction shift in real time. **Granite explains the delta** โ what changed and why. ### ๐ Legends Matchup Cross-era comparisons โ Brazil 1970 vs Germany 2014? England 1966 vs France 2018? **Granite settles the debate** with statistical context and passionate football storytelling. ### ๐ Match Report Analyzer (Docling) Upload a football match report PDF. **IBM Docling** extracts the text. **Granite + LangChain** analyzes the tactics, key moments, and what decided the match. ### ๐ Decision Trace Every prediction is fully transparent. View: - **Feature importance** โ which factors drove the prediction - **Granite explanation** โ AI-generated narrative of the model's reasoning - **Model metrics** โ accuracy, feature weights, training methodology ### ๐ง Model Transparency - **Algorithm**: Random Forest (200 trees, max depth 12) - **Accuracy**: 55.8% on unseen data (vs 47.2% baseline) - **Training**: 24,179 matches (pre-2018) - **Testing**: 7,652 matches (2018+) - **Features**: 8 factors โ win rates, goal averages, recent form, venue, tournament type --- ## ๐๏ธ Architecture ``` โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โ Streamlit Frontend โ โ โโโโโโโโโโโโ โโโโโโโโโโโโ โโโโโโโโโโ โโโโโโโโโโโโ โ โ โ Preview โ โWhat-If โ โLegends โ โ Docling โ โ โ โ โ โSimulator โ โMatchup โ โAnalyzer โ โ โ โโโโโโโฌโโโโโโ โโโโโโฌโโโโโโ โโโโโฌโโโโโ โโโโโโฌโโโโโโ โ โโโโโโโโโโผโโโโโโโโโโโโโโผโโโโโโโโโโโโผโโโโโโโโโโโโผโโโโโโโโ โ โ โ โ โผ โผ โผ โผ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โ FastAPI Backend โ โ โโโโโโโโโโโโ โโโโโโโโโโโโ โโโโโโโโโโ โโโโโโโโโโโโ โ โ โ/predict โ โ/explain/ โ โ/explainโ โ/docling/ โ โ โ โ โ โpreview โ โ/legendsโ โanalyze โ โ โ โdecision โ โmomentum โ โ โ โ โ โ โ โโโโโโโฌโโโโโ โโโโโโฌโโโโโโ โโโโโฌโโโโโ โโโโโโฌโโโโโโ โ โโโโโโโโโโผโโโโโโโโโโโโโผโโโโโโโโโโโโผโโโโโโโโโโโโผโโโโโโโโ โ โ โ โ โผ โผ โผ โผ โโโโโโโโโโ โโโโโโโโโโโโโ โโโโโโโโโโ โโโโโโโโโโโโ โ Random โ โ LangChainโ โ IBM โ โ IBM โ โ Forest โ โ Prompt โ โ Graniteโ โ Docling โ โ Model โ โ Templates โ โvia HF โ โ PDFParserโ โโโโโโโโโโ โโโโโโโโโโโโโ โโโโโโโโโโ โโโโโโโโโโโโ ``` --- ## ๐ฏ Judging Criteria Alignment | Criterion | How Match Decoded Addresses It | |---|---| | **Technical Execution** | 5 FastAPI endpoints, Random Forest ML model (55.8% acc), LangChain prompt chains, Docling PDF parsing, Streamlit UI with Plotly charts | | **Innovation** | Explainability-first approach โ not just prediction but WHY. Cross-era Legends Matchup. What-if simulator with AI delta analysis. Docling match report analysis | | **Challenge Fit** | Direct football theme. "Understand the game. Explain the moments." โ every feature is about fan understanding, not pure prediction | | **Feasibility** | Live prototype with 215 teams, 49K matches, 5 working endpoints. Runs on free HuggingFace Spaces. Zero credit card required | | **Use of IBM Tech** | 4 IBM technologies: **Granite** (LLM), **LangChain** (prompts), **Docling** (PDF parsing), **Bob** (development assistance) | | **User Experience** | Polished glassmorphic UI, mobile-friendly, 4 interactive tabs, real-time animations, stadium-themed design | | **Explainability** | Fully traceable predictions. Feature importance displayed. Granite explains every decision in plain language. No black box | --- ## ๐ Quick Start ### Prerequisites - Python 3.11+ - HuggingFace token (for Granite Inference API โ included in code) ### Installation ```bash # Clone git clone https://github.com/agp-369/match-decoded.git cd match-decoded # Install dependencies pip install -r requirements.txt # Start the backend API python -m uvicorn backend.main:app --host 0.0.0.0 --port 8000 # In a new terminal, start the frontend streamlit run frontend/app.py ``` Open your browser to `http://localhost:8501` ### Environment Variables Create a `.env` file in the project root: ```env HF_TOKEN=your_huggingface_token_here # Get yours at https://huggingface.co/settings/tokens API_URL=http://localhost:8000 # Backend URL (auto-detected) ``` --- ## ๐ Project Structure ``` match-decoded/ โโโ backend/ โ โโโ main.py # FastAPI (5 endpoints) โ โโโ model.py # Random Forest wrapper โ โโโ granite.py # IBM Granite + LangChain integration โ โโโ langchain_prompts.py # LangChain prompt templates โ โโโ docling_parser.py # IBM Docling PDF parsing โ โโโ requirements.txt # Backend deps โโโ frontend/ โ โโโ app.py # Streamlit UI (4 tabs) โ โโโ requirements.txt # Frontend deps โโโ models/ โ โโโ match_predictor.pkl # Trained Random Forest โ โโโ team_data.pkl # Team statistics โโโ requirements.txt # Combined deps โโโ .huggingface.yaml # HuggingFace Spaces config โโโ README.md ``` --- ## ๐ฌ Demo Video ### Pitch Script ``` "Every football fan has watched a match and wondered: WHY did they win? Match Decoded answers that question. Powered by IBM Granite, LangChain, Docling, and built with IBM Bob, Match Decoded analyzes 49,000 international matches to explain the invisible forces shaping every game. Select any two teams. Granite delivers a tactical preview explaining why one has the edge. Change the venue โ watch the prediction shift. Compare legends across eras โ Granite settles the debate. Upload a match report โ Docling extracts the tactics, Granite analyzes them. Teams have million-dollar analytics. Fans have guesswork. Match Decoded bridges that gap. Built with IBM Granite. LangChain. Docling. IBM Bob. Match Decoded โ Every fan deserves to know WHY." ``` --- ## ๐จโ๐ป Built With | Technology | Purpose | |---|---| | **IBM Granite 3.1-2B** | AI-powered match explainability | | **LangChain** | Structured prompt engineering (5 templates) | | **IBM Docling** | PDF match report parsing | | **IBM Bob** | AI code assistant | | **Streamlit** | Interactive web frontend | | **FastAPI** | High-performance backend API | | **scikit-learn** | Random Forest prediction model | | **Plotly** | Interactive data visualizations | | **HuggingFace Spaces** | Free deployment (zero credit card) | --- ## ๐ Training Data - **Source**: International football results dataset (1872-2026) - **Total matches**: 49,329 - **Teams**: 215 international sides - **Training set**: 24,179 matches (pre-2018) - **Test set**: 7,652 matches (2018+) - **Model**: Random Forest (200 trees, max depth 12) - **Accuracy**: 55.8% (vs 47.2% baseline) - **Features**: 8 factors โ team_a_winrate, team_b_winrate, team_a_goal_avg, team_b_goal_avg, team_a_recent_form, team_b_recent_form, is_neutral, is_major_tournament --- ## ๐ License Apache 2.0 โ Built for the IBM AI Builders Challenge 2026 ---