File size: 9,012 Bytes
07ddf7f | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 | ---
license: other
language:
- en
task_categories:
- text-generation
- question-answering
tags:
- mlb
- baseball
- sports-analytics
- chatml
- parquet
- instruction-tuning
- matchup-analysis
- structured-output
- statsapi
size_categories:
- 1K<n<10K
pretty_name: MLB 2023 ChatML Matchups
configs:
- config_name: default
data_files:
- split: train
path: data/train-00000-of-00001.parquet
---
# MLB 2023 ChatML Matchups
MLB 2023 ChatML Matchups is a compact, inspection-friendly instruction dataset derived from the public MLB Stats API for the 2023 Major League Baseball regular season. It converts structured game, offense, and pitching data into ChatML-style examples that can be used to study grounded sports reasoning, structured response generation, and retrieval-conditioned assistant behavior.
The dataset is intentionally small enough to audit directly, but structured enough to support serious supervised fine-tuning experiments. Each row asks an assistant to build a pitching and offense matchup brief for one team against its opponent on a specific date. The target answer is a compact JSON object containing the exact facts supplied by the data pipeline.
## Executive Summary
| Property | Value |
|---|---:|
| Season | 2023 MLB regular season |
| Source | Public MLB Stats API |
| Completed unique games | 2,427 |
| Rows | 4,854 |
| Teams | 30 |
| Format | Parquet |
| Split | `train` |
| Primary training column | `messages` |
| Unit of observation | One team perspective for one completed game |
| Target format | JSON inside the assistant message |
Each completed game emits two examples: one from the away team's perspective and one from the home team's perspective. Postponed placeholders are excluded. Suspended or continued games that appear on multiple schedule dates are deduplicated by MLB `gamePk`.
## Motivation
Sports analytics work often lives at the boundary between structured records and natural-language reasoning. A model may need to answer a seemingly simple question such as "How did Atlanta match up with Washington on Opening Day?" while preserving numerical context about offense, pitching, final score, and opponent strength.
This dataset is designed for that boundary. It teaches the model to:
- condition on explicit facts rather than unsupported memory
- preserve team, opponent, score, batting, and pitching context
- reason from a team-specific point of view
- emit structured, machine-checkable assistant outputs
- keep sports analysis grounded in the supplied record
The result is a useful dataset for fine-tuning and evaluation workflows where the goal is not just fluent commentary, but disciplined use of retrieved or supplied sports data.
## What Is In Each Row
Every row includes:
- game identity and date
- team and opponent identity
- home/away side
- final score from the row team's perspective
- game-level batting statistics for both teams
- game-level pitching statistics for both teams
- full-season 2023 hitting statistics for both teams
- full-season 2023 pitching statistics for both teams
- a ChatML `messages` field containing `system`, `user`, and `assistant` turns
The assistant answer is JSON. This makes the target easy to validate, parse, score, and transform into downstream prose if desired.
## Data Sources And Construction
The dataset was built from the public MLB Stats API:
- `https://statsapi.mlb.com/api/v1/schedule`
- `https://statsapi.mlb.com/api/v1/teams/stats`
- `https://statsapi.mlb.com/api/v1/game/{gamePk}/boxscore`
The builder performs a sequential, rate-limited scrape with a local disk cache, retry/backoff behavior, and explicit `429` handling. The completed run used 2,429 network requests, had zero retries, and received zero rate-limit responses.
The season team statistics are full-season 2023 aggregates. They are included as context for model learning and matchup framing, not as a pregame-only feature matrix.
## Row Example
```json
[
{
"role": "system",
"content": "You are an MLB matchup analyst. Use only the supplied 2023 MLB Stats API facts and answer in compact JSON."
},
{
"role": "user",
"content": "Build a pitching and offense matchup brief for Atlanta Braves vs Washington Nationals on 2023-03-30."
},
{
"role": "assistant",
"content": "{\"season\":2023,\"game_pk\":718780,\"team\":{\"name\":\"Atlanta Braves\",...}}"
}
]
```
## Column Schema
| Column | Description |
|---|---|
| `row_id` | Stable identifier: `mlb-2023-{game_pk}-{side}` |
| `season` | Season year, always `2023` |
| `game_pk` | MLB game identifier |
| `game_date` | UTC date as `YYYY-MM-DD` |
| `game_datetime_utc` | Full UTC game datetime from MLB schedule data |
| `team_id`, `team_name`, `team_side` | Team identity and row perspective |
| `opponent_id`, `opponent_name`, `opponent_side` | Opponent identity and side |
| `team_runs`, `opponent_runs` | Final score from the row team's perspective |
| `result` | `win`, `loss`, or `tie` |
| `messages` | ChatML-style `system`, `user`, `assistant` messages |
| `assistant_payload_json` | Full assistant target payload as JSON text |
| `team_game_batting_json` | Team game batting line |
| `team_game_pitching_json` | Team game pitching line |
| `opponent_game_batting_json` | Opponent game batting line |
| `opponent_game_pitching_json` | Opponent game pitching line |
| `team_season_hitting_json` | Team full-season hitting context |
| `team_season_pitching_json` | Team full-season pitching context |
| `opponent_season_hitting_json` | Opponent full-season hitting context |
| `opponent_season_pitching_json` | Opponent full-season pitching context |
## Loading The Dataset
### Hugging Face Datasets
```python
from datasets import load_dataset
ds = load_dataset("clarkkitchen22/MLB-2023-ChatML-Matchups", split="train")
row = ds[0]
messages = row["messages"]
assistant_payload = row["assistant_payload_json"]
```
### Pandas
```python
import pandas as pd
df = pd.read_parquet(
"hf://datasets/clarkkitchen22/MLB-2023-ChatML-Matchups/data/train-00000-of-00001.parquet"
)
print(df[["team_name", "opponent_name", "team_runs", "opponent_runs", "result"]].head())
```
## How To Use This Dataset
For supervised fine-tuning, use the `messages` column directly if your trainer accepts ChatML-style conversations. If your model requires a single text field, render each message list through the tokenizer's chat template before training.
Recommended experiments:
- Train a small instruct model to preserve structured baseball facts in JSON.
- Evaluate structured-output faithfulness by parsing `assistant_payload_json`.
- Test retrieval-augmented pipelines where the retrieved Parquet row becomes the grounding context.
- Compare prose-generation prompts against JSON-first prompts for sports analytics reliability.
- Build a lightweight matchup assistant that can cite team offense and pitching context.
The cleanest research use is to treat this as a controlled structured-output dataset: the model is asked for analysis, but the target is deliberately fact-shaped and parseable.
## Why This Dataset Matters
Many sports datasets are either raw tables or free-form text. Raw tables are easy to compute over but awkward for chat-model training. Free-form text is easy to train on but hard to audit for factual grounding. This dataset sits between those extremes: every example is conversational at the surface and structured at the target.
That design makes it useful for a practical machine-learning question: can a model learn to be conversational while staying bound to supplied statistical evidence?
## Verification
The dataset was verified with `scripts/verify_dataset.py`.
Verification summary:
- `rows`: 4,854
- `games`: 2,427
- `teams`: 30
- `rows_match_schedule_x2`: true
- `unique_row_ids`: true
- `all_games_present`: true
- `all_30_teams_present`: true
- `season_matches`: true
- `chatml_roles_valid`: true
- `pitching_fields_present`: true
## Limitations
- This dataset reflects MLB Stats API responses available at build time.
- Season team statistics are full-season 2023 totals, not strictly pregame rolling features.
- The assistant targets are structured JSON, not finished editorial scouting prose.
- It does not include player-level pitch-by-pitch events, betting odds, injuries, weather, umpires, lineups, or park-factor adjustments.
- It is not suitable by itself for causal claims about team quality or predictive wagering.
- Commercial use and redistribution should be evaluated against applicable MLB data terms and policies.
## Responsible Use
Use this dataset for sports analytics research, instruction tuning, retrieval prototypes, and structured-output evaluation. Do not present model outputs as official MLB commentary, real-time predictions, injury guidance, or betting advice.
## Attribution
Data was collected from the public MLB Stats API. This dataset is not affiliated with, endorsed by, or sponsored by Major League Baseball, MLB Advanced Media, or any MLB club.
|