File size: 3,794 Bytes
c681622
a2f0291
 
 
 
 
 
 
 
 
 
 
 
 
 
 
c681622
a2f0291
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
---
license: mit
task_categories:
  - text-generation
language:
  - en
tags:
  - freertos
  - esp32
  - esp-idf
  - qwen
  - unsloth
  - code
pretty_name: FreeRTOS ESP32
size_categories:
  - 1K<n<10K
---

# FreeRTOS ESP32

Instructional **ChatML** dataset for fine-tuning language models (e.g. **Qwen** via **Unsloth**) as an expert **ESP32 / ESP-IDF / FreeRTOS** assistant.

Content is original instructional material oriented around ESP-IDF v5.x FreeRTOS APIs and idioms — not a verbatim dump of vendor documentation.

## Dataset summary

| Item | Value |
|------|--------|
| Format | Hub `Dataset` / JSONL with ChatML `messages` (`system` / `user` / `assistant`) |
| Total examples | **1160** |
| Train | **1101** |
| Validation | **59** (~5%, stratified by category) |
| License | MIT |
| Language | English |
| Focus | FreeRTOS on ESP32 (ESP-IDF), embedded C, real-time patterns |

Each row has a `messages` list (ChatML) and a `meta` object (id, category, tags, difficulty, style, APIs, etc.).

### Schema

```json
{
  "messages": [
    {"role": "system", "content": "..."},
    {"role": "user", "content": "..."},
    {"role": "assistant", "content": "..."}
  ],
  "meta": {
    "id": "tasks_basic_0042",
    "category": "tasks_basic",
    "tags": ["xTaskCreate", "stack"],
    "difficulty": "intermediate",
    "style": "code_lab",
    "apis": ["xTaskCreate", "vTaskDelay"],
    "esp_idf_version_note": "v5.x conceptual",
    "source": "generated",
    "multi_turn": false
  }
}
```

- Every row has `system` plus at least one `user` / `assistant` pair.
- ~12% multi-turn (debug-style follow-ups).
- Categories cover tasks, SMP/pin-to-core, queues, semaphores/mutexes, event groups, FreeRTOS & ESP timers, stream/message buffers, notifications, ISR/critical sections, heap/`heap_caps`, ring buffers, hooks/TLS/WDT, design patterns, debug/troubleshoot, and compare/choose.

## Load

```python
from datasets import load_dataset

ds = load_dataset("rafuke/freertos_esp32")
print(ds)
print(len(ds["train"]), len(ds["validation"]))
print(ds["train"][0]["messages"][0]["role"])
```

### Fine-tuning sketch (Unsloth + Qwen)

Map `messages` through the tokenizer chat template:

```python
from datasets import load_dataset

dataset = load_dataset("rafuke/freertos_esp32")

def to_text(batch, tokenizer):
    texts = [
        tokenizer.apply_chat_template(
            msgs,
            tokenize=False,
            add_generation_prompt=False,
        )
        for msgs in batch["messages"]
    ]
    return {"text": texts}

# train_ds = dataset["train"].map(lambda b: to_text(b, tokenizer), batched=True, ...)
```

## Intended use

- Supervised fine-tuning (SFT) of instruct models for ESP32 / FreeRTOS Q&A and code assistance.
- Evaluation of embedded RTOS knowledge in chat format.

## Out of scope / known limitations

- **Not a substitute for official docs.** Prefer Espressif ESP-IDF and FreeRTOS reference manuals for authoritative API contracts, errata, and chip-specific behavior.
- Answers target **ESP-IDF v5.x** conceptual usage; APIs and defaults can differ across IDF versions and SoCs (ESP32, S2, S3, C3, C6, H2, etc.).
- Vanilla FreeRTOS vs ESP-IDF FreeRTOS differences (SMP, pin-to-core, TWDT, `heap_caps`, ring buffers) are called out in spirit, but edge cases may be incomplete.
- Generated instructional content may contain occasional inaccuracies; validate critical code on hardware.
- Not a full project corpus (no complete `sdkconfig` / multi-file apps per row).
- English only.

## License

MIT — see `LICENSE` in this repository.

## Citation

If you use this dataset, please cite the Hub repo:

```
@misc{freertos_esp32,
  title  = {FreeRTOS ESP32},
  author = {rafuke},
  year   = {2026},
  url    = {https://huggingface.co/datasets/rafuke/freertos_esp32}
}
```