File size: 5,458 Bytes
7de4d63
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
# Grok Synthetic Generation Prompt For 400GB Dataset Target

Give this document to each interactive Grok session when more synthetic data is
needed. Grok should generate only staging JSONL. Final dedup, balancing,
checkpointing, Hugging Face upload, and Google Drive backup are handled outside
Grok.

## Mission

Generate high-quality, non-duplicated synthetic code training records for the
FABLE 5 code completion and FIM dataset. Output JSONL only. The target system
will combine this synthetic stream with public real-code sources into twenty
balanced 20GB single-JSONL checkpoints, for 400GB total mirrored to Hugging Face
and Google Drive.

## Absolute Safety Rules

- Do not load the whole corpus into memory.
- Do not scan all existing dataset files.
- Do not build an in-memory global set of hashes.
- Write small JSONL files incrementally.
- Keep one process below 1.2GiB RSS; stop immediately above 1.5GiB RSS.
- Stop if disk free space drops below 95GiB.
- Never write into `dataset/`; only write staging output.
- Never delete source datasets.
- Never create binary, parquet, sqlite, zip, tar, or cache files unless
  explicitly requested.

## Output Directory

Write generated files under:

```text
data/grok_outbox/<run_id>.inprogress/
```

When a run is complete and all files are flushed, rename the folder to:

```text
data/grok_outbox/<run_id>.final/
```

Use file names:

```text
w<worker>-part-<number>.jsonl
```

Each file should be about 512MiB to 1GiB. Smaller files are acceptable. Do not
create one huge file.

## JSONL Schema

Each line must be one UTF-8 JSON object:

```json
{"text":"...","domain":"code_fim","difficulty":"medium","meta":{"lang":"python","source":"grok","mode":"psm","synthetic_kind":"api_usage"}}
```

Required fields:

- `text`: non-empty training string.
- `domain`: `code_fim` or `code_gen`.
- `difficulty`: `easy`, `medium`, or `hard`.
- `meta.lang`: one of the target languages.
- `meta.source`: always `grok`.
- `meta.synthetic_kind`: one of the categories below.

FIM records must use one of:

```text
<|fim_prefix|>{prefix}<|fim_suffix|>{suffix}<|fim_middle|>{middle}
<|fim_suffix|>{suffix}<|fim_prefix|>{prefix}<|fim_middle|>{middle}
```

Do not include markdown fences inside `text` unless the training record is
intentionally a markdown/documentation example.

## Target Mix For Synthetic Output

Across each Grok run, approximate this mix:

| Category | Share |
| --- | ---: |
| Realistic repository FIM | 35% |
| API/library usage FIM | 20% |
| Bug fix / refactor FIM | 15% |
| Tests and edge cases | 10% |
| Algorithmic code generation | 8% |
| Systems/concurrency/performance | 7% |
| Documentation/comment aware completion | 5% |

Language mix:

| Language | Share |
| --- | ---: |
| Python | 24% |
| TypeScript/JavaScript | 22% |
| Java | 14% |
| Rust | 12% |
| C/C++ | 12% |
| Go | 8% |
| Kotlin/Swift/C# mixed | 8% |

Difficulty mix:

| Difficulty | Share |
| --- | ---: |
| easy | 20% |
| medium | 50% |
| hard | 30% |

FIM mode mix:

| Mode | Share |
| --- | ---: |
| psm | 70% |
| spm | 20% |
| gen | 10% |

## Quality Bar

Generate useful code that looks like it came from real projects:

- Complete functions, classes, modules, tests, configs, and migrations.
- Realistic imports and dependency boundaries.
- Meaningful variable names and project structure.
- Edge cases, error handling, logging, type hints, and validation.
- Korean and English comments are allowed, but code should remain idiomatic.
- Include tests for tricky logic where appropriate.
- Prefer medium-length examples. Avoid tiny toy snippets as bulk data.

Reject or avoid:

- Near-duplicate templates with only renamed variables.
- Repeated boilerplate.
- Fake secrets, API keys, private keys, passwords, tokens, or credentials.
- Copyrighted source copied from real projects.
- Broken syntax unless the record is explicitly a bug-fix example and the
  completion repairs it.
- Long natural-language explanations replacing code.

## Dedup Discipline Inside Grok

Within a single Grok run, keep a small bounded rolling hash set only for recent
outputs to avoid immediate repeats. Do not attempt global dedup across all
datasets. The external pipeline handles global out-of-core dedup.

For each generated record, vary at least three of:

- language
- library/API family
- problem shape
- repository path
- data structure
- error handling
- tests
- FIM split location
- naming style

## Record Examples

Good `meta.synthetic_kind` values:

- `repository_fim`
- `api_usage`
- `bugfix_refactor`
- `unit_tests`
- `algorithmic`
- `systems_concurrency`
- `performance`
- `docs_comments`
- `config_infra`
- `data_processing`

Example shape:

```json
{"text":"<|fim_prefix|>def normalize_path(raw: str) -> str:\n    cleaned = raw.strip()\n<|fim_suffix|>\n    return cleaned\n<|fim_middle|>    if not cleaned:\n        raise ValueError(\"path is empty\")\n","domain":"code_fim","difficulty":"easy","meta":{"lang":"python","source":"grok","mode":"psm","synthetic_kind":"bugfix_refactor","path":"src/pathing/normalize.py"}}
```

## Run Completion Report

At the end of a run, write:

```text
data/grok_outbox/<run_id>.final/RUN_REPORT.md
```

Include:

- total files
- total bytes
- approximate records
- category counts
- language counts
- difficulty counts
- max observed RSS
- disk free at start and end
- any files intentionally skipped or stopped early

The report is metadata only. Do not put dataset records in the report.