Skip to content

Commit 4d06628

Browse files
committed
docs(VisualBuilderPlan): add §9.6 Training Data Inspector + F-H stage
New §9.6 Training Data Inspector — per-token metadata channels + parquet preview. Based on 3-agent research (code-extract across 3 repos + Exa deep + Perplexity deep; Brave/4th agent failed on JSON encoding error in tool output, не блокирует synthesis). Documents our enriched parquet schema (nanochat is widest): - Universal: input_ids, target_ids, loss_mask, doc_ids, pack_id, valid_token_count, num_docs - Platform: platform_ids (113-ID OS/arch/compiler/GPU vocab) - AST: token_ast_depth, sibling_index, node_type - Structure: token_structure_ids, dep_levels - Semantic: token_symbol_ids, call_targets, type_refs, def_use - Code scopes: token_chunk_starts/ends/kinds/dep_levels - Graph edges: token_call_edges, type_edges - Temporal/diff: change_mask_pre/post, hunk_id, edit_op Browser parquet stack (WASM-preferred): - Primary: hyparquet (pure JS, zero WASM, ~50 kB, streams from URL) - Grid: hyparam/hightable (virtualized, 1M+ packs) - Arrow JS for columnar manipulation - Lazy DuckDB-WASM (4-6 MB) for SQL filter mode - parquet-wasm 0.7.1 (456 KB brotli) optional for wide-schema decode Greenfield layers (~900 LoC, nobody does this combo): 1. Per-token ribbon timeline (1 ribbon per metadata channel) 2. FIM tri-pane mode when <fim_*> detected 3. Pack pagination + virtualized rendering 4. Forward-signature sidecar — static mapping parquet column → model.forward() kwarg + consumers (gdn needs doc_ids, engram needs chunk_starts+kinds, mhc needs symbol_ids, etc.) 5. Channel inspector hover tooltips with decoded interpretation (platform_id=42 → 'macOS arm64 clang metal') 6. Symbol-ID / call-graph mini-graph on chunk-boundary click 7. Reuse F-G Universal Tokenizer Playground for tokenize/detokenize 8. Multi-source mix Sankey (optional, reads '0.3 web 0.7 code') 9. Optional SQL filter via DuckDB-WASM lazy-load Production-frequency metadata channels (research-ranked): 1. document_ids / position-reset — universal (Llama-3, DeepSeek-V3) 2. loss_mask — universal SFT 3. FIM markers — all code models 4. Per-file headers <repo_name>, <file_name>, <lang> — StarCoder family 5. Per-document quality score — FineWeb-Edu, RedPajama-V2 Prior art cited: CTRL (arxiv:1909.05858), StarCoder/2 (2305.06161, 2402.19173), MeCo (2501.01956), BigScience metadata, Source-Aware Training (2404.01019), FineWeb-Edu (2406.17557). New JSON-RPC endpoint: data.preview_parquet (added to F-A schema): source + pack_offset/limit + channels[] + tokenizer + filter_sql Response: pack_id + num_docs + valid_token_count + channels dict + detokenized_text + forward_signature (kwarg/dtype/shape/source_column/ consumed_by per kwarg). Backend: new cppmega_v4.data.preview Python module with RuntimeParquet adapter (pyarrow.parquet in Jupyter mode; raw rows for JupyterLite browser-side hyparquet decode). F-H ticket cppmega-mlx-o0k.8 created under Visual Builder GUI epic. Can run in PARALLEL with F-C/F-D after F-A schema + F-G runtime. Budget updated: F-H +2 weeks (total effort 12 weeks; wall-clock ~8-9 unchanged due to parallelism).
1 parent 97e5645 commit 4d06628

1 file changed

Lines changed: 193 additions & 4 deletions

File tree

VisualBuilderPlan.md

Lines changed: 193 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -765,6 +765,34 @@ UI poсредник: ошибки кода маппит на in-place toast + no
765765
React shell)
766766
- См. cppmega-mlx-o0k.7
767767

768+
**Этап F-H — Training Data Inspector (2 недели)**
769+
- Новый React route/tab `/data` для preview enriched parquet
770+
- Runtime: `hyparquet` (pure JS, zero WASM, ~50 kB!) default
771+
streams from URL; lazy DuckDB-WASM (4-6 MB) для SQL filter
772+
- Virtualized grid через `hyparam/hightable` (1M+ packs smooth)
773+
- Greenfield слои (~900 LoC, не существует ни у кого): per-token
774+
ribbon timeline (1 ribbon per channel — int=palette, bool=binary,
775+
float=gradient), FIM tri-pane mode, pack pagination, forward-
776+
signature sidecar (статический mapping parquet column → forward
777+
kwarg + consumers), channel inspector hover tooltip, symbol-ID/
778+
call-graph mini-graph, multi-source Sankey, optional SQL filter
779+
- Reuse F-G Universal Tokenizer Playground component для tokenize/
780+
detokenize preview pane
781+
- Новый Python module `cppmega_v4.data.preview` — RuntimeParquet
782+
adapter поверх pyarrow.parquet (Jupyter mode); raw rows для
783+
JupyterLite browser-side decode
784+
- JSON-RPC endpoint `data.preview_parquet` (в F-A schema):
785+
source + pack_offset/limit + channels[] + tokenizer + optional
786+
filter_sql; response per pack с channels dict + detokenized_text
787+
+ forward_signature mapping
788+
- Тесты: unit (каждый channel renderer, FIM detection, forward-
789+
signature mapping для 22 bricks), system (load nanochat enriched
790+
parquet, paginate через 100 packs, verify все 18 channels render;
791+
load cppmega.mlx packed parquet с subset), perf (<200ms на pack
792+
load + ribbon render; pagination <50ms per page)
793+
- Можно делать ПАРАЛЛЕЛЬНО с F-C/F-D после F-A schema + F-G runtime
794+
- См. cppmega-mlx-o0k.8
795+
768796
**Этап F-E — JupyterLite/Pyodide static bundle + GH Pages deploy (1 неделя)**
769797
- Pyodide preload `cppmega_v4` (отделить от MLX runtime)
770798
- GitHub Pages auto-deploy on main commit
@@ -1000,6 +1028,165 @@ Cм. F-G ticket (`cppmega-mlx-o0k.7`).
10001028
10011029
---
10021030
1031+
9.6 Training Data Inspector — parquet preview + per-token metadata (F-H)
1032+
1033+
Отдельная вкладка `/data` в Visual Builder. У нас не просто token
1034+
streams — у нас **enriched parquet** с per-token metadata. nanochat
1035+
schema (`tokenized_enriched_schema.py:64-176`) шире всех:
1036+
1037+
- **Universal**: `input_ids`, `target_ids`, `loss_mask`, `doc_ids`,
1038+
`pack_id`, `valid_token_count`, `num_docs`
1039+
- **Platform**: `platform_ids` (113-ID vocab: OS/arch/compiler/GPU)
1040+
- **AST**: `token_ast_depth`, `token_sibling_index`, `token_ast_node_type`
1041+
- **Structure**: `token_structure_ids`, `token_dep_levels`
1042+
- **Semantic**: `token_symbol_ids`, `token_call_targets`,
1043+
`token_type_refs`, `token_def_use`
1044+
- **Code scopes**: `token_chunk_starts/ends/kinds/dep_levels`
1045+
- **Graph edges**: `token_call_edges`, `token_type_edges`
1046+
- **Temporal/diff**: `token_change_mask_pre/post`, `hunk_id_per_token`,
1047+
`edit_op_per_token`
1048+
1049+
cppmega.mlx mirrors subset (`parquet_dataset.py:34-41` aliases:
1050+
`token_structure_ids`, `token_dep_levels`, `ast_depth_ids`,
1051+
`sibling_index_ids`, `node_type_ids`). `LMTokenBatch` dataclass
1052+
шифрует это в model.forward().
1053+
1054+
### 9.6.1 Browser parquet stack (WASM-preferred)
1055+
1056+
| Pick | Bundle | When |
1057+
|---|---|---|
1058+
| **`hyparquet`** (pure JS) | ~50 kB, **zero WASM** | default — streams from URL, JupyterLite-friendly |
1059+
| `hyparam/hightable` | small | virtualized grid render (1M+ packs smooth) |
1060+
| `apache-arrow` JS | small | columnar manipulation в browser |
1061+
| `DuckDB-WASM` 1.33 | ~4-6 MB | lazy-load когда юзеру нужен SQL filter |
1062+
| `parquet-wasm` 0.7.1 | 456 KB brotli | optional, для wide-schema decode speed |
1063+
1064+
Reference: `XiangpengHao/parquet-viewer` (Rust+Dioxus WASM build).
1065+
1066+
### 9.6.2 UI layout
1067+
1068+
```
1069+
┌────────────────────────────────────────────────────────────────────┐
1070+
│ Tab: [Architecture/Loss/Optim/Tokenizer/Data/Sharding/Gotchas] │
1071+
├────────────────────────────────────────────────────────────────────┤
1072+
│ ┌─ Source ──────────┐ ┌─ Channel toggles ────────────────────┐ │
1073+
│ │ [browse... ▼] │ │ [✓doc_id] [✓loss_mask] [✓platform] │ │
1074+
│ │ packed_v3_001.pq │ │ [✓ast_depth] [□call_edges] [□type] │ │
1075+
│ │ 4096 packs │ │ [✓change_mask] [□hunk_id] │ │
1076+
│ └───────────────────┘ └──────────────────────────────────────┘ │
1077+
│ ┌─ Pack browser ─────────────────────────────────────────────┐ │
1078+
│ │ pack_id: 0 num_docs: 3 valid: 4090 [< prev] [next >] │ │
1079+
│ │ Token strip: ░def░ ░fib░ ░on░ ░acci░ ░<NL>░ ... │ │
1080+
│ │ Ribbon: doc_id [─doc_0──][doc_1──][doc_2──] │ │
1081+
│ │ Ribbon: loss_mask[████████░░░░████░░] │ │
1082+
│ │ Ribbon: ast_depth[▁▂▃▄▅▄▃▂▁▁▂▃▄▅▄▃▂▁] │ │
1083+
│ │ Ribbon: platform [▓gb10▓▓▓▓ ▒linux/x86▒▒] │ │
1084+
│ │ Ribbon: change [ ▰▰▰ pre-edit ▰▰▰ ] │ │
1085+
│ └────────────────────────────────────────────────────────────┘ │
1086+
│ ┌─ Forward signature sidecar ────────────────────────────────┐ │
1087+
│ │ В model.forward() для этого pack: │ │
1088+
│ │ input_ids: tensor[2048] int32 │ │
1089+
│ │ target_ids: tensor[2048] int32 ← target_ids col │ │
1090+
│ │ loss_mask: tensor[2048] bool ← loss_mask col │ │
1091+
│ │ doc_ids: tensor[2048] int32 ← cumsum from EOS │ │
1092+
│ │ platform_ids: tensor[2048] int32 consumer: platform_emb │ │
1093+
│ │ ast_depth_ids: tensor[2048] int32 consumer: structure │ │
1094+
│ │ (gdn needs doc_ids, engram needs chunk_starts+kinds, │ │
1095+
│ │ mhc needs symbol_ids) │ │
1096+
│ └────────────────────────────────────────────────────────────┘ │
1097+
│ ┌─ Tokenize/Detokenize preview (reuses F-G) ────────────────┐ │
1098+
│ │ raw text → tokens → decode round-trip diff │ │
1099+
│ └────────────────────────────────────────────────────────────┘ │
1100+
│ ┌─ Multi-source mix (Sankey, optional) ──────────────────────┐ │
1101+
│ │ [web 30%]─┐ │ │
1102+
│ │ ├─→[mixed_pack_001..1000] │ │
1103+
│ │ [code 70%]┘ │ │
1104+
│ └────────────────────────────────────────────────────────────┘ │
1105+
└────────────────────────────────────────────────────────────────────┘
1106+
```
1107+
1108+
### 9.6.3 Greenfield слои (~900 LoC)
1109+
1110+
Никто из 9+ обследованных tools не делает per-token overlay внутри
1111+
packed sequence. Что строим:
1112+
1113+
1. Per-token **ribbon timeline** под token strip (1 ribbon per
1114+
channel; цвет mapping per type: int=palette, bool=binary,
1115+
float=gradient)
1116+
2. **FIM tri-pane mode** когда detected `<fim_*>` markers в pack
1117+
3. **Pack pagination** с virtualized rendering (1M+ packs)
1118+
4. **Forward-signature sidecar** — статический mapping parquet
1119+
column → `model.forward()` kwarg + consumers ('gdn needs
1120+
doc_ids', 'engram needs chunk_starts+kinds', 'mhc needs
1121+
symbol_ids', 'platform_emb needs platform_ids')
1122+
5. **Channel inspector**: hover ribbon segment → tooltip с raw value
1123+
+ decoded interpretation (`platform_id=42 → macOS arm64 clang metal`)
1124+
6. **Symbol-ID/call-graph mini-graph**: click chunk boundary →
1125+
small graph showing call edges
1126+
7. **Reuse F-G Tokenizer Playground** для tokenize/detokenize preview
1127+
8. **Multi-source mix Sankey** (optional, читает '0.3 web 0.7 code')
1128+
9. **SQL filter mode** (DuckDB-WASM lazy-load) — `WHERE doc_count>5
1129+
AND any(loss_mask==0)`
1130+
1131+
### 9.6.4 Production-frequency channels (research)
1132+
1133+
Top 5 metadata channels in production (frequency-ranked, по 4-agent scan):
1134+
1135+
1. `document_ids` / position-reset — Llama-3, DeepSeek-V3, Jamba,
1136+
Nemotron (universal)
1137+
2. `loss_mask` (ignore_index=-100) — universal SFT
1138+
3. FIM `<fim_prefix/middle/suffix>` — StarCoder/2, SantaCoder,
1139+
DeepSeek-Coder, Code-Llama (arxiv:2207.14255)
1140+
4. Per-file headers `<repo_name>`, `<file_name>`, `<lang>` —
1141+
StarCoder family (arxiv:2305.06161, 2402.19173)
1142+
5. Per-document quality score (FineWeb-Edu classifier,
1143+
RedPajama-V2 signals) — все web mixes
1144+
1145+
Related prior art: CTRL (arxiv:1909.05858), BigScience metadata
1146+
schema, MeCo (arxiv:2501.01956), Source-Aware Training (arxiv:2404.01019).
1147+
1148+
### 9.6.5 API endpoint (новый в F-A schema)
1149+
1150+
```json
1151+
{
1152+
"method": "data.preview_parquet",
1153+
"params": {
1154+
"source": { "type": "local_file|url|hf_dataset", "spec": "..." },
1155+
"pack_offset": 0, "pack_limit": 10,
1156+
"channels": ["doc_ids", "loss_mask", "platform_ids", "ast_depth_ids"],
1157+
"tokenizer": { "source": "preset", "spec": "cppmega_v3" },
1158+
"filter_sql": null
1159+
}
1160+
}
1161+
```
1162+
1163+
Response per pack:
1164+
```json
1165+
{
1166+
"pack_id": 0, "num_docs": 3, "valid_token_count": 4090,
1167+
"channels": {
1168+
"doc_ids": [0,0,0,0,0,1,1,1, ...],
1169+
"loss_mask": [1,1,1,0,0,1,1,1, ...],
1170+
"platform_ids": [42,42,42, ...]
1171+
},
1172+
"detokenized_text": "...",
1173+
"forward_signature": [
1174+
{"kwarg": "input_ids", "dtype": "int32", "shape": [2048],
1175+
"source_column": "input_ids", "consumed_by": ["all"]},
1176+
{"kwarg": "doc_ids", "dtype": "int32", "shape": [2048],
1177+
"source_column": "doc_ids", "consumed_by": ["gdn", "kda", "engram"]}
1178+
]
1179+
}
1180+
```
1181+
1182+
Backend: новый `cppmega_v4.data.preview` Python module с
1183+
`RuntimeParquet` adapter поверх pyarrow.parquet (Jupyter mode); raw
1184+
rows для browser-side decode (JupyterLite через hyparquet).
1185+
1186+
См. F-H ticket (`cppmega-mlx-o0k.8`).
1187+
1188+
---
1189+
10031190
10. Покрытие Раschka LLM Architecture Gallery (71 модель)
10041191
10051192
Прогнал список галереи против наших 22 bricks + 12 presets.
@@ -1043,10 +1230,12 @@ bricks, parallel-block topology, gallery coverage tests.
10431230
10441231
11. Бюджет + риски
10451232
1046-
Бюджет: 10 недель effort (F-A + F-A.2 + F-B..F-E + F-G universal playground
1047-
2 нед) для v1 production-ready Jupyter widget + static demo + CLI runner +
1048-
universal tokenizer playground. F-G параллелится с F-C/F-D, поэтому
1049-
wall-clock остаётся ~8 недель. Phase 2 опционально через 3-6 месяцев.
1233+
Бюджет: 12 недель effort (F-A + F-A.2 + F-B..F-E + F-G universal
1234+
tokenizer playground 2 нед + F-H training data inspector 2 нед) для v1
1235+
production-ready Jupyter widget + static demo + CLI runner + tokenizer
1236+
playground + data inspector. F-G и F-H параллелятся с F-C/F-D после
1237+
F-A schema lock; F-H также зависит от F-G runtime для tokenizer reuse.
1238+
Wall-clock остаётся ~8-9 недель. Phase 2 опционально через 3-6 месяцев.
10501239
10511240
**Нумерация секций после правок**: §1-9 как раньше, §10 (gallery
10521241
coverage), §11 (бюджет+риски, был §10).

0 commit comments

Comments
 (0)