--- license: cc-by-4.0 language: - en pretty_name: "GPIO-LLM: Raspberry Pi 5 GPIO request-to-action dataset" size_categories: - 1M **Safety.** Model output must never drive hardware directly. Every action is meant to pass a deterministic > validator and hardware controller first (the project ships a validator and a GPIO simulator). The labels > encode the project's safety policy; they are not a substitute for correct wiring. ## What's new in v2.0 (`gpio_actions_v2`, default) - **Train grows from 58,821 to 1,678,821 rows.** The 58,821 original rows are unchanged; 1,620,000 new rows have `source == "deterministic_gen_v1"`. - **Eval is unchanged.** `eval` and `eval_core` are the same files, byte for byte, so v1 and v2 scores can be compared directly. - **Same schema, same specification.** The action vocabulary is still 1.0 (Raspberry Pi 5 / RP1), and the fields and types match v1. - **No language model wrote any of the new rows.** A seeded, rule-based generator produced both labels and wording (details below). - **New knowledge base** in `knowledge/`. It holds real board pinouts, sensor modules and hobby projects, with sources, and was used to make the wording more realistic. - **The original release stays available.** It is the `gpio_actions` config and the git tag `v1.0`: ```python from datasets import load_dataset ds = load_dataset("AwaleSagar/gpio-llm-rpi5-actions") # v2: 1.68M train rows v1 = load_dataset("AwaleSagar/gpio-llm-rpi5-actions", "gpio_actions") # v1: 58,821 train rows v1 = load_dataset("AwaleSagar/gpio-llm-rpi5-actions", revision="v1.0") # exact v1 snapshot original_only = ds["train"].filter(lambda r: r["source"] != "deterministic_gen_v1") ``` ## Quick start ```python from datasets import load_dataset ds = load_dataset("AwaleSagar/gpio-llm-rpi5-actions") # splits: train, eval, eval_core row = ds["train"][0] print(row["prompt"] + row["target"]) ``` Fine-tune on `target` with the loss masked over `prompt`. The target starts with a space (`"Assistant:"` | `" {...}"`), so tokenizing the two parts separately gives exactly the tokens of the joined text. ## Splits | Split | v2 rows | v1 rows | Purpose | |---|---|---|---| | `train` | 1,678,821 | 58,821 | Training (v2 = 58,821 original + 1,620,000 synthetic) | | `eval` | 26,297 | 26,297 | Held-out evaluation: 132 phrasing templates never used in training | | `eval_core` | 5,083 | 5,083 | Quick evaluation: 46 rows from every eval template | - Train and eval share no ids, no phrasing templates and no number-normalised text. - `eval_core` is a subset of `eval`. - For the synthetic rows, three eval-leakage tests were applied to every candidate (see *How v2 was made*). The highest word-3-shingle Jaccard between an accepted row and eval is 0.692, under the 0.7 limit. ## Fields | Field | Type | Description | |---|---|---| | `id` | string | Unique row id | | `prompt` | string | Model input: optional `Context: {json}` line, the conversation as `User:` / `Assistant:` lines, ending with `Assistant:` | | `target` | string | Model output: a space and the action as compact JSON | | `tokens` | int | Tokens of `prompt + target` with the project tokenizer (`gpio_llm_bpe_12k`); at most 256 in synthetic rows | | `action` | string | Action name (`ask_clarification`, `gpio_mode`, `gpio_pulse`, `gpio_pwm`, `gpio_read`, `gpio_sequence`, `gpio_write`, `report_error`, `wait`) | | `category` | string | One of `clarification`, `driver`, `error`, `general_hardware`, `gpio_mode`, `gpio_pwm`, `gpio_read`, `gpio_sequence`, `gpio_timing`, `gpio_write`, `safety`, `sensor` | | `template_id` | string | Phrasing template the row came from, the unit of the train/eval split. Synthetic rows use `dg..` | | `source` | string | `golden_manual`, `synthetic_template_v1/v2` or `teacher_` (v1 rows), or `deterministic_gen_v1` (v2 synthetic rows) | | `difficulty` | int | 1 (direct) to 5 (multi-step or tricky) | | `fact_refs` | list | Hardware facts (`F-*`) and dataset policies (`P-*`) the label depends on (`configs/rpi5_hardware_facts.json`) | | `messages` | list | The conversation as role/content turns | | `context` | string (JSON) | Optional runtime context: `device_mappings`, `available_pins` or `gpio_state` | | `expected_action` | string (JSON) | The label as a JSON object (same as `target`) | Actions, fields, enums and reason codes are defined in `configs/action_vocabulary.json`. ## Examples ```text prompt: Context: {"device_mappings":{"door_lock_relay":20}} User: Turn on the door lock relay. Assistant: target: {"action":"gpio_write","pin":20,"value":"HIGH"} prompt: User: Pi, pulse GPIO 13 for 3500 milliseconds. (deterministic_gen_v1) Assistant: target: {"action":"gpio_pulse","pin":13,"value":"HIGH","duration_ms":3500} prompt: User: could you turn physical pin 17 on real quick? thanks (deterministic_gen_v1) Assistant: target: {"action":"report_error","pin":null,"parameters":{"reason":"not_a_gpio","header_pin":17}} ``` ## Composition (v2 train) | Category | Original (v1) | Synthetic (v2) | Total | |---|---|---|---| | clarification | 3,608 | 237,680 | 241,288 | | driver | 1,896 | 141,960 | 143,856 | | error | 10,853 | 299,150 | 310,003 | | general_hardware | 162 | 14,838 | 15,000 | | gpio_mode | 4,513 | 58,038 | 62,551 | | gpio_pwm | 5,964 | 122,877 | 128,841 | | gpio_read | 4,079 | 50,868 | 54,947 | | gpio_sequence | 6,401 | 207,233 | 213,634 | | gpio_timing | 6,067 | 153,668 | 159,735 | | gpio_write | 7,960 | 122,908 | 130,868 | | safety | 4,187 | 123,284 | 127,471 | | sensor | 3,131 | 87,496 | 90,627 | | Action | v2 train rows | |---|---| | `report_error` | 452,474 | | `gpio_sequence` | 254,550 | | `ask_clarification` | 241,288 | | `gpio_pwm` | 192,944 | | `gpio_write` | 169,705 | | `gpio_read` | 145,574 | | `gpio_pulse` | 120,829 | | `gpio_mode` | 62,551 | | `wait` | 38,906 | The synthetic rows use 137 template ids. `provenance/v2_composition.json` also breaks the data down by difficulty. ## How v1 was made (original 58,821 rows) 1. **Hardware facts.** Every capability comes from cited sources: the Raspberry Pi documentation, the RP1 peripherals datasheet (Table 4, checked cell by cell) and the Raspberry Pi 5 product brief. Uncertain facts are left out of labels. 2. **Labels.** 98 hand-written golden rows and fact-grounded templates produce every target deterministically. No label was written by a language model. 3. **Wording.** Teacher models only rewrote the user's words for existing targets: - `deepseek/deepseek-v4.1-flash`: 197 rows - `gpt-5.6-terra`: 10,997 rows - `z-ai/glm-5.3-flash`: 72,306 rows Each rewrite passed deterministic wording checks, the strict validator, duplicate and leakage checks, and a judge model. 4. **Checks.** These were applied to every row: - strict schema and hardware-rule validation - pin grounding - exact and near-duplicate removal - contradiction checks - template-level train/eval separation - replay through the GPIO simulator ## How v2 was made (1,620,000 synthetic rows) **No generative model was sampled.** Generation was label first, words second. 1. **Label first.** A seeded generator (NumPy PCG64) samples a valid action under specification 1.0. - It uses the same frozen hardware facts: RP1 alternate-function table, hardware PWM only on GPIO 12/13/18/19, GPIO0/1 reserved, fixed pull-ups on 2/3, drive strengths 2/4/8/12 mA. - It follows the same policies, for example no PWM on GPIO14/15, a question instead of a guess, and active-low handling. 2. **Words second.** The generator builds the request from: - hand-written phrase frames and a lexicon - register transforms (casual, terse, polite, voice-assistant, typos) - device names, context variants and multi-turn follow-ups - real wiring scenes from the knowledge base 3. **How the code was written.** The generator code, frames and lexicon were written with an AI coding assistant (Claude) and reviewed rule by rule. At generation time no text is sampled from any language model. Every row can be reproduced from the seed and the code. 4. **Validation gate.** All 100% of accepted rows pass these checks: - the strict validator - replay in the GPIO simulator - pin grounding - canonical JSON key order - prompt/target/token consistency, with at most 256 tokens - grammar and wording checks 5. **Measurement only.** [EmbeddingGemma-300M](https://huggingface.co/google/embeddinggemma-300m) embeddings (256-dimensional Matryoshka) were used for gap analysis, near-duplicate removal, leakage checks and diversity-aware selection. The model never produced text. 6. **Eval leakage.** A candidate is rejected if any of these is true: - its number-normalised skeleton appears in eval - its 3-shingle Jaccard with an eval row is at least 0.7 - its cosine to an eval row reaches the 99th percentile of original train→eval similarity 7. **Dedup and selection.** - Exact duplicates of original, eval or earlier rows are removed. - A pair counts as a near-duplicate only if both rows have the same label skeleton and cosine ≥ 0.97. - Greedy selection favours novel rows, with a per-template cap of 25% and family quotas from gap analysis. 8. **Stages.** The data was built in stages, each measured before scaling up: 10K pilot → 100K → knowledge-base run → 500K → 1M. All five were then merged. | Check (final 1M stage) | Result | |---|---| | Validator + simulator | 100% of 2.6M candidates checked; only passing rows kept | | Eval leakage in accepted rows | 0 (10,514 candidates rejected) | | Unique prompts | 100% | | Mean nearest-neighbour cosine to original train | 0.878 (72.9% of rows in a novel region) | | Labels in a manual review sample | 32/32 correct | Stage reports, dedup/leakage reports and review samples are in `generator_reports/`. The release manifest with file hashes is `provenance/v2_release_manifest.json`. ## Knowledge base (`knowledge/`) Real reference data used to make scenes and wording more realistic. No language model wrote any of it. | File | Contents | |---|---| | `boards.json` | 32 Raspberry Pi boards, 16 of them Linux Pis with a 40-pin header. For each GPIO family (BCM2835/6/7 + RP3A0, BCM2711, RP1): alternate functions for GPIO0–27, default pulls, drive strengths, input thresholds and PWM channels. The `pinctrl` tables were checked cell by cell against datasheets. | | `sensors_src.yaml` | 19 common modules (PIR, HC-SR04, relays, DHT22, DS18B20, SG90, L298N, WS2812, …) with signal levels, v1 action mapping, caveats and source URLs | | `projects.json` | 122 real project scenes (device → BCM pin, operations, conflicts) from GPIO Zero recipes and Raspberry Pi Foundation projects; 88 fit specification 1.0 | | `sources.json` | Source repositories with commits and licences, plus datasheet and module URLs | | `README.md` | Method, verification and known conflicts | Only Raspberry Pi 5 / RP1 facts drive the labels. The other boards are recorded for a future board-aware specification. ## Intended use and limitations - **Intended use.** Training and evaluating small models that map requests to structured hardware actions, and research on clarification and refusal behaviour. - **All requests are synthetic.** They come from templates, model rewrites (v1) or the rule-based generator (v2). Real spoken phrasing is under-represented. - **Less wording diversity in v2.** Rule-based wording is less varied than the v1 teacher rewrites: distinct-2 is 0.093 vs 0.128 on equal 10K samples. Rows are valid and unique, but many share frames. - **Intent mix is skewed at the 1M stage.** 27 generator families ran out of fresh wording, so about 205K rows of their quota went to families with spare candidates: - The receiving families include `pwm_device`, `project_scene_seq`, `pulse`, `seq_multi`, `pwm_basic` and `multi_turn`. - Intent-cell Gini is 0.414 (0.355 after the 500K stage). - If you need a balanced mix, reweight or subsample by `template_id` or `category`, or use the v1 config. - **Scope.** Action vocabulary 1.0 on the 40-pin header of a Raspberry Pi 5: - In scope: digital I/O, pulls, drive strength, documented alternate functions, hardware/software PWM, pulses, waits and sequences. - Out of scope: bus transactions (I2C/SPI/UART payloads), sensor protocols, edge-triggered waits and timing precision limits. - **Conservative policies are built into the labels.** Examples: GPIO0/1 are refused, "pin N" means BCM GPIO N, "turn on" means HIGH, hedged pin choices trigger a clarifying question, and PWM on GPIO14/15 is never taught. Each policy is recorded in `docs/SPEC_V1_DECISIONS.md` (specification 1.0). - **Not independently verified.** v2 has not yet been checked with a training A/B run on `eval_core`, and has had no independent human review beyond the review samples. ## Models trained on this dataset Three from-scratch Llama-style models were pretrained on 550M fineweb-edu tokens and then fine-tuned on all of `gpio_actions_v2` train for 2 epochs. Numbers are greedy exact match on `eval`, before any validator: | Model | Parameters | `eval` exact match | Pi Zero 2 W p50 (C engine, `eval_core`) | |---|---|---|---| | [gpio-llm-pico-rpi5](https://huggingface.co/AwaleSagar/gpio-llm-pico-rpi5) | 2.7M | 91.88% | 86 ms | | [gpio-llm-nano-rpi5](https://huggingface.co/AwaleSagar/gpio-llm-nano-rpi5) | 5.0M | 93.61% | 132 ms | | [gpio-llm-base-rpi5](https://huggingface.co/AwaleSagar/gpio-llm-base-rpi5) | 18.8M | 95.17% | 498 ms | The training code and the offline C inference engine are at [github.com/AwaleSagar/gpio-llm](https://github.com/AwaleSagar/gpio-llm). All of it is grouped in the [GPIO-LLM collection](https://huggingface.co/collections/AwaleSagar/gpio-llm-6aaea402d46359e24f36501b). ## Licence and attribution - **Dataset.** Released under **CC-BY-4.0**. - **v1 teacher rows.** User wording in `teacher_*` rows was generated with third-party models; check those providers' terms on using model outputs. - **Hardware facts** summarise public Raspberry Pi documentation and datasheets. - **Knowledge base.** The files in `knowledge/` keep the licences of their sources: - **Raspberry Pi documentation** ([raspberrypi/documentation](https://github.com/raspberrypi/documentation)), © Raspberry Pi Ltd, **CC BY-SA 4.0**. Used for board and GPIO facts. - **Raspberry Pi Foundation learning projects** ([raspberrypilearning](https://github.com/raspberrypilearning)), **CC BY-SA 4.0**. Used for the project scenes in `projects.json`; the repos are listed in `sources.json`. Derived project data is shared under CC BY-SA 4.0. - **GPIO Zero** ([gpiozero/gpiozero](https://github.com/gpiozero/gpiozero)), © Ben Nuttall, Dave Jones and contributors, **BSD-3-Clause**. Used for recipes and docstring quotes. - **`pinctrl`** ([raspberrypi/utils](https://github.com/raspberrypi/utils)), © Raspberry Pi Ltd, **BSD-3-Clause**. Used for alternate-function tables. - **Datasheets, vendor pages and tutorials** in `sensors_src.yaml` are cited by URL only. Verbatim quotes from third-party sites were removed from this public copy. - **Pretraining text is not included.** The companion English pretraining text is a filtered subset of [HuggingFaceTB/smollm-corpus](https://huggingface.co/datasets/HuggingFaceTB/smollm-corpus) (`fineweb-edu-dedup`, ODC-By 1.0, derived from Common Crawl). `provenance/` lists the exact selection so it can be rebuilt. The project's pretraining mix used 550M tokens. ## Provenance | Version | Git tag | Record | |---|---|---| | v1 (`gpio_llm_v1`) | `v1.0` | `provenance/release_manifest.json` | | v2 (`gpio_llm_v1_synth1620k`) | `v2.0` | `provenance/v2_release_manifest.json`: file SHA-256, spec lock, generator runs and seeds | ## Citation ```bibtex @misc{gpio_llm_dataset, title = {GPIO-LLM: Raspberry Pi 5 GPIO request-to-action dataset}, author = {GPIO-LLM project}, year = {2026}, note = {Release gpio_llm_v1, v2.0 (1.68M-row synthetic expansion)} } ```