File size: 6,385 Bytes
edceceb
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4205457
 
 
 
edceceb
 
4205457
edceceb
 
4205457
 
 
 
 
 
 
 
edceceb
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4205457
 
 
edceceb
 
4205457
 
 
edceceb
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4205457
 
 
 
edceceb
 
4205457
 
 
 
edceceb
 
 
 
 
 
 
 
 
 
4205457
 
edceceb
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
---
license: mit
task_categories:
- text-generation
language:
- en
tags:
- bash
- shell
- code
- instruction-tuning
- sft
- command-line
size_categories:
- 10K<n<100K
pretty_name: Bash Instruction-Tuning Dataset
configs:
- config_name: default
  data_files: bash_dataset.jsonl
---

# Bash Instruction-Tuning Dataset (~55k)

A synthetic instruction-tuning dataset that pairs natural-language requests with
correct Bash solutions, built for fine-tuning small LLMs to translate plain
requests into runnable shell commands, pipelines, and scripts.

Each example is a chat conversation (system / user / assistant) plus two metadata
fields (`category`, `utility`) for slicing and analysis.

## Format

One JSON object per line (`bash_dataset.jsonl`):

```json
{
  "messages": [
    {"role": "system",    "content": "You are a Bash expert."},
    {"role": "user",      "content": "Show the last 20 lines of error.log."},
    {"role": "assistant", "content": "tail -n 20 error.log"}
  ],
  "category": "single",
  "utility": "tail"
}
```

- `messages` — the training conversation. The system prompt is one of 5 equivalent
  Bash-assistant prompts (rotated so the model doesn't overfit a single string).
- `category``single` | `pipeline` | `script` (see below).
- `utility` — the primary command of the solution (e.g. `grep`, `awk`, `find`,
  `for`), used to enforce a per-command cap and to analyze coverage.

Scripts (`category == "script"`) contain real multi-line Bash (JSON-escaped `\n`),
typically with `set -euo pipefail`, functions, `getopts`, `trap` cleanup, loops,
here-docs, etc.

## Statistics

| Metric | Value |
|---|---|
| Examples | 55,000 |
| `single` (one-shot commands) | 22,000 (40%) |
| `pipeline` (pipes, `&&`/`\|\|`, `$(...)`, `xargs`) | 19,250 (35%) |
| `script` (multi-line) | 13,750 (25%) |
| Distinct primary utilities | 89 |
| Max share of any one utility | 4.00% (hard cap 2,200/util) |
| Unique user (NL) strings | 98.7% |
| Unique assistant (Bash) strings | 75.6% |
| Argument fidelity | 100% (0 request/command noun mismatches) |
| Largest shared 4-word NL opening | 1.4% |

**Validity**: 100% pass `bash -n` (0 syntax errors). Static analysis with
shellcheck flags no warning-level findings on **96%** of a 4,000-example sample;
almost all remaining findings are a single style nit (`SC2010`, `ls | grep`).

**Argument fidelity**: every example is checked so the command actually
references the concrete nouns named in the request — the same filename,
extension, user, group, service, process, and port. This is enforced at
generation time by a hard gate (`argcheck.py`); the shipped file has **0**
mismatches. (An earlier version of this generator had ~12% argument mismatches
that `bash -n`/shellcheck could not detect, because a wrong filename still
parses and lints; the gate exists specifically to prevent that.)

**Coverage of system/info utilities** that small models often get wrong
(counts include single + pipeline + script uses):

| util | n | util | n | util | n |
|---|---|---|---|---|---|
| journalctl | 2200 | lsof | 648 | ss | 481 |
| pstree | 753 | renice | 365 | nice | 293 |
| vmstat | 288 | netstat | 234 | iostat | 183 |
| w | 158 | dmesg | 154 | free | 90 |
| uptime | 34 | hostname | 25 | | |

(`uptime` / `hostname` are lower because their genuine idiomatic command space is
small; they are covered with real flag variants rather than padded phrasings.)

## How it was built

Generated by a recipe engine (`generate.py`, included). Each recipe family emits
`(request, command)` pairs by combining hand-written phrasing templates
(imperative / question / casual) with realistic parameter pools (plausible file
names, directories, ports, services, users, patterns). The generator enforces:

- category quotas (40 / 35 / 25),
- a 4% per-utility cap so no command dominates (a real failure mode of earlier runs),
- minimum floors for the info/system utilities above,
- SHA-1 deduplication of `(request, command)` pairs,
- an **argument-fidelity gate** (`argcheck.py`) — the command must reference the
  same concrete nouns the request names, or the pair is rejected,
- phrasing diversification so no single opening template dominates,
- a `bash -n` syntax gate on every command before it is written.

Every parameter (filename, dir, extension, user, ...) is drawn once per example
and reused in both the request and the command, so they never disagree.

## Loading

```python
from datasets import load_dataset
ds = load_dataset("json", data_files="bash_dataset.jsonl", split="train")
print(ds[0]["messages"])

# analyze by slice
import collections
print(collections.Counter(ds["category"]))
print(collections.Counter(ds["utility"]).most_common(15))
```

The dataset viewer will expose `messages`, `category`, and `utility` as columns.

## Intended use & limitations

**Good for**: teaching a small model to map natural-language requests to correct
single Bash commands, short pipelines, and small scripts — including the
system/info utilities listed above.

**Limitations (be aware before relying on it):**

- **Synthetic.** Variety comes from recombining templates and token pools, not
  from human authorship. Phrasing is diversified (no opening template exceeds
  ~1.5% of rows, NL strings are 98.7% unique), but the underlying request shapes
  are still generated from a finite set of families; ~24% of commands recur with
  different phrasings.
- **Validity ≠ full semantic correctness.** `bash -n` + shellcheck prove the
  commands parse and lint clean, and the argument-fidelity gate guarantees the
  command uses the nouns from the request; none of these prove the command's
  *logic* perfectly satisfies the intent. Some pairs are plausible-but-approximate
  (e.g. an `awk` column index assumes a particular log layout).
- **Single-turn, one canonical answer.** No explanations, alternatives, negative
  examples, or multi-turn dialogue.
- **Not executed at scale on real Linux.** Many commands (`systemctl`,
  `journalctl`, `apt`, `vmstat`, …) are idiomatic but were validated statically,
  not run.

## Files

- `bash_dataset.jsonl` — the dataset (55,000 rows).
- `generate.py` — the generator (reproducible; resumable via `progress.json`).
- `argcheck.py` — the argument-fidelity checker used as the generation gate;
  also runnable as a standalone auditor over the dataset.
- `README.md` — this card.