clarkkitchen22's picture
Add MLB 2024 ChatML matchup dataset
8c5b9c6 verified
metadata
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 2024 ChatML Matchups
configs:
  - config_name: default
    data_files:
      - split: train
        path: data/train-00000-of-00001.parquet

MLB 2024 ChatML Matchups

MLB 2024 ChatML Matchups is a compact, inspection-friendly instruction dataset derived from the public MLB Stats API for the 2024 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 2024 MLB regular season
Source Public MLB Stats API
Completed unique games 2,425
Rows 4,850
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 the Dodgers match up with the Padres?" 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 2024 hitting statistics for both teams
  • full-season 2024 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,427 network requests, had zero retries, and received zero rate-limit responses.

The season team statistics are full-season 2024 aggregates. They are included as context for model learning and matchup framing, not as a pregame-only feature matrix.

Row Example

[
  {
    "role": "system",
    "content": "You are an MLB matchup analyst. Use only the supplied 2024 MLB Stats API facts and answer in compact JSON."
  },
  {
    "role": "user",
    "content": "Build a pitching and offense matchup brief for Los Angeles Dodgers vs San Diego Padres on 2024-03-20."
  },
  {
    "role": "assistant",
    "content": "{\"season\":2024,\"game_pk\":745444,\"team\":{\"name\":\"Los Angeles Dodgers\",...}}"
  }
]

Column Schema

Column Description
row_id Stable identifier: mlb-2024-{game_pk}-{side}
season Season year, always 2024
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

from datasets import load_dataset

ds = load_dataset("clarkkitchen22/MLB-2024-ChatML-Matchups", split="train")
row = ds[0]

messages = row["messages"]
assistant_payload = row["assistant_payload_json"]

Pandas

import pandas as pd

df = pd.read_parquet(
    "hf://datasets/clarkkitchen22/MLB-2024-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,850
  • games: 2,425
  • 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 2024 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.