@mechane-ai/elements 0.47.0 → 0.49.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +288 -5
- package/bin/mechane-elements-catalog.mjs +104 -12
- package/dist/ai.js +5 -5
- package/dist/article-yyNPg6VU.js +1904 -0
- package/dist/article.js +1 -0
- package/dist/catalog.json +1691 -163
- package/dist/{categorical-values-DdfGIowV.js → categorical-values-DCznViFp.js} +1 -1
- package/dist/{cells--Bd1fQFR.js → cells-CNZE4us2.js} +2 -2
- package/dist/charts/cartesian.js +1 -1
- package/dist/charts/cells.js +1 -1
- package/dist/charts/comparison.js +1 -1
- package/dist/charts/distribution.js +1 -1
- package/dist/charts/figure.js +12 -12
- package/dist/charts/graph.js +1 -1
- package/dist/charts/hierarchy.js +1 -1
- package/dist/charts/image.js +1 -1
- package/dist/charts/matrix.js +3 -2
- package/dist/charts/plot.js +6 -6
- package/dist/charts/relationship.js +1 -1
- package/dist/charts/text.js +1 -1
- package/dist/charts/timeline.js +1 -1
- package/dist/charts/trend.js +1 -1
- package/dist/charts.js +2 -2
- package/dist/clock-DSm5lkNE.js +16 -0
- package/dist/{code-block-DioAM2bZ.js → code-block-BZsY2sh3.js} +1 -1
- package/dist/collections.js +1 -1
- package/dist/content/code.js +1 -1
- package/dist/content/diff.js +3 -3
- package/dist/content/link.js +1 -1
- package/dist/content/markdown.js +2 -2
- package/dist/content/tree.js +1 -1
- package/dist/{content-link-NWuHp5rC.js → content-link-PnpcnTCx.js} +1 -1
- package/dist/content.js +1 -1
- package/dist/{dates-Cww8UR_n.js → dates-ckJdYF7t.js} +1 -1
- package/dist/describe-lesson-BmREzDpt.js +175 -0
- package/dist/{dumbbell-plot-B2ZTgQaI.js → dumbbell-plot-CMv9llfd.js} +9 -7
- package/dist/{embedding-map-CGM_k6lC.js → embedding-map-DC-lgzCq.js} +8 -8
- package/dist/feedback.js +1 -1
- package/dist/{figure-frame-wRkIEAwe.js → figure-frame-BjFzbl3m.js} +3 -3
- package/dist/forms/dates.js +1 -1
- package/dist/forms.js +3 -3
- package/dist/{image-grid-CVA4SOy_.js → image-grid-DHqtj_zs.js} +4 -4
- package/dist/index.js +1 -1
- package/dist/kits/evaluation.js +5 -5
- package/dist/kits/interpretability.js +320 -302
- package/dist/kits/operations.js +6 -6
- package/dist/kits/research.js +558 -0
- package/dist/kits/training.js +6 -6
- package/dist/layout.js +205 -110
- package/dist/lesson/agent.js +811 -0
- package/dist/lesson/spec.js +661 -0
- package/dist/lesson.js +5 -0
- package/dist/mdx.js +227 -0
- package/dist/navigation.js +2 -2
- package/dist/packages/charts/src/cartesian/index.d.ts +1 -1
- package/dist/packages/charts/src/cartesian/scatter-plot.d.ts +18 -0
- package/dist/packages/charts/src/chart-theme.d.ts +1 -1
- package/dist/packages/charts/src/matrix/index.d.ts +1 -0
- package/dist/packages/charts/src/plot/plot-marks.d.ts +7 -3
- package/dist/packages/charts/src/plot/plot-surface.d.ts +3 -1
- package/dist/packages/collections/src/index.d.ts +1 -1
- package/dist/packages/collections/src/metrics.d.ts +9 -1
- package/dist/packages/content/src/index.d.ts +2 -0
- package/dist/packages/content/src/text-match.d.ts +22 -0
- package/dist/packages/core/src/index.d.ts +1 -0
- package/dist/packages/core/src/surfaces.d.ts +12 -2
- package/dist/packages/forms/src/index.d.ts +2 -0
- package/dist/packages/forms/src/token-input.d.ts +24 -0
- package/dist/packages/kits/src/interpretability/index.d.ts +1 -1
- package/dist/packages/kits/src/interpretability/logit-lens.d.ts +10 -1
- package/dist/packages/kits/src/research/finding-card.d.ts +43 -0
- package/dist/packages/kits/src/research/index.d.ts +8 -0
- package/dist/packages/kits/src/research/milestone-path.d.ts +36 -0
- package/dist/packages/kits/src/research/specimen-diff.d.ts +41 -0
- package/dist/packages/kits/src/research/work-heartbeat.d.ts +34 -0
- package/dist/packages/layout/src/figure-grid.d.ts +8 -0
- package/dist/packages/layout/src/index.d.ts +4 -1
- package/dist/packages/layout/src/sidebar.d.ts +7 -0
- package/dist/packages/layout/src/workbench.d.ts +4 -1
- package/dist/packages/teaching/src/agent/index.d.ts +11 -0
- package/dist/packages/teaching/src/agent/learner-trace.d.ts +84 -0
- package/dist/packages/teaching/src/agent/lesson-bridge.d.ts +59 -0
- package/dist/packages/teaching/src/agent/lesson-tour.d.ts +63 -0
- package/dist/packages/teaching/src/agent/tutor-tools.d.ts +86 -0
- package/dist/packages/teaching/src/article/article-checks.d.ts +9 -0
- package/dist/packages/teaching/src/article/article-context.d.ts +49 -0
- package/dist/packages/teaching/src/article/article-error.d.ts +12 -0
- package/dist/packages/teaching/src/article/article-labels.d.ts +54 -0
- package/dist/packages/teaching/src/article/article-layout.stylex.d.ts +14 -0
- package/dist/packages/teaching/src/article/article-outline.d.ts +9 -0
- package/dist/packages/teaching/src/article/article.d.ts +42 -0
- package/dist/packages/teaching/src/article/beat-steps.d.ts +18 -0
- package/dist/packages/teaching/src/article/beat.d.ts +16 -0
- package/dist/packages/teaching/src/article/challenge.d.ts +29 -0
- package/dist/packages/teaching/src/article/exercise-styles.d.ts +76 -0
- package/dist/packages/teaching/src/article/figure.d.ts +51 -0
- package/dist/packages/teaching/src/article/index.d.ts +31 -0
- package/dist/packages/teaching/src/article/lesson-values.d.ts +5 -0
- package/dist/packages/teaching/src/article/notes.d.ts +36 -0
- package/dist/packages/teaching/src/article/outline-types.d.ts +73 -0
- package/dist/packages/teaching/src/article/predict.d.ts +58 -0
- package/dist/packages/teaching/src/article/progress-store.d.ts +64 -0
- package/dist/packages/teaching/src/article/scrolly.d.ts +26 -0
- package/dist/packages/{kits/src/explainers → teaching/src/article}/term.d.ts +8 -2
- package/dist/packages/teaching/src/article/tex.d.ts +12 -0
- package/dist/packages/teaching/src/article/view-essay.d.ts +13 -0
- package/dist/packages/teaching/src/article/view-present.d.ts +8 -0
- package/dist/packages/teaching/src/article/view-sheet.d.ts +7 -0
- package/dist/packages/teaching/src/article/view-static.d.ts +7 -0
- package/dist/packages/teaching/src/article/walk.d.ts +34 -0
- package/dist/packages/teaching/src/lesson/define-lesson.d.ts +136 -0
- package/dist/packages/teaching/src/lesson/index.d.ts +24 -0
- package/dist/packages/teaching/src/lesson/inline-choice.d.ts +12 -0
- package/dist/packages/teaching/src/lesson/lesson-context.d.ts +18 -0
- package/dist/packages/teaching/src/lesson/lesson-error.d.ts +12 -0
- package/dist/packages/teaching/src/lesson/lesson-locale.d.ts +4 -0
- package/dist/packages/teaching/src/lesson/lesson-persistence.d.ts +17 -0
- package/dist/packages/teaching/src/lesson/lesson-player.d.ts +51 -0
- package/dist/packages/teaching/src/lesson/lesson-store.d.ts +84 -0
- package/dist/packages/teaching/src/lesson/lesson.d.ts +39 -0
- package/dist/packages/teaching/src/lesson/param-controls.d.ts +14 -0
- package/dist/packages/teaching/src/lesson/param.d.ts +34 -0
- package/dist/packages/teaching/src/lesson/playback.d.ts +42 -0
- package/dist/packages/teaching/src/lesson/transport.d.ts +19 -0
- package/dist/packages/teaching/src/lesson/use-lesson.d.ts +36 -0
- package/dist/packages/teaching/src/mdx/essay-components.d.ts +79 -0
- package/dist/packages/teaching/src/mdx/essay-markdown.d.ts +41 -0
- package/dist/packages/teaching/src/mdx/essay.d.ts +32 -0
- package/dist/packages/teaching/src/mdx/index.d.ts +9 -0
- package/dist/packages/teaching/src/mdx/requested-view.d.ts +6 -0
- package/dist/packages/teaching/src/scene/flow/flow-layout.d.ts +38 -0
- package/dist/packages/teaching/src/scene/flow/flow-pulse.d.ts +16 -0
- package/dist/packages/teaching/src/scene/flow/scene-flow.d.ts +81 -0
- package/dist/packages/teaching/src/scene/index.d.ts +77 -0
- package/dist/packages/teaching/src/scene/morph/morph-scope.d.ts +28 -0
- package/dist/packages/teaching/src/scene/plane/plane-hit.d.ts +22 -0
- package/dist/packages/teaching/src/scene/plane/plane-label.d.ts +23 -0
- package/dist/packages/teaching/src/scene/plane/plane-labels.d.ts +42 -0
- package/dist/packages/teaching/src/scene/plane/plane-math.d.ts +45 -0
- package/dist/packages/teaching/src/scene/plane/scene-axes.d.ts +30 -0
- package/dist/packages/teaching/src/scene/plane/scene-curve.d.ts +42 -0
- package/dist/packages/teaching/src/scene/plane/scene-point.d.ts +59 -0
- package/dist/packages/teaching/src/scene/plane/scene-projection.d.ts +27 -0
- package/dist/packages/teaching/src/scene/plane/scene-region.d.ts +38 -0
- package/dist/packages/teaching/src/scene/plane/scene-rule.d.ts +35 -0
- package/dist/packages/teaching/src/scene/plane/scene-vector.d.ts +39 -0
- package/dist/packages/teaching/src/scene/scene-bracket.d.ts +24 -0
- package/dist/packages/teaching/src/scene/scene-callout.d.ts +26 -0
- package/dist/packages/teaching/src/scene/scene-context.d.ts +179 -0
- package/dist/packages/teaching/src/scene/scene-custom.d.ts +31 -0
- package/dist/packages/teaching/src/scene/scene-geometry.d.ts +181 -0
- package/dist/packages/teaching/src/scene/scene-group.d.ts +28 -0
- package/dist/packages/teaching/src/scene/scene-highlight.d.ts +19 -0
- package/dist/packages/teaching/src/scene/scene-layer.d.ts +16 -0
- package/dist/packages/teaching/src/scene/scene-node.d.ts +67 -0
- package/dist/packages/teaching/src/scene/scene-obstacles.d.ts +27 -0
- package/dist/packages/teaching/src/scene/scene-registry.d.ts +79 -0
- package/dist/packages/teaching/src/scene/scene-stagger.d.ts +43 -0
- package/dist/packages/teaching/src/scene/scene-style.d.ts +14 -0
- package/dist/packages/teaching/src/scene/scene-validate.d.ts +65 -0
- package/dist/packages/teaching/src/scene/scene-wire.d.ts +45 -0
- package/dist/packages/teaching/src/scene/scene.d.ts +36 -0
- package/dist/packages/teaching/src/scene/shapes/cell-color.d.ts +11 -0
- package/dist/packages/teaching/src/scene/shapes/cell-grid.d.ts +69 -0
- package/dist/packages/teaching/src/scene/shapes/scene-card.d.ts +114 -0
- package/dist/packages/teaching/src/scene/shapes/scene-cells.d.ts +84 -0
- package/dist/packages/teaching/src/scene/shapes/scene-slot.d.ts +37 -0
- package/dist/packages/teaching/src/scene/shapes/scene-stack.d.ts +46 -0
- package/dist/packages/teaching/src/scene/shapes/scene-token.d.ts +63 -0
- package/dist/packages/teaching/src/scene/shapes/scene-tokens.d.ts +40 -0
- package/dist/packages/teaching/src/scene/shapes/stack-book.d.ts +35 -0
- package/dist/packages/teaching/src/scene/shapes/stack-layout.d.ts +63 -0
- package/dist/packages/teaching/src/scene/shapes/token-layout.d.ts +39 -0
- package/dist/packages/teaching/src/spec/advice.d.ts +23 -0
- package/dist/packages/teaching/src/spec/chart-names.d.ts +2 -0
- package/dist/packages/teaching/src/spec/describe-lesson.d.ts +85 -0
- package/dist/packages/teaching/src/spec/explainer-guide.d.ts +21 -0
- package/dist/packages/teaching/src/spec/findings.d.ts +39 -0
- package/dist/packages/teaching/src/spec/index.d.ts +14 -0
- package/dist/packages/teaching/src/spec/lesson-plan.d.ts +43 -0
- package/dist/packages/teaching/src/spec/validate-plan.d.ts +11 -0
- package/dist/packages/teaching/src/time/clock.d.ts +7 -0
- package/dist/packages/teaching/src/time/tween.d.ts +19 -0
- package/dist/packages/teaching/src/time/use-tween.d.ts +6 -0
- package/dist/param-BE3VMSkH.js +450 -0
- package/dist/{pierre-diff-DlvjyuJn.js → pierre-diff-aGyQK5xK.js} +1 -1
- package/dist/{plot-axes-DJkLW4wk.js → plot-axes-D5S9BnBa.js} +1 -1
- package/dist/{plot-layout-BEuoOHbs.js → plot-layout-Bqe4-0qZ.js} +4 -3
- package/dist/{plot-marks-A64v7aTw.js → plot-marks-FVsbFkUs.js} +18 -15
- package/dist/{plot-surface-CJTIqtck.js → plot-surface-DON6WUmk.js} +11 -11
- package/dist/{plot-width-DcqtSgzb.js → plot-width-D3hTycYX.js} +1 -1
- package/dist/{reference-lines-CWA8VeUR.js → reference-lines-hjuD1rRZ.js} +2 -2
- package/dist/scene-BP0Ue0R5.js +4938 -0
- package/dist/scene.js +1 -0
- package/dist/{slope-chart-DT22h_ym.js → slope-chart-C8eeSgL4.js} +7 -7
- package/dist/{src-CpdJlDhO.js → src-9EJskqB_.js} +73 -31
- package/dist/{src-D5NXRJZe.js → src-B2rgpWap.js} +48 -14
- package/dist/{src-BPTDJqt0.js → src-Ci8DeY8J.js} +1 -1
- package/dist/{src-CGc_hjxJ.js → src-DFW49IAs.js} +143 -111
- package/dist/{src-1EHkSFS-.js → src-Dxs3Buo_.js} +205 -139
- package/dist/{src-CExIrXPC.js → src-npqwq3Sa.js} +1 -1
- package/dist/styles2.css +542 -21
- package/dist/{time-series-IB3CB93O.js → time-series-BL933QyA.js} +787 -715
- package/dist/{token-heatmap-C00DnoNO.js → token-heatmap-BB65awva.js} +4 -4
- package/dist/{token-predictions-Cxx29iDr.js → token-predictions-Pa8eUGan.js} +6 -6
- package/dist/transport-DzyxVXbL.js +715 -0
- package/dist/{tree-diagram-DsckNKaW.js → tree-diagram-DJhKBiia.js} +6 -6
- package/dist/{treemap-9_DpLCW9.js → treemap-CxxgABUg.js} +5 -5
- package/dist/use-tween-5HZ55_9d.js +72 -0
- package/dist/{violin-plot-BhPHKXsN.js → violin-plot-CoAEF_7Z.js} +7 -6
- package/dist/{waterfall-CGksuTy5.js → waterfall-DdoEXEkT.js} +7 -7
- package/package.json +30 -5
- package/recipes/counting-cards.tsx +656 -0
- package/recipes/explorable-essay.tsx +172 -0
- package/skills/extend-elements/SKILL.md +21 -0
- package/skills/plan-lesson/SKILL.md +86 -0
- package/skills/plan-lesson/references/plan-format.md +114 -0
- package/skills/plan-lesson/references/worked-plan.md +171 -0
- package/skills/review-elements/SKILL.md +4 -2
- package/skills/review-explainer/SKILL.md +97 -0
- package/skills/upgrade-elements/references/releases.md +65 -0
- package/skills/use-elements/SKILL.md +18 -16
- package/skills/use-elements/references/kits.md +9 -26
- package/skills/use-elements/references/teaching.md +36 -0
- package/skills/write-explainer/SKILL.md +112 -0
- package/skills/write-explainer/references/article.md +164 -0
- package/skills/write-explainer/references/lesson.md +148 -0
- package/skills/write-explainer/references/mdx.md +78 -0
- package/skills/write-explainer/references/scene-parts.md +273 -0
- package/skills/write-explainer/references/scene.md +168 -0
- package/skills/write-explainer/references/tutor.md +104 -0
- package/skills/write-explainer/references/worked-essay.md +459 -0
- package/templates/essay/AGENTS.md +14 -0
- package/templates/essay/README.md +59 -0
- package/templates/essay/index.html +17 -0
- package/templates/essay/package.template.json +21 -0
- package/templates/essay/plan.json +96 -0
- package/templates/essay/src/essay.mdx +97 -0
- package/templates/essay/src/figures.tsx +92 -0
- package/templates/essay/src/lesson.ts +83 -0
- package/templates/essay/src/main.tsx +53 -0
- package/templates/essay/src/mdx.d.ts +7 -0
- package/templates/essay/tsconfig.template.json +15 -0
- package/templates/essay/vite.config.template.txt +8 -0
- package/dist/kits/explainers.js +0 -452
- package/dist/packages/kits/src/explainers/figures.d.ts +0 -31
- package/dist/packages/kits/src/explainers/index.d.ts +0 -8
- package/dist/packages/kits/src/explainers/story-steps.d.ts +0 -46
- /package/dist/packages/{kits/src/explainers → teaching/src/article}/linked-target.d.ts +0 -0
- /package/dist/packages/{kits/src/explainers → teaching/src/lesson}/bound-value.d.ts +0 -0
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
import { Article, Beat, Figure, Predict } from '@mechane-ai/elements/article';
|
|
2
|
+
import { CurveChart } from '@mechane-ai/elements/charts/trend';
|
|
3
|
+
import { defineLesson, Param, useLesson, Value } from '@mechane-ai/elements/lesson';
|
|
4
|
+
import { Scene, SceneNode, SceneWire } from '@mechane-ai/elements/scene';
|
|
5
|
+
import { spacing } from '@mechane-ai/elements/tokens';
|
|
6
|
+
|
|
7
|
+
type EssayProps = { readonly title: string; readonly summary: string };
|
|
8
|
+
|
|
9
|
+
const BATCH_MAX = 256;
|
|
10
|
+
const CURVE_POINTS = 33;
|
|
11
|
+
const PAGE_WIDTH = 1200;
|
|
12
|
+
|
|
13
|
+
/** The page's own gutter: an article fills what it is given and leaves the edges to the page. */
|
|
14
|
+
const pageStyle = {
|
|
15
|
+
boxSizing: 'border-box',
|
|
16
|
+
maxWidth: PAGE_WIDTH,
|
|
17
|
+
margin: '0 auto',
|
|
18
|
+
padding: `${spacing.xxl} ${spacing.lg}`,
|
|
19
|
+
} as const;
|
|
20
|
+
|
|
21
|
+
/** Gradient noise falls with the square root of the batch size. The numbers are synthetic. */
|
|
22
|
+
const lesson = defineLesson({
|
|
23
|
+
id: 'batch-noise',
|
|
24
|
+
title: 'Why a bigger batch is quieter',
|
|
25
|
+
params: {
|
|
26
|
+
batch: {
|
|
27
|
+
kind: 'number',
|
|
28
|
+
label: 'Batch size',
|
|
29
|
+
value: 4,
|
|
30
|
+
min: 1,
|
|
31
|
+
max: BATCH_MAX,
|
|
32
|
+
step: 1,
|
|
33
|
+
scale: 'log',
|
|
34
|
+
format: { maximumFractionDigits: 0 },
|
|
35
|
+
},
|
|
36
|
+
},
|
|
37
|
+
derived: {
|
|
38
|
+
noise: {
|
|
39
|
+
label: 'Gradient noise',
|
|
40
|
+
format: { style: 'percent', maximumFractionDigits: 0 },
|
|
41
|
+
from: ({ batch }) => 1 / Math.sqrt(batch),
|
|
42
|
+
},
|
|
43
|
+
},
|
|
44
|
+
beats: [
|
|
45
|
+
{
|
|
46
|
+
id: 'estimate',
|
|
47
|
+
title: 'A batch estimates the gradient',
|
|
48
|
+
goal: 'See that the gradient of a batch is an average, so its error comes from how few examples it averages.',
|
|
49
|
+
states: [
|
|
50
|
+
{ id: 'single', label: 'One example', values: { batch: 1 } },
|
|
51
|
+
{ id: 'sixteen', label: 'Sixteen examples', values: { batch: 16 } },
|
|
52
|
+
],
|
|
53
|
+
},
|
|
54
|
+
{
|
|
55
|
+
id: 'noise',
|
|
56
|
+
title: 'Noise falls with the square root',
|
|
57
|
+
goal: 'Find that four times the examples halves the noise, not quarters it.',
|
|
58
|
+
misconception: 'That doubling the batch halves the noise.',
|
|
59
|
+
states: [
|
|
60
|
+
{ id: 'four', label: 'Four examples', values: { batch: 4 } },
|
|
61
|
+
{ id: 'sixty-four', label: 'Sixty-four examples', values: { batch: 64 } },
|
|
62
|
+
],
|
|
63
|
+
},
|
|
64
|
+
],
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
const batches = Array.from({ length: CURVE_POINTS }, (_, index) => BATCH_MAX ** (index / (CURVE_POINTS - 1)));
|
|
68
|
+
|
|
69
|
+
function BatchScene() {
|
|
70
|
+
const { values, locale } = useLesson(lesson);
|
|
71
|
+
|
|
72
|
+
return (
|
|
73
|
+
<Scene
|
|
74
|
+
title="From a batch to a gradient"
|
|
75
|
+
description="Synthetic. A batch of examples is averaged into one gradient estimate whose noise shrinks as the batch grows."
|
|
76
|
+
locale={locale}
|
|
77
|
+
x={[0, 2]}
|
|
78
|
+
y={[0, 1]}
|
|
79
|
+
height="compact"
|
|
80
|
+
>
|
|
81
|
+
<SceneNode
|
|
82
|
+
id="batch"
|
|
83
|
+
at={[0.5, 0.5]}
|
|
84
|
+
text={`${values.batch} examples`}
|
|
85
|
+
label={`A batch of ${values.batch} examples`}
|
|
86
|
+
/>
|
|
87
|
+
<SceneNode
|
|
88
|
+
id="gradient"
|
|
89
|
+
at={[1.5, 0.5]}
|
|
90
|
+
shape="pill"
|
|
91
|
+
text="gradient"
|
|
92
|
+
label={`The averaged gradient, with noise ${Math.round(values.noise * 100)}% of a single example's`}
|
|
93
|
+
tone={values.noise > 0.5 ? 'negative' : 'positive'}
|
|
94
|
+
/>
|
|
95
|
+
<SceneWire from="batch" to="gradient" label="The examples are averaged" />
|
|
96
|
+
</Scene>
|
|
97
|
+
);
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
function NoiseCurve() {
|
|
101
|
+
const { values, locale } = useLesson(lesson);
|
|
102
|
+
|
|
103
|
+
return (
|
|
104
|
+
<CurveChart
|
|
105
|
+
title="Gradient noise by batch size"
|
|
106
|
+
description="Synthetic noise as a share of a single example's noise, on a log batch axis."
|
|
107
|
+
locale={locale}
|
|
108
|
+
series={[
|
|
109
|
+
{
|
|
110
|
+
id: 'noise',
|
|
111
|
+
label: 'Noise',
|
|
112
|
+
tone: 'series1',
|
|
113
|
+
points: batches.map((batch) => ({ x: batch, y: 1 / Math.sqrt(batch) })),
|
|
114
|
+
},
|
|
115
|
+
]}
|
|
116
|
+
x={{ label: 'Batch size', scale: 'log', domain: [1, BATCH_MAX], format: { maximumFractionDigits: 0 } }}
|
|
117
|
+
y={{ label: 'Noise', domain: [0, 1], format: { style: 'percent', maximumFractionDigits: 0 } }}
|
|
118
|
+
markers={[{ x: values.batch, label: 'Now' }]}
|
|
119
|
+
labels="none"
|
|
120
|
+
height="compact"
|
|
121
|
+
/>
|
|
122
|
+
);
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
/**
|
|
126
|
+
* Build an explorable essay in one TSX file: a lesson that declares the values, two beats of prose that read them, a
|
|
127
|
+
* scene, a chart and a prediction. Pass a title and a summary. Use an MDX file with the essay starter instead when the
|
|
128
|
+
* prose is long.
|
|
129
|
+
*/
|
|
130
|
+
export function ExplorableEssay({ title, summary }: EssayProps) {
|
|
131
|
+
return (
|
|
132
|
+
<main style={pageStyle}>
|
|
133
|
+
<Article lesson={lesson} locale="en-US" title={title} summary={summary}>
|
|
134
|
+
<Beat id="estimate">
|
|
135
|
+
<p>
|
|
136
|
+
A gradient from <Param name="batch" /> examples is their average, so it is noisy by <Value name="noise" />{' '}
|
|
137
|
+
of what a single example gives.
|
|
138
|
+
</p>
|
|
139
|
+
<Figure
|
|
140
|
+
id="batch-scene"
|
|
141
|
+
caption="A batch of examples is averaged into one gradient."
|
|
142
|
+
description="Two boxes joined by an arrow: the batch of examples and the gradient they average into."
|
|
143
|
+
>
|
|
144
|
+
<BatchScene />
|
|
145
|
+
</Figure>
|
|
146
|
+
</Beat>
|
|
147
|
+
<Beat id="noise">
|
|
148
|
+
<Predict
|
|
149
|
+
id="quadruple"
|
|
150
|
+
prompt="Four times the examples: how does the noise change?"
|
|
151
|
+
options={[
|
|
152
|
+
{ id: 'quarter', label: 'It falls to a quarter' },
|
|
153
|
+
{ id: 'half', label: 'It halves' },
|
|
154
|
+
{ id: 'same', label: 'It stays the same' },
|
|
155
|
+
]}
|
|
156
|
+
answer="half"
|
|
157
|
+
>
|
|
158
|
+
<p>Noise falls with the square root of the batch size, so four times the examples halves it.</p>
|
|
159
|
+
</Predict>
|
|
160
|
+
<Figure
|
|
161
|
+
id="noise-curve"
|
|
162
|
+
caption="Noise at every batch size, with the current one marked."
|
|
163
|
+
description="A curve falling steeply for small batches and slowly for large ones."
|
|
164
|
+
reads={['batch']}
|
|
165
|
+
>
|
|
166
|
+
<NoiseCurve />
|
|
167
|
+
</Figure>
|
|
168
|
+
</Beat>
|
|
169
|
+
</Article>
|
|
170
|
+
</main>
|
|
171
|
+
);
|
|
172
|
+
}
|
|
@@ -160,3 +160,24 @@ axes or colors. If you want to draw an SVG mark, use or request a chart instead.
|
|
|
160
160
|
- Compute no statistic. The application supplies means, intervals, ranks and deltas.
|
|
161
161
|
- Write one stories file titled `Kits/<Kit name>` with a story per component, one page that composes them and a `States`
|
|
162
162
|
story. Export the components from the kit's `index.ts` and add the entry to `package.json`.
|
|
163
|
+
|
|
164
|
+
## A teaching part
|
|
165
|
+
|
|
166
|
+
The teaching layers live in `packages/teaching/src`: `lesson`, `time`, `scene`, `article`, `mdx`, `spec` and `agent`.
|
|
167
|
+
Read contract `workspaces/core/.contracts/142-ui-teaching-layers/CONTRACT.md` first. A part an essay keeps drawing by
|
|
168
|
+
hand, with `SceneCustom` or raw SVG, is a candidate.
|
|
169
|
+
|
|
170
|
+
- Put a scene part in the scene folder that owns its kind: `scene/plane` for coordinate marks, `scene/shapes` for cards,
|
|
171
|
+
cells and tokens, `scene/flow` and `scene/morph`, or the folder root for a core part. Copy `scene/scene-node.tsx` for
|
|
172
|
+
a part on the HTML layer, or `scene/scene-bracket.tsx` for an SVG one.
|
|
173
|
+
- Register the object with `useSceneObject` and draw from the eased values it returns. Never start a frame loop, a timer
|
|
174
|
+
or a keyframe: the one clock in `time/clock.ts` moves everything, and reduced motion takes the end state.
|
|
175
|
+
- Give it a stable `id`, `isShown`, a `label` that makes it a keyboard item, `tone` resolved through the tone scope, and
|
|
176
|
+
a `labels` prop for its own words. Report author errors with `problem`, not by throwing.
|
|
177
|
+
- Inside `packages/teaching/src`, import the defining file, never a folder's `index.ts`. Export the part from its
|
|
178
|
+
folder's `index.ts`, which is the public entry.
|
|
179
|
+
- Add it to `explainerParts` and the guide in `spec/explainer-guide.ts` with the reader's `question`, `guidance` that
|
|
180
|
+
names the better part otherwise, and an `example` that compiles. Add it to `essayComponents` in
|
|
181
|
+
`mdx/essay-components.ts` so MDX essays can use it.
|
|
182
|
+
- Write `Teaching/<Name>` stories beside it: a default with synthetic machine-learning content said to be synthetic,
|
|
183
|
+
states, narrow and reduced motion. Describe it in the `write-explainer` skill's scene references.
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: plan-lesson
|
|
3
|
+
description:
|
|
4
|
+
Plan an explorable explanation before writing any component. Use when asked to explain a topic, a paper or a research
|
|
5
|
+
result as an interactive essay with `@mechane-ai/elements`, or before changing the beats of an existing lesson.
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
# Plan a lesson
|
|
9
|
+
|
|
10
|
+
An explorable essay is an argument the reader takes part in, not a tour of a model's features. Write the argument as a
|
|
11
|
+
`LessonPlan` first: plain JSON that names the one idea, the values the reader holds, and the beats. Check it with
|
|
12
|
+
`validateLessonPlan`, and write components only once it has no errors. Then follow the `write-explainer` skill.
|
|
13
|
+
|
|
14
|
+
The plan is cheap to change. A beat cut here saves a figure, its prose and its states later.
|
|
15
|
+
|
|
16
|
+
## The procedure
|
|
17
|
+
|
|
18
|
+
1. **Find the one idea.** Write the sentence the reader should be able to say afterwards, with its mechanism: "Each step
|
|
19
|
+
multiplies the loss by (1 − 2 × rate)², so it falls for rates under 1 and grows past it." A topic ("learning rates")
|
|
20
|
+
or a list ("rates, momentum and schedules") is not an idea. If the source has three ideas, plan three essays.
|
|
21
|
+
2. **Name the reader.** `audience` says who reads it and what they already know. Every beat builds only on that and on
|
|
22
|
+
the beats before it.
|
|
23
|
+
3. **Choose the params.** A param is a value the reader holds and changes: a number with its range, step and format, a
|
|
24
|
+
choice of two to five options, or a toggle. Keep two to five. Each must change something the reader can see. A value
|
|
25
|
+
the reader only reads is a derived value, not a param.
|
|
26
|
+
4. **Name the derived values.** Each derived value lists the names it `reads` and its `formula` in words. Declare them
|
|
27
|
+
in computing order: a derived value reads params and derived values declared above it.
|
|
28
|
+
5. **Cut the beats.** One beat is one step of the argument: one `goal` sentence the reader can say after it, the
|
|
29
|
+
`misconception` it corrects, and at most one new param. Start concrete: a specific hand of cards, one token, one
|
|
30
|
+
weight. Generalise in a later beat. Add a beat titled "Recap" after every seven.
|
|
31
|
+
6. **Pick one figure per beat by its question.** Write the reader's question first ("How much does each card count
|
|
32
|
+
toward the sum?"), then choose the part whose `question` in `explainerGuide` matches, or a chart from `chartGuide`.
|
|
33
|
+
`shows` lists the params and derived values the figure draws. Never invent a part name.
|
|
34
|
+
7. **Decide where the reader acts.** Put a `predict` ask before a result the reader could guess wrong, in one of the
|
|
35
|
+
first three beats. Put a `challenge` ask after the reader has the tool to reach it. The reader's own action should
|
|
36
|
+
cause each change the beat is about.
|
|
37
|
+
8. **Declare the states worth seeing.** Each beat's `states` set params to show the beat's point. Order them: the first
|
|
38
|
+
state is the beat's opening picture, which the static view prints and the present view opens at each time the
|
|
39
|
+
presenter reaches the beat. The beat sheet draws every state. A beat that introduces a param has a state that moves
|
|
40
|
+
it.
|
|
41
|
+
9. **Validate and fix.** Run the validator below. Fix every error, then read every advice and either follow it or state
|
|
42
|
+
in one sentence why the plan declines it.
|
|
43
|
+
|
|
44
|
+
Read [the plan format](references/plan-format.md) for each field and the validator's messages, and
|
|
45
|
+
[a worked plan](references/worked-plan.md) for a complete plan with the reasons behind each choice.
|
|
46
|
+
|
|
47
|
+
## Check the plan
|
|
48
|
+
|
|
49
|
+
In the essay starter, `src/main.tsx` lists every finding of `plan.json` under the essay as "Lesson checks". From any
|
|
50
|
+
directory where `@mechane-ai/elements` is installed, run the validator in Node:
|
|
51
|
+
|
|
52
|
+
```sh
|
|
53
|
+
node --input-type=module -e "
|
|
54
|
+
import { readFileSync } from 'node:fs';
|
|
55
|
+
import { validateLessonPlan } from '@mechane-ai/elements/lesson/spec';
|
|
56
|
+
const { isValid, findings } = validateLessonPlan(JSON.parse(readFileSync('plan.json', 'utf8')));
|
|
57
|
+
for (const finding of findings) console.log(finding.severity, finding.path, finding.message);
|
|
58
|
+
console.log(isValid ? 'valid' : 'invalid');
|
|
59
|
+
process.exitCode = isValid ? 0 : 1;
|
|
60
|
+
"
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
Each finding has a `severity`, a `path` such as `beats[2].states[0].values.rate`, and a sentence that says what to do.
|
|
64
|
+
An `error` is something `defineLesson` would refuse. An `advice` is teaching practice. The plan is valid when no finding
|
|
65
|
+
is an error.
|
|
66
|
+
|
|
67
|
+
## A good plan
|
|
68
|
+
|
|
69
|
+
- The `idea` is one sentence with a mechanism, and the last beat's `goal` restates it.
|
|
70
|
+
- Every beat has a goal, a figure whose question the goal answers, and a state for each param it introduces.
|
|
71
|
+
- The reader commits to a prediction before the first surprise, and reaches a challenge with their own hands.
|
|
72
|
+
- Every param appears in some figure's `shows` or in a derived value's `reads`.
|
|
73
|
+
- The beats read as a chain: each goal needs the one before it.
|
|
74
|
+
|
|
75
|
+
## Failure modes
|
|
76
|
+
|
|
77
|
+
| The plan | Why it fails | Fix |
|
|
78
|
+
| --------------------------------------------- | --------------------------------------------------- | --------------------------------------------------- |
|
|
79
|
+
| Beats named after parts of a model or a paper | A tour of features has no argument to follow | Rewrite each title as a claim the beat demonstrates |
|
|
80
|
+
| A param no figure shows | The reader moves a control and nothing answers | Add it to a figure's `shows`, or remove it |
|
|
81
|
+
| Three params introduced in the first beat | The reader cannot tell which change did what | One new param per beat |
|
|
82
|
+
| A figure for every paragraph | Each figure costs attention; most repeat the last | One figure per beat; reuse it across states |
|
|
83
|
+
| No `predict` in the first three beats | The reader watches instead of thinking | Ask before the first result they could get wrong |
|
|
84
|
+
| An abstract first beat: "Let x be an input" | Nothing to hold on to | Start with one concrete case, then generalise |
|
|
85
|
+
| States that set derived values | Derived values follow the params; the plan is wrong | Set the params that produce the value |
|
|
86
|
+
| Synthetic numbers presented as measurements | The reader trusts a fiction | Say "synthetic" in the audience-facing text |
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
# The plan format
|
|
2
|
+
|
|
3
|
+
`LessonPlan` is exported as a type from `@mechane-ai/elements/lesson/spec`. A plan is plain JSON, so a model can write
|
|
4
|
+
it and `validateLessonPlan(input: unknown)` can check it. Its params and beats are the shapes `defineLesson` takes.
|
|
5
|
+
|
|
6
|
+
## Fields
|
|
7
|
+
|
|
8
|
+
| Field | Holds |
|
|
9
|
+
| ---------- | ---------------------------------------------------------------------------------------------------- |
|
|
10
|
+
| `id` | The lesson id, such as `"card-neuron"`. It names the lesson in the agent bridge and in storage keys. |
|
|
11
|
+
| `title` | The essay's title, a claim rather than a topic where possible. |
|
|
12
|
+
| `audience` | Who reads it and what they already know. |
|
|
13
|
+
| `idea` | The one sentence the reader should leave with. |
|
|
14
|
+
| `params` | Values the reader changes, by name. |
|
|
15
|
+
| `derived` | Values computed from the params, by name, in computing order. Optional. |
|
|
16
|
+
| `beats` | The steps of the argument, in reading order. At least one. |
|
|
17
|
+
|
|
18
|
+
A param is one of three kinds:
|
|
19
|
+
|
|
20
|
+
```json
|
|
21
|
+
{
|
|
22
|
+
"rate": {
|
|
23
|
+
"kind": "number",
|
|
24
|
+
"label": "Learning rate",
|
|
25
|
+
"value": 0.1,
|
|
26
|
+
"min": 0.05,
|
|
27
|
+
"max": 1.2,
|
|
28
|
+
"step": 0.05,
|
|
29
|
+
"format": { "maximumFractionDigits": 2 }
|
|
30
|
+
},
|
|
31
|
+
"token": {
|
|
32
|
+
"kind": "choice",
|
|
33
|
+
"label": "Followed token",
|
|
34
|
+
"value": "cat",
|
|
35
|
+
"options": [
|
|
36
|
+
{ "id": "cat", "label": "cat" },
|
|
37
|
+
{ "id": "dog", "label": "dog" }
|
|
38
|
+
]
|
|
39
|
+
},
|
|
40
|
+
"isMasked": { "kind": "toggle", "label": "Causal mask", "value": false }
|
|
41
|
+
}
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
- `value` is the opening value. It must lie in the range or be one of the option ids.
|
|
45
|
+
- `format` is `Intl.NumberFormat` options. Use `{ "style": "percent" }` for shares, and
|
|
46
|
+
`{ "style": "unit", "unit": "bit" }` for units `Intl` knows.
|
|
47
|
+
- `scale: "log"` gives each tenfold the same drag distance. It needs `min` above zero.
|
|
48
|
+
- Name a toggle as a question that is true or false: `isMasked`, `hasBias`.
|
|
49
|
+
|
|
50
|
+
A derived value names what it reads and its formula in words. The code comes later, in `defineLesson`:
|
|
51
|
+
|
|
52
|
+
```json
|
|
53
|
+
{
|
|
54
|
+
"sum": {
|
|
55
|
+
"label": "Weighted sum",
|
|
56
|
+
"format": { "maximumFractionDigits": 1 },
|
|
57
|
+
"reads": ["hand", "heartWeight", "spadeWeight", "bias"],
|
|
58
|
+
"formula": "heart rank × heart weight + spade rank × spade weight + bias"
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
A beat is a `LessonBeat` with two planning fields:
|
|
64
|
+
|
|
65
|
+
| Field | Holds |
|
|
66
|
+
| --------------- | ------------------------------------------------------------------------------------------------------ |
|
|
67
|
+
| `id`, `title` | The beat's id, used by `<Beat id>`, and its heading. |
|
|
68
|
+
| `goal` | One sentence the reader can say after the beat. A tutor reads it; the reader never sees it. |
|
|
69
|
+
| `misconception` | The wrong belief the beat corrects. Tutor note. |
|
|
70
|
+
| `hints` | Sentences a tutor or a `Challenge` gives, in order. Tutor note. |
|
|
71
|
+
| `steps` | Reveal steps after the first view, for the present view. Defaults to 0. |
|
|
72
|
+
| `states` | `{ id, label, values }` each. `values` set params only. The first opens the static and present views. |
|
|
73
|
+
| `figure` | `{ part, question, shows? }`: a part from `explainerParts` or a chart name, and the reader's question. |
|
|
74
|
+
| `ask` | `{ kind: "predict" \| "challenge", prompt }`. |
|
|
75
|
+
|
|
76
|
+
Read the parts and their questions from Node:
|
|
77
|
+
|
|
78
|
+
```sh
|
|
79
|
+
node --input-type=module -e "
|
|
80
|
+
import { explainerGuide } from '@mechane-ai/elements/lesson/spec';
|
|
81
|
+
for (const entry of explainerGuide) console.log(entry.part + ': ' + entry.question);
|
|
82
|
+
"
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
Charts are listed with their questions in `chartGuide` from `@mechane-ai/elements/charts/figure`. A beat's figure is a
|
|
86
|
+
chart when the picture is data on axes, and a scene part when it is things and their connections.
|
|
87
|
+
|
|
88
|
+
## What the validator says
|
|
89
|
+
|
|
90
|
+
These are real messages for a plan that has the common mistakes:
|
|
91
|
+
|
|
92
|
+
```text
|
|
93
|
+
error params.temperature.min - A log scale needs min above zero. Use a linear scale, or start at a small positive value.
|
|
94
|
+
error derived.weights.reads - "weights" reads "scores", which is declared after it. defineLesson computes in order, so move "scores" above it.
|
|
95
|
+
error beats[0].figure.part - "AttentionDiagram" is not a teaching part or a chart. Choose a part from explainerGuide or a chart from chartGuide.
|
|
96
|
+
error beats[1].states[0].values.weights - "weights" is a derived value; a state sets params only, and the derived values follow.
|
|
97
|
+
error beats[2].figure.shows - "mask" is not a param or a derived value.
|
|
98
|
+
advice beats[0].goal - Beat "overview" has no goal. Add one sentence the reader should be able to say after it.
|
|
99
|
+
advice beats[0].states - Beat "overview" introduces 3 new params (temperature, heads, isMasked). Introduce one per beat, so the reader can tell what each one does.
|
|
100
|
+
advice beats - None of the first three beats asks for a prediction or a challenge. Add a Predict early, so the reader commits to a guess.
|
|
101
|
+
advice beats[1].figure - This beat shows no figure. Give it one, or fold its prose into the beat before.
|
|
102
|
+
advice derived.weights - No figure shows "weights" and no value reads it. List it in a figure's shows, or remove it.
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
The advice also names a param that no state moves, and a run of more than seven beats with no beat titled "Recap".
|
|
106
|
+
|
|
107
|
+
## From the plan to the lesson
|
|
108
|
+
|
|
109
|
+
Copy `params` and each beat's `id`, `title`, `goal`, `misconception`, `hints`, `steps` and `states` into `defineLesson`
|
|
110
|
+
as TypeScript literals. Leave `figure` and `ask` in the plan: they become `<Figure>`, `Predict` and `Challenge` in the
|
|
111
|
+
essay. Write each derived value's `from` as a pure function of the names in its `reads`. Do not import `plan.json` into
|
|
112
|
+
`defineLesson`: JSON widens `"kind": "number"` to a string, and the lesson loses its types.
|
|
113
|
+
|
|
114
|
+
Keep `plan.json` beside the essay. When the argument changes, change the plan first and run the validator again.
|
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
# A worked plan
|
|
2
|
+
|
|
3
|
+
The plan for an essay told with playing cards: one artificial neuron as a weighted vote over two cards. It passes
|
|
4
|
+
`validateLessonPlan` with no findings. The `write-explainer` skill builds the same essay from it, in
|
|
5
|
+
[its worked essay](../../write-explainer/references/worked-essay.md).
|
|
6
|
+
|
|
7
|
+
```json
|
|
8
|
+
{
|
|
9
|
+
"id": "card-neuron",
|
|
10
|
+
"title": "A neuron is a weighted vote",
|
|
11
|
+
"audience": "Readers who can add and multiply and have heard that networks have weights, but have never watched one decide.",
|
|
12
|
+
"idea": "A neuron multiplies each input by a weight, adds the products and a bias, and says yes when the total is above zero; learning moves the weights.",
|
|
13
|
+
"params": {
|
|
14
|
+
"hand": {
|
|
15
|
+
"kind": "choice",
|
|
16
|
+
"label": "Hand dealt",
|
|
17
|
+
"value": "queen-seven",
|
|
18
|
+
"options": [
|
|
19
|
+
{ "id": "queen-seven", "label": "Queen of Hearts, Seven of Spades" },
|
|
20
|
+
{ "id": "two-king", "label": "Two of Hearts, King of Spades" }
|
|
21
|
+
]
|
|
22
|
+
},
|
|
23
|
+
"heartWeight": {
|
|
24
|
+
"kind": "number",
|
|
25
|
+
"label": "Weight on the heart card",
|
|
26
|
+
"value": 0.5,
|
|
27
|
+
"min": -1,
|
|
28
|
+
"max": 1,
|
|
29
|
+
"step": 0.1,
|
|
30
|
+
"format": { "maximumFractionDigits": 1 }
|
|
31
|
+
},
|
|
32
|
+
"spadeWeight": {
|
|
33
|
+
"kind": "number",
|
|
34
|
+
"label": "Weight on the spade card",
|
|
35
|
+
"value": 0.5,
|
|
36
|
+
"min": -1,
|
|
37
|
+
"max": 1,
|
|
38
|
+
"step": 0.1,
|
|
39
|
+
"format": { "maximumFractionDigits": 1 }
|
|
40
|
+
},
|
|
41
|
+
"bias": {
|
|
42
|
+
"kind": "number",
|
|
43
|
+
"label": "Bias",
|
|
44
|
+
"value": 0,
|
|
45
|
+
"min": -10,
|
|
46
|
+
"max": 10,
|
|
47
|
+
"step": 0.5,
|
|
48
|
+
"format": { "maximumFractionDigits": 1 }
|
|
49
|
+
}
|
|
50
|
+
},
|
|
51
|
+
"derived": {
|
|
52
|
+
"sum": {
|
|
53
|
+
"label": "Weighted sum",
|
|
54
|
+
"format": { "maximumFractionDigits": 1 },
|
|
55
|
+
"reads": ["hand", "heartWeight", "spadeWeight", "bias"],
|
|
56
|
+
"formula": "heart rank × heart weight + spade rank × spade weight + bias"
|
|
57
|
+
},
|
|
58
|
+
"yes": {
|
|
59
|
+
"label": "Chance the neuron says yes",
|
|
60
|
+
"format": { "style": "percent", "maximumFractionDigits": 0 },
|
|
61
|
+
"reads": ["sum"],
|
|
62
|
+
"formula": "the sigmoid of the weighted sum"
|
|
63
|
+
}
|
|
64
|
+
},
|
|
65
|
+
"beats": [
|
|
66
|
+
{
|
|
67
|
+
"id": "hand",
|
|
68
|
+
"title": "Two cards, two numbers",
|
|
69
|
+
"goal": "Read each card as a number, its rank: an ace is 1, a queen 12, a king 13.",
|
|
70
|
+
"misconception": "That the suit changes the number; the suit only says which input the card is.",
|
|
71
|
+
"states": [
|
|
72
|
+
{ "id": "queen-seven", "label": "Queen and seven", "values": { "hand": "queen-seven" } },
|
|
73
|
+
{ "id": "two-king", "label": "Two and king", "values": { "hand": "two-king" } }
|
|
74
|
+
],
|
|
75
|
+
"figure": { "part": "SceneStack", "question": "Which two numbers go into the neuron?", "shows": ["hand"] },
|
|
76
|
+
"ask": { "kind": "predict", "prompt": "Which hand adds up to more, before any weights?" }
|
|
77
|
+
},
|
|
78
|
+
{
|
|
79
|
+
"id": "weights",
|
|
80
|
+
"title": "Each card gets a weight",
|
|
81
|
+
"goal": "See that a weight scales its card: at 0.5 the queen counts as 6, and below zero it counts against.",
|
|
82
|
+
"misconception": "That a weight is the card's value; it is how much the value counts.",
|
|
83
|
+
"hints": ["Drag the heart weight below zero and watch the wire turn."],
|
|
84
|
+
"states": [
|
|
85
|
+
{ "id": "even", "label": "Both weights 0.5", "values": { "heartWeight": 0.5 } },
|
|
86
|
+
{ "id": "against", "label": "Hearts count against", "values": { "heartWeight": -0.5 } }
|
|
87
|
+
],
|
|
88
|
+
"figure": {
|
|
89
|
+
"part": "Scene",
|
|
90
|
+
"question": "How much does each card count toward the sum?",
|
|
91
|
+
"shows": ["heartWeight", "sum"]
|
|
92
|
+
},
|
|
93
|
+
"ask": { "kind": "predict", "prompt": "Make the heart weight −0.5. Does the weighted sum rise or fall?" }
|
|
94
|
+
},
|
|
95
|
+
{
|
|
96
|
+
"id": "sum",
|
|
97
|
+
"title": "The neuron adds the votes",
|
|
98
|
+
"goal": "Compute the weighted sum of one hand by hand, then check it against the figure.",
|
|
99
|
+
"states": [
|
|
100
|
+
{ "id": "balanced", "label": "Spade weight 0.5", "values": { "spadeWeight": 0.5 } },
|
|
101
|
+
{ "id": "spade-heavy", "label": "Spade weight 1", "values": { "spadeWeight": 1 } }
|
|
102
|
+
],
|
|
103
|
+
"figure": {
|
|
104
|
+
"part": "LessonFlow",
|
|
105
|
+
"question": "How is the sum computed from the cards and the weights?",
|
|
106
|
+
"shows": ["sum", "spadeWeight"]
|
|
107
|
+
}
|
|
108
|
+
},
|
|
109
|
+
{
|
|
110
|
+
"id": "bias",
|
|
111
|
+
"title": "The bias sets the bar",
|
|
112
|
+
"goal": "Connect a negative bias with a neuron that needs stronger evidence before it says yes.",
|
|
113
|
+
"misconception": "That the bias is one more card; it is added whatever the hand.",
|
|
114
|
+
"hints": ["At a bias of −8 the cards must add about 10 more.", "Raise the weight on the queen."],
|
|
115
|
+
"states": [
|
|
116
|
+
{ "id": "no-bias", "label": "No bias", "values": { "bias": 0 } },
|
|
117
|
+
{ "id": "skeptic", "label": "Bias −8", "values": { "bias": -8 } }
|
|
118
|
+
],
|
|
119
|
+
"figure": { "part": "SceneCurve", "question": "How sure is the neuron at this sum?", "shows": ["sum", "yes"] },
|
|
120
|
+
"ask": {
|
|
121
|
+
"kind": "challenge",
|
|
122
|
+
"prompt": "With a bias of −8, make the neuron at least 90% sure for the queen and seven."
|
|
123
|
+
}
|
|
124
|
+
},
|
|
125
|
+
{
|
|
126
|
+
"id": "learning",
|
|
127
|
+
"title": "Learning moves the weights",
|
|
128
|
+
"goal": "See that training changes only the weights and the bias, never the cards.",
|
|
129
|
+
"states": [
|
|
130
|
+
{
|
|
131
|
+
"id": "before",
|
|
132
|
+
"label": "Before training",
|
|
133
|
+
"values": { "heartWeight": -0.5, "spadeWeight": 0.5, "bias": 0 }
|
|
134
|
+
},
|
|
135
|
+
{ "id": "after", "label": "After training", "values": { "heartWeight": 0.8, "spadeWeight": -0.2, "bias": -4 } }
|
|
136
|
+
],
|
|
137
|
+
"figure": {
|
|
138
|
+
"part": "SceneCells",
|
|
139
|
+
"question": "Which weights did training change, and by how much?",
|
|
140
|
+
"shows": ["heartWeight", "spadeWeight", "bias"]
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
]
|
|
144
|
+
}
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
## Why each choice
|
|
148
|
+
|
|
149
|
+
- **The idea has a mechanism.** "Multiplies, adds, says yes above zero; learning moves the weights" can be checked
|
|
150
|
+
against every figure. "How neurons work" could not.
|
|
151
|
+
- **Concrete first.** Beat 1 is two specific cards, read as two numbers. Weights, sums and the sigmoid come after the
|
|
152
|
+
reader holds those numbers.
|
|
153
|
+
- **One new param per beat.** `hand`, then `heartWeight`, then `spadeWeight`, then `bias`. The last beat moves only
|
|
154
|
+
params the reader already knows, so it can move several at once.
|
|
155
|
+
- **Each figure answers its beat's question.** The hand is cards in a deck and a row (`SceneStack`). The vote is wires
|
|
156
|
+
whose thickness is the weight (`Scene` with `SceneWire`). The sum is the lesson's own derivation (`LessonFlow`). The
|
|
157
|
+
confidence is a function of the sum (`SceneCurve`). Training is three numbers (`SceneCells`).
|
|
158
|
+
- **The same card is the same object.** `queen-hearts` is one id in the hand, the vote and the prose, so a `Term` on
|
|
159
|
+
"Queen of Hearts" lights it in every figure.
|
|
160
|
+
- **Predict early, challenge late.** Beat 1 asks which hand is larger before any weight exists, because readers expect
|
|
161
|
+
the king to win. Beat 4 asks the reader to beat a skeptical bias, once they hold every control that can.
|
|
162
|
+
- **States show the point.** Each beat's states differ in exactly the param the beat introduces, so the beat sheet shows
|
|
163
|
+
the cause and its effect side by side.
|
|
164
|
+
- **Misconceptions are specific.** "That a weight is the card's value" names a belief a tutor can test with one
|
|
165
|
+
question.
|
|
166
|
+
|
|
167
|
+
## What the first draft got wrong
|
|
168
|
+
|
|
169
|
+
The first draft had one beat, "The neuron", with all four params, a `SceneNode` per input and no ask. The validator said
|
|
170
|
+
the beat introduced four params and that no early beat asked anything. Splitting it gave four beats with one new param
|
|
171
|
+
each, and the reader now has a reason to touch each control.
|
|
@@ -9,7 +9,8 @@ description:
|
|
|
9
9
|
# Review an Elements page
|
|
10
10
|
|
|
11
11
|
Run the page in a browser and use it. A passing type check says nothing about focus, loading or layout. Report what you
|
|
12
|
-
checked, what failed and what you could not check.
|
|
12
|
+
checked, what failed and what you could not check. For an explorable essay built with the teaching layers, also follow
|
|
13
|
+
the `review-explainer` skill, which checks whether it teaches.
|
|
13
14
|
|
|
14
15
|
## 1. Keyboard alone
|
|
15
16
|
|
|
@@ -46,7 +47,8 @@ Check 360 pixels wide, a tablet width and a wide desktop.
|
|
|
46
47
|
|
|
47
48
|
- Switch to the dark theme and open every menu, dialog, popover and tooltip. A portaled panel in the wrong theme means
|
|
48
49
|
the theme is not on the document root.
|
|
49
|
-
- Turn on reduced motion. Fades and slides stop, and nothing waits for an animation to finish.
|
|
50
|
+
- Turn on reduced motion. Fades and slides stop, and nothing waits for an animation to finish. A scene lands on its new
|
|
51
|
+
state at once and a `Playback` jumps to its end.
|
|
50
52
|
|
|
51
53
|
## 5. Honest content
|
|
52
54
|
|