@mechane-ai/elements 0.46.0 → 0.48.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 +590 -34
- package/bin/mechane-elements-catalog.mjs +104 -12
- package/dist/ai.js +4 -4
- package/dist/article-BXZr10QQ.js +1904 -0
- package/dist/article.js +1 -0
- package/dist/catalog.json +3696 -33
- package/dist/categorical-values-BpVq8cFj.js +107 -0
- package/dist/cells-xVmnQ9oQ.js +384 -0
- package/dist/chart-link-AE_xuxiP.js +35 -0
- package/dist/chart-tones-ei3BC2AL.js +27 -0
- package/dist/charts/cartesian.js +1 -2958
- package/dist/charts/cells.js +1 -0
- package/dist/charts/comparison.js +1 -0
- package/dist/charts/distribution.js +1 -781
- package/dist/charts/figure.js +3404 -0
- package/dist/charts/graph.js +1 -655
- package/dist/charts/hierarchy.js +1 -121
- package/dist/charts/image.js +1 -0
- package/dist/charts/matrix.js +4 -644
- package/dist/charts/plot.js +15 -0
- package/dist/charts/relationship.js +1 -0
- package/dist/charts/text.js +1 -0
- package/dist/charts/timeline.js +1 -266
- package/dist/charts/transforms.js +677 -0
- package/dist/charts/trend.js +1 -0
- package/dist/charts.js +8 -3
- package/dist/clock-DSm5lkNE.js +16 -0
- package/dist/collections.js +1 -2195
- package/dist/color-legend-CIo7DhXB.js +62 -0
- package/dist/dates-Cww8UR_n.js +810 -0
- package/dist/describe-lesson-BmREzDpt.js +175 -0
- package/dist/dumbbell-plot-DQdTxDeO.js +509 -0
- package/dist/embedding-map-CF-J-8JW.js +1929 -0
- package/dist/feedback.js +1 -1
- package/dist/figure-format-B8kRZMlo.js +36 -0
- package/dist/figure-frame-BJ3REgTA.js +270 -0
- package/dist/forms/dates.js +1 -810
- package/dist/forms.js +1 -1
- package/dist/heatmap-scale-Zte6Ya-g.js +20 -0
- package/dist/image-grid-Dl2sjIMB.js +598 -0
- package/dist/kits/evaluation.js +431 -0
- package/dist/kits/interpretability.js +1033 -0
- package/dist/kits/operations.js +239 -0
- package/dist/kits/training.js +335 -0
- package/dist/label-place-Z0fryBZb.js +42 -0
- package/dist/lesson/agent.js +811 -0
- package/dist/lesson/spec.js +661 -0
- package/dist/lesson.js +5 -0
- package/dist/locate-Bcg3QcP4.js +11 -0
- package/dist/mdx.js +227 -0
- package/dist/packages/charts/src/cartesian/bar-chart.d.ts +40 -21
- package/dist/packages/charts/src/cartesian/bar-data.d.ts +15 -4
- package/dist/packages/charts/src/cartesian/bar-overlays.d.ts +7 -3
- package/dist/packages/charts/src/cartesian/breakdown-bar.d.ts +10 -8
- package/dist/packages/charts/src/cartesian/bridge-chart.d.ts +20 -16
- package/dist/packages/charts/src/cartesian/bridge-data.d.ts +5 -4
- package/dist/packages/charts/src/cartesian/composition-bars.d.ts +8 -4
- package/dist/packages/charts/src/cartesian/index.d.ts +5 -5
- package/dist/packages/charts/src/cartesian/reference-lines.d.ts +25 -18
- package/dist/packages/charts/src/cartesian/scatter-plot.d.ts +30 -25
- package/dist/packages/charts/src/cartesian/sparkline.d.ts +14 -2
- package/dist/packages/charts/src/cartesian/time-series-bands.d.ts +3 -2
- package/dist/packages/charts/src/cartesian/time-series-data.d.ts +12 -2
- package/dist/packages/charts/src/cartesian/time-series-line.d.ts +2 -2
- package/dist/packages/charts/src/cartesian/time-series-overlays.d.ts +6 -4
- package/dist/packages/charts/src/cartesian/time-series.d.ts +60 -36
- package/dist/packages/charts/src/cartesian/value-labels.d.ts +22 -0
- package/dist/packages/charts/src/categorical-values.d.ts +1 -1
- package/dist/packages/charts/src/cells/bar-cell.d.ts +13 -0
- package/dist/packages/charts/src/cells/cell-layout.d.ts +81 -0
- package/dist/packages/charts/src/cells/change-cell.d.ts +17 -0
- package/dist/packages/charts/src/cells/heat-cell.d.ts +19 -0
- package/dist/packages/charts/src/cells/index.d.ts +11 -0
- package/dist/packages/charts/src/cells/interval-cell.d.ts +16 -0
- package/dist/packages/charts/src/cells/spark-cell.d.ts +22 -0
- package/dist/packages/charts/src/chart-frame.d.ts +14 -7
- package/dist/packages/charts/src/chart-grid.d.ts +19 -0
- package/dist/packages/charts/src/chart-input.d.ts +1 -9
- package/dist/packages/charts/src/chart-link.d.ts +56 -0
- package/dist/packages/charts/src/chart.d.ts +0 -8
- package/dist/packages/charts/src/comparison/bullet-bar.d.ts +34 -0
- package/dist/packages/charts/src/comparison/comparison-plot.d.ts +54 -0
- package/dist/packages/charts/src/comparison/dot-plot.d.ts +41 -0
- package/dist/packages/charts/src/comparison/dumbbell-plot.d.ts +33 -0
- package/dist/packages/charts/src/comparison/index.d.ts +6 -0
- package/dist/packages/charts/src/distribution/box-plot.d.ts +40 -0
- package/dist/packages/charts/src/distribution/distribution-input.d.ts +5 -3
- package/dist/packages/charts/src/distribution/distribution-plot.d.ts +28 -161
- package/dist/packages/charts/src/distribution/ecdf.d.ts +16 -15
- package/dist/packages/charts/src/distribution/group-plot-input.d.ts +35 -0
- package/dist/packages/charts/src/distribution/group-plot-layout.d.ts +79 -0
- package/dist/packages/charts/src/distribution/group-plot.d.ts +73 -0
- package/dist/packages/charts/src/distribution/histogram.d.ts +16 -16
- package/dist/packages/charts/src/distribution/index.d.ts +11 -0
- package/dist/packages/charts/src/distribution/interval-plot.d.ts +16 -13
- package/dist/packages/charts/src/distribution/ranked-bars.d.ts +17 -14
- package/dist/packages/charts/src/distribution/ridgeline.d.ts +34 -0
- package/dist/packages/charts/src/distribution/strip-plot.d.ts +37 -0
- package/dist/packages/charts/src/distribution/violin-plot.d.ts +34 -0
- package/dist/packages/charts/src/figure/figure-format.d.ts +34 -0
- package/dist/packages/charts/src/figure/figure-frame.d.ts +47 -0
- package/dist/packages/charts/src/figure/figure-props.d.ts +54 -0
- package/dist/packages/charts/src/figure/tone-scope.d.ts +32 -0
- package/dist/packages/charts/src/graph/attribution-graph.d.ts +62 -0
- package/dist/packages/charts/src/graph/attribution-layout.d.ts +88 -0
- package/dist/packages/charts/src/graph/flow-diagram.d.ts +14 -15
- package/dist/packages/charts/src/graph/flow-layout.d.ts +4 -2
- package/dist/packages/charts/src/graph/graph-canvas.d.ts +33 -0
- package/dist/packages/charts/src/graph/index.d.ts +6 -2
- package/dist/packages/charts/src/graph/relation-graph.d.ts +24 -13
- package/dist/packages/charts/src/graph/tree-diagram.d.ts +41 -0
- package/dist/packages/charts/src/graph/tree-layout.d.ts +71 -0
- package/dist/packages/charts/src/hierarchy/area-mark.d.ts +17 -0
- package/dist/packages/charts/src/hierarchy/icicle.d.ts +35 -0
- package/dist/packages/charts/src/hierarchy/index.d.ts +2 -0
- package/dist/packages/charts/src/hierarchy/partition-layout.d.ts +25 -0
- package/dist/packages/charts/src/hierarchy/treemap-layout.d.ts +26 -0
- package/dist/packages/charts/src/hierarchy/treemap.d.ts +11 -9
- package/dist/packages/charts/src/image/attribution-legend.d.ts +13 -0
- package/dist/packages/charts/src/image/attribution-overlay.d.ts +50 -0
- package/dist/packages/charts/src/image/attribution-ramp.d.ts +16 -0
- package/dist/packages/charts/src/image/image-atlas.d.ts +37 -0
- package/dist/packages/charts/src/image/image-fill.d.ts +9 -0
- package/dist/packages/charts/src/image/image-grid.d.ts +26 -0
- package/dist/packages/charts/src/image/image-input.d.ts +27 -0
- package/dist/packages/charts/src/image/image-tile.d.ts +27 -0
- package/dist/packages/charts/src/image/index.d.ts +7 -0
- package/dist/packages/charts/src/index.d.ts +15 -1
- package/dist/packages/charts/src/matrix/attention-matrix.d.ts +41 -0
- package/dist/packages/charts/src/matrix/calendar-heatmap.d.ts +37 -0
- package/dist/packages/charts/src/matrix/color-legend.d.ts +9 -2
- package/dist/packages/charts/src/matrix/confusion-matrix.d.ts +36 -0
- package/dist/packages/charts/src/matrix/correlation-matrix.d.ts +34 -0
- package/dist/packages/charts/src/matrix/heatmap-scale.d.ts +8 -2
- package/dist/packages/charts/src/matrix/index.d.ts +15 -3
- package/dist/packages/charts/src/matrix/matrix-cells.d.ts +27 -3
- package/dist/packages/charts/src/matrix/matrix-figure.d.ts +50 -0
- package/dist/packages/charts/src/matrix/matrix-mark.d.ts +34 -0
- package/dist/packages/charts/src/matrix/matrix-presets.d.ts +20 -0
- package/dist/packages/charts/src/matrix/matrix-range.d.ts +45 -0
- package/dist/packages/charts/src/matrix/matrix-strip.d.ts +13 -14
- package/dist/packages/charts/src/matrix/matrix-types.d.ts +40 -0
- package/dist/packages/charts/src/matrix/matrix.d.ts +13 -11
- package/dist/packages/charts/src/matrix/token-heatmap.d.ts +16 -10
- package/dist/packages/charts/src/plot/contours.d.ts +45 -0
- package/dist/packages/charts/src/plot/index.d.ts +49 -0
- package/dist/packages/charts/src/plot/label-place.d.ts +35 -0
- package/dist/packages/charts/src/plot/locate.d.ts +18 -0
- package/dist/packages/charts/src/plot/path.d.ts +39 -0
- package/dist/packages/charts/src/plot/plot-axes.d.ts +20 -0
- package/dist/packages/charts/src/plot/plot-layout.d.ts +221 -0
- package/dist/packages/charts/src/plot/plot-marks.d.ts +128 -0
- package/dist/packages/charts/src/plot/plot-surface.d.ts +32 -0
- package/dist/packages/charts/src/plot/render/density-layer.d.ts +17 -0
- package/dist/packages/charts/src/plot/render/hit-index.d.ts +37 -0
- package/dist/packages/charts/src/plot/render/plot-viewport.d.ts +39 -0
- package/dist/packages/charts/src/plot/render/point-layer.d.ts +41 -0
- package/dist/packages/charts/src/plot/render/theme-colors.d.ts +15 -0
- package/dist/packages/charts/src/plot/scale.d.ts +48 -0
- package/dist/packages/charts/src/plot/ticks.d.ts +34 -0
- package/dist/packages/charts/src/plot-width.d.ts +3 -2
- package/dist/packages/charts/src/relationship/contour-plot.d.ts +61 -0
- package/dist/packages/charts/src/relationship/density-map.d.ts +45 -0
- package/dist/packages/charts/src/relationship/embedding-map.d.ts +75 -0
- package/dist/packages/charts/src/relationship/index.d.ts +11 -0
- package/dist/packages/charts/src/relationship/level-legend.d.ts +11 -0
- package/dist/packages/charts/src/relationship/measures.d.ts +85 -0
- package/dist/packages/charts/src/relationship/parallel-coordinates.d.ts +30 -0
- package/dist/packages/charts/src/relationship/range-controls.d.ts +20 -0
- package/dist/packages/charts/src/relationship/scatter-matrix.d.ts +20 -0
- package/dist/packages/charts/src/spec/chart-guide.d.ts +21 -0
- package/dist/packages/charts/src/spec/figure-registry.d.ts +44 -0
- package/dist/packages/charts/src/spec/figure-spec.d.ts +147 -0
- package/dist/packages/charts/src/spec/figure-text.d.ts +8 -0
- package/dist/packages/charts/src/spec/figure.d.ts +12 -0
- package/dist/packages/charts/src/spec/guide-data.d.ts +85 -0
- package/dist/packages/charts/src/spec/index.d.ts +10 -0
- package/dist/packages/charts/src/spec/validate-figure.d.ts +15 -0
- package/dist/packages/charts/src/text/index.d.ts +11 -0
- package/dist/packages/charts/src/text/token-examples.d.ts +42 -0
- package/dist/packages/charts/src/text/token-grid.d.ts +47 -0
- package/dist/packages/charts/src/text/token-links.d.ts +49 -0
- package/dist/packages/charts/src/text/token-predictions.d.ts +38 -0
- package/dist/packages/charts/src/text/token-scale.d.ts +20 -0
- package/dist/packages/charts/src/text/token-text.d.ts +39 -0
- package/dist/packages/charts/src/timeline/event-strip.d.ts +70 -0
- package/dist/packages/charts/src/timeline/index.d.ts +3 -1
- package/dist/packages/charts/src/timeline/waterfall.d.ts +24 -13
- package/dist/packages/charts/src/transforms/bins.d.ts +91 -0
- package/dist/packages/charts/src/transforms/density.d.ts +53 -0
- package/dist/packages/charts/src/transforms/fits.d.ts +50 -0
- package/dist/packages/charts/src/transforms/index.d.ts +19 -0
- package/dist/packages/charts/src/transforms/matrices.d.ts +49 -0
- package/dist/packages/charts/src/transforms/quantiles.d.ts +96 -0
- package/dist/packages/charts/src/transforms/ranks.d.ts +44 -0
- package/dist/packages/charts/src/transforms/runs.d.ts +47 -0
- package/dist/packages/charts/src/transforms/sampling.d.ts +75 -0
- package/dist/packages/charts/src/transforms/smoothing.d.ts +41 -0
- package/dist/packages/charts/src/transforms/values.d.ts +70 -0
- package/dist/packages/charts/src/trend/bump-chart.d.ts +33 -0
- package/dist/packages/charts/src/trend/column-figure.d.ts +38 -0
- package/dist/packages/charts/src/trend/column-positions.d.ts +21 -0
- package/dist/packages/charts/src/trend/curve-chart.d.ts +69 -0
- package/dist/packages/charts/src/trend/end-labels.d.ts +40 -0
- package/dist/packages/charts/src/trend/horizon-chart.d.ts +37 -0
- package/dist/packages/charts/src/trend/index.d.ts +10 -0
- package/dist/packages/charts/src/trend/line-locate.d.ts +21 -0
- package/dist/packages/charts/src/trend/runs-chart.d.ts +50 -0
- package/dist/packages/charts/src/trend/slope-chart.d.ts +35 -0
- package/dist/packages/kits/src/evaluation/evaluation-data.d.ts +31 -0
- package/dist/packages/kits/src/evaluation/index.d.ts +8 -0
- package/dist/packages/kits/src/evaluation/leaderboard-cells.d.ts +62 -0
- package/dist/packages/kits/src/evaluation/leaderboard.d.ts +59 -0
- package/dist/packages/kits/src/evaluation/model-comparison.d.ts +59 -0
- package/dist/packages/kits/src/evaluation/score-breakdown.d.ts +33 -0
- package/dist/packages/kits/src/interpretability/attention-head-grid.d.ts +56 -0
- package/dist/packages/kits/src/interpretability/attribution-workbench.d.ts +29 -0
- package/dist/packages/kits/src/interpretability/embedding-atlas.d.ts +41 -0
- package/dist/packages/kits/src/interpretability/feature-card.d.ts +33 -0
- package/dist/packages/kits/src/interpretability/feature-list.d.ts +51 -0
- package/dist/packages/kits/src/interpretability/feature-logits.d.ts +23 -0
- package/dist/packages/kits/src/interpretability/features.d.ts +70 -0
- package/dist/packages/kits/src/interpretability/index.d.ts +16 -0
- package/dist/packages/kits/src/interpretability/kit-styles.d.ts +118 -0
- package/dist/packages/kits/src/interpretability/logit-lens.d.ts +50 -0
- package/dist/packages/kits/src/interpretability/node-panel.d.ts +32 -0
- package/dist/packages/kits/src/interpretability/shared-link.d.ts +8 -0
- package/dist/packages/kits/src/interpretability/steering-panel.d.ts +52 -0
- package/dist/packages/kits/src/operations/budget-board.d.ts +49 -0
- package/dist/packages/kits/src/operations/incident-timeline.d.ts +30 -0
- package/dist/packages/kits/src/operations/index.d.ts +6 -0
- package/dist/packages/kits/src/operations/service-health.d.ts +66 -0
- package/dist/packages/kits/src/training/index.d.ts +8 -0
- package/dist/packages/kits/src/training/run-dashboard.d.ts +49 -0
- package/dist/packages/kits/src/training/run-legend.d.ts +21 -0
- package/dist/packages/kits/src/training/run-marker.d.ts +5 -0
- package/dist/packages/kits/src/training/run-state.d.ts +7 -0
- package/dist/packages/kits/src/training/run-table.d.ts +63 -0
- package/dist/packages/kits/src/training/runs-overview.d.ts +20 -0
- package/dist/packages/kits/src/training/runs.d.ts +34 -0
- 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/linked-target.d.ts +22 -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/teaching/src/article/term.d.ts +35 -0
- 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/bound-value.d.ts +29 -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-CqKUTHaO.js +450 -0
- package/dist/path-BglsXpnO.js +59 -0
- package/dist/plot-axes-DJkLW4wk.js +100 -0
- package/dist/plot-layout-CZVSJ-le.js +912 -0
- package/dist/plot-marks-uozcbOIX.js +229 -0
- package/dist/plot-surface-CbVBvgqZ.js +51 -0
- package/dist/plot-width-DcqtSgzb.js +124 -0
- package/dist/point-layer-C-EYETAt.js +655 -0
- package/dist/reference-lines-BDcttOp0.js +82 -0
- package/dist/scale-C2xgZyZN.js +63 -0
- package/dist/scene-0z2gbaDE.js +4938 -0
- package/dist/scene.js +1 -0
- package/dist/slope-chart-BKVEAVCs.js +1279 -0
- package/dist/{src-1EHkSFS-.js → src-BD6xlvDt.js} +2 -2
- package/dist/{src-DVHlknB6.js → src-CExIrXPC.js} +169 -193
- package/dist/src-DIS0YOj0.js +44 -0
- package/dist/src-Dcfq8vE4.js +2195 -0
- package/dist/styles2.css +907 -59
- package/dist/time-series-BgzGNOk0.js +2670 -0
- package/dist/token-heatmap-BrW1OsKD.js +1354 -0
- package/dist/token-predictions-yerq_Oet.js +1093 -0
- package/dist/tone-scope-DKiSw-JR.js +32 -0
- package/dist/transport-BJweqDPj.js +715 -0
- package/dist/tree-diagram-D09BRqE-.js +1629 -0
- package/dist/treemap-CW4WsJNL.js +472 -0
- package/dist/use-tween-5HZ55_9d.js +72 -0
- package/dist/values-963L6n1m.js +65 -0
- package/dist/violin-plot-DrtPZ1-T.js +1292 -0
- package/dist/waterfall-DYLSnGjm.js +576 -0
- package/package.json +78 -4
- package/recipes/allocation-report.tsx +15 -7
- package/recipes/counting-cards.tsx +656 -0
- package/recipes/explorable-essay.tsx +172 -0
- package/skills/extend-elements/SKILL.md +81 -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 +47 -3
- package/skills/review-explainer/SKILL.md +97 -0
- package/skills/upgrade-elements/SKILL.md +3 -1
- package/skills/upgrade-elements/references/releases.md +249 -0
- package/skills/use-elements/SKILL.md +22 -14
- package/skills/use-elements/references/charts.md +362 -41
- package/skills/use-elements/references/figures.md +173 -0
- package/skills/use-elements/references/kits.md +180 -0
- 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/categorical-values-BXi-rJuv.js +0 -74
- package/dist/chart-data-CIJVWCYt.js +0 -21
- package/dist/chart-frame-BaxKn_MB.js +0 -236
- package/dist/chart-input-Bm82_9Rd.js +0 -22
- package/dist/chart-theme-4zprJ3rW.js +0 -404
- package/dist/plot-width-v2c_rA20.js +0 -63
|
@@ -0,0 +1,459 @@
|
|
|
1
|
+
# A worked essay
|
|
2
|
+
|
|
3
|
+
The essay planned in the `plan-lesson` skill's worked plan: one neuron as a weighted vote over two playing cards. These
|
|
4
|
+
three files type check against the package. In the essay starter they replace `src/lesson.ts` and `src/figures.tsx`, and
|
|
5
|
+
the third file is the TSX form of `src/essay.mdx`.
|
|
6
|
+
|
|
7
|
+
Notice what is absent: no `useState`, no animation loop, no SVG coordinates, no color. Each figure describes the state
|
|
8
|
+
the lesson is in, and the parts move when it changes.
|
|
9
|
+
|
|
10
|
+
## `lesson.ts`
|
|
11
|
+
|
|
12
|
+
The plan's params and beats as literals, with each derived value's formula written as code.
|
|
13
|
+
|
|
14
|
+
```ts
|
|
15
|
+
import { defineLesson } from '@mechane-ai/elements/lesson';
|
|
16
|
+
|
|
17
|
+
/** The cards of the essay. A card's rank is the number it feeds the neuron. The hands are synthetic. */
|
|
18
|
+
export const cards = [
|
|
19
|
+
{ id: 'queen-hearts', rank: 'Q', suit: 'heart', value: 12 },
|
|
20
|
+
{ id: 'seven-spades', rank: '7', suit: 'spade', value: 7 },
|
|
21
|
+
{ id: 'two-hearts', rank: '2', suit: 'heart', value: 2 },
|
|
22
|
+
{ id: 'king-spades', rank: 'K', suit: 'spade', value: 13 },
|
|
23
|
+
] as const;
|
|
24
|
+
|
|
25
|
+
/** The two cards of each hand: the heart first, then the spade. */
|
|
26
|
+
export const hands = {
|
|
27
|
+
'queen-seven': ['queen-hearts', 'seven-spades'],
|
|
28
|
+
'two-king': ['two-hearts', 'king-spades'],
|
|
29
|
+
} as const;
|
|
30
|
+
|
|
31
|
+
function rankOf(id: string): number {
|
|
32
|
+
return cards.find((card) => card.id === id)?.value ?? 0;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export const lesson = defineLesson({
|
|
36
|
+
id: 'card-neuron',
|
|
37
|
+
title: 'A neuron is a weighted vote',
|
|
38
|
+
params: {
|
|
39
|
+
hand: {
|
|
40
|
+
kind: 'choice',
|
|
41
|
+
label: 'Hand dealt',
|
|
42
|
+
value: 'queen-seven',
|
|
43
|
+
options: [
|
|
44
|
+
{ id: 'queen-seven', label: 'Queen of Hearts, Seven of Spades' },
|
|
45
|
+
{ id: 'two-king', label: 'Two of Hearts, King of Spades' },
|
|
46
|
+
],
|
|
47
|
+
},
|
|
48
|
+
heartWeight: {
|
|
49
|
+
kind: 'number',
|
|
50
|
+
label: 'Weight on the heart card',
|
|
51
|
+
value: 0.5,
|
|
52
|
+
min: -1,
|
|
53
|
+
max: 1,
|
|
54
|
+
step: 0.1,
|
|
55
|
+
format: { maximumFractionDigits: 1 },
|
|
56
|
+
},
|
|
57
|
+
spadeWeight: {
|
|
58
|
+
kind: 'number',
|
|
59
|
+
label: 'Weight on the spade card',
|
|
60
|
+
value: 0.5,
|
|
61
|
+
min: -1,
|
|
62
|
+
max: 1,
|
|
63
|
+
step: 0.1,
|
|
64
|
+
format: { maximumFractionDigits: 1 },
|
|
65
|
+
},
|
|
66
|
+
bias: {
|
|
67
|
+
kind: 'number',
|
|
68
|
+
label: 'Bias',
|
|
69
|
+
value: 0,
|
|
70
|
+
min: -10,
|
|
71
|
+
max: 10,
|
|
72
|
+
step: 0.5,
|
|
73
|
+
format: { maximumFractionDigits: 1 },
|
|
74
|
+
},
|
|
75
|
+
},
|
|
76
|
+
derived: {
|
|
77
|
+
sum: {
|
|
78
|
+
label: 'Weighted sum',
|
|
79
|
+
format: { maximumFractionDigits: 1 },
|
|
80
|
+
from: ({ hand, heartWeight, spadeWeight, bias }) =>
|
|
81
|
+
rankOf(hands[hand][0]) * heartWeight + rankOf(hands[hand][1]) * spadeWeight + bias,
|
|
82
|
+
},
|
|
83
|
+
yes: {
|
|
84
|
+
label: 'Chance the neuron says yes',
|
|
85
|
+
format: { style: 'percent', maximumFractionDigits: 0 },
|
|
86
|
+
from: ({ sum }) => 1 / (1 + Math.exp(-sum)),
|
|
87
|
+
},
|
|
88
|
+
},
|
|
89
|
+
beats: [
|
|
90
|
+
{
|
|
91
|
+
id: 'hand',
|
|
92
|
+
title: 'Two cards, two numbers',
|
|
93
|
+
goal: 'Read each card as a number, its rank: an ace is 1, a queen 12, a king 13.',
|
|
94
|
+
misconception: 'That the suit changes the number; the suit only says which input the card is.',
|
|
95
|
+
states: [
|
|
96
|
+
{ id: 'queen-seven', label: 'Queen and seven', values: { hand: 'queen-seven' } },
|
|
97
|
+
{ id: 'two-king', label: 'Two and king', values: { hand: 'two-king' } },
|
|
98
|
+
],
|
|
99
|
+
},
|
|
100
|
+
{
|
|
101
|
+
id: 'weights',
|
|
102
|
+
title: 'Each card gets a weight',
|
|
103
|
+
goal: 'See that a weight scales its card: at 0.5 the queen counts as 6, and below zero it counts against.',
|
|
104
|
+
misconception: 'That a weight is the card’s value; it is how much the value counts.',
|
|
105
|
+
hints: ['Drag the heart weight below zero and watch the wire turn.'],
|
|
106
|
+
states: [
|
|
107
|
+
{ id: 'even', label: 'Both weights 0.5', values: { heartWeight: 0.5 } },
|
|
108
|
+
{ id: 'against', label: 'Hearts count against', values: { heartWeight: -0.5 } },
|
|
109
|
+
],
|
|
110
|
+
},
|
|
111
|
+
{
|
|
112
|
+
id: 'sum',
|
|
113
|
+
title: 'The neuron adds the votes',
|
|
114
|
+
goal: 'Compute the weighted sum of one hand by hand, then check it against the figure.',
|
|
115
|
+
states: [
|
|
116
|
+
{ id: 'balanced', label: 'Spade weight 0.5', values: { spadeWeight: 0.5 } },
|
|
117
|
+
{ id: 'spade-heavy', label: 'Spade weight 1', values: { spadeWeight: 1 } },
|
|
118
|
+
],
|
|
119
|
+
},
|
|
120
|
+
{
|
|
121
|
+
id: 'bias',
|
|
122
|
+
title: 'The bias sets the bar',
|
|
123
|
+
goal: 'Connect a negative bias with a neuron that needs stronger evidence before it says yes.',
|
|
124
|
+
misconception: 'That the bias is one more card; it is added whatever the hand.',
|
|
125
|
+
hints: ['At a bias of −8 the cards must add about 10 more.', 'Raise the weight on the queen.'],
|
|
126
|
+
states: [
|
|
127
|
+
{ id: 'no-bias', label: 'No bias', values: { bias: 0 } },
|
|
128
|
+
{ id: 'skeptic', label: 'Bias −8', values: { bias: -8 } },
|
|
129
|
+
],
|
|
130
|
+
},
|
|
131
|
+
{
|
|
132
|
+
id: 'learning',
|
|
133
|
+
title: 'Learning moves the weights',
|
|
134
|
+
goal: 'See that training changes only the weights and the bias, never the cards.',
|
|
135
|
+
states: [
|
|
136
|
+
{ id: 'before', label: 'Before training', values: { heartWeight: -0.5, spadeWeight: 0.5, bias: 0 } },
|
|
137
|
+
{ id: 'after', label: 'After training', values: { heartWeight: 0.8, spadeWeight: -0.2, bias: -4 } },
|
|
138
|
+
],
|
|
139
|
+
},
|
|
140
|
+
],
|
|
141
|
+
});
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
## `figures.tsx`
|
|
145
|
+
|
|
146
|
+
Each figure reads the lesson and nothing else, so the beat sheet can draw it at any state. The cards keep their ids
|
|
147
|
+
across both scenes. Dragging the point in `ConfidenceScene` sets the bias through `sets`, which keeps each move on the
|
|
148
|
+
param's step grid and inside its range. The hand's two stacks deal with `stagger`, so the cards leave in turn.
|
|
149
|
+
|
|
150
|
+
```tsx
|
|
151
|
+
import { formatValue } from '@mechane-ai/elements/charts';
|
|
152
|
+
import { useLesson } from '@mechane-ai/elements/lesson';
|
|
153
|
+
import {
|
|
154
|
+
Scene,
|
|
155
|
+
SceneAxes,
|
|
156
|
+
SceneCard,
|
|
157
|
+
SceneCells,
|
|
158
|
+
SceneCurve,
|
|
159
|
+
SceneNode,
|
|
160
|
+
ScenePoint,
|
|
161
|
+
SceneRule,
|
|
162
|
+
SceneStack,
|
|
163
|
+
SceneWire,
|
|
164
|
+
} from '@mechane-ai/elements/scene';
|
|
165
|
+
import type { ReactNode } from 'react';
|
|
166
|
+
import { cards, hands, lesson } from './lesson.ts';
|
|
167
|
+
|
|
168
|
+
const ONE_DECIMAL = { maximumFractionDigits: 1 } as const;
|
|
169
|
+
|
|
170
|
+
/** The deck and the hand. Changing `hand` deals two cards out of the deck, face up, in turn. */
|
|
171
|
+
export function HandScene(): ReactNode {
|
|
172
|
+
const { values, locale } = useLesson(lesson);
|
|
173
|
+
const dealt: ReadonlyArray<string> = hands[values.hand];
|
|
174
|
+
const deck = cards.flatMap((card) => (dealt.includes(card.id) ? [] : [card.id]));
|
|
175
|
+
|
|
176
|
+
return (
|
|
177
|
+
<Scene
|
|
178
|
+
title="The hand"
|
|
179
|
+
description="Four synthetic cards: two dealt face up into the hand, two face down in the deck."
|
|
180
|
+
locale={locale}
|
|
181
|
+
x={[0, 4]}
|
|
182
|
+
y={[0, 2]}
|
|
183
|
+
height="tall"
|
|
184
|
+
>
|
|
185
|
+
<SceneStack id="deck" at={[0.8, 1]} cards={deck} stagger="short" label="The deck, two cards face down" />
|
|
186
|
+
<SceneStack
|
|
187
|
+
id="dealt"
|
|
188
|
+
at={[2.8, 1]}
|
|
189
|
+
layout="row"
|
|
190
|
+
cards={dealt}
|
|
191
|
+
stagger="regular"
|
|
192
|
+
label="The hand, two cards face up"
|
|
193
|
+
/>
|
|
194
|
+
{cards.map((card) => (
|
|
195
|
+
<SceneCard key={card.id} id={card.id} rank={card.rank} suit={card.suit} isFaceUp={dealt.includes(card.id)} />
|
|
196
|
+
))}
|
|
197
|
+
</Scene>
|
|
198
|
+
);
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
/** Each card wired to the sum; a wire's thickness is its weight and its hue the weight's sign. */
|
|
202
|
+
export function VoteScene(): ReactNode {
|
|
203
|
+
const { values, locale } = useLesson(lesson);
|
|
204
|
+
const [heartId, spadeId] = hands[values.hand];
|
|
205
|
+
const heart = cards.find((card) => card.id === heartId) ?? cards[0];
|
|
206
|
+
const spade = cards.find((card) => card.id === spadeId) ?? cards[1];
|
|
207
|
+
const sum = formatValue({ value: values.sum, locale, format: ONE_DECIMAL });
|
|
208
|
+
|
|
209
|
+
return (
|
|
210
|
+
<Scene
|
|
211
|
+
title="The weighted vote"
|
|
212
|
+
description="Each card's rank times its weight flows into one sum. Thicker wires count more; a negative weight counts against."
|
|
213
|
+
locale={locale}
|
|
214
|
+
x={[0, 4]}
|
|
215
|
+
y={[0, 2]}
|
|
216
|
+
height="tall"
|
|
217
|
+
>
|
|
218
|
+
<SceneCard id={heart.id} at={[0.6, 1.5]} rank={heart.rank} suit={heart.suit} size="small" />
|
|
219
|
+
<SceneCard id={spade.id} at={[0.6, 0.5]} rank={spade.rank} suit={spade.suit} size="small" />
|
|
220
|
+
<SceneNode id="sum" at={[3.2, 1]} shape="circle" text={sum} label={`The weighted sum, ${sum}`} />
|
|
221
|
+
{[
|
|
222
|
+
{ card: heart, weight: values.heartWeight },
|
|
223
|
+
{ card: spade, weight: values.spadeWeight },
|
|
224
|
+
].map(({ card, weight }) => {
|
|
225
|
+
const text = formatValue({ value: weight, locale, format: ONE_DECIMAL });
|
|
226
|
+
|
|
227
|
+
return (
|
|
228
|
+
<SceneWire
|
|
229
|
+
key={card.id}
|
|
230
|
+
from={card.id}
|
|
231
|
+
to="sum"
|
|
232
|
+
weight={weight}
|
|
233
|
+
text={`× ${text}`}
|
|
234
|
+
label={`Rank ${card.value} counts with weight ${text}`}
|
|
235
|
+
/>
|
|
236
|
+
);
|
|
237
|
+
})}
|
|
238
|
+
</Scene>
|
|
239
|
+
);
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
function sigmoid(sum: number): number {
|
|
243
|
+
return 1 / (1 + Math.exp(-sum));
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
/** How sure the neuron is at each bias, for the cards and weights it has. Dragging the point sets the bias. */
|
|
247
|
+
export function ConfidenceScene(): ReactNode {
|
|
248
|
+
const { values, locale } = useLesson(lesson);
|
|
249
|
+
const fromCards = values.sum - values.bias;
|
|
250
|
+
const chance = (bias: number): number => sigmoid(fromCards + bias);
|
|
251
|
+
const bias = formatValue({ value: values.bias, locale, format: ONE_DECIMAL });
|
|
252
|
+
const yes = formatValue({ value: values.yes, locale, format: { style: 'percent', maximumFractionDigits: 0 } });
|
|
253
|
+
|
|
254
|
+
return (
|
|
255
|
+
<Scene
|
|
256
|
+
title="How sure the neuron is"
|
|
257
|
+
description="The chance of saying yes at each bias, for the current cards and weights. The curve shifts when a weight changes."
|
|
258
|
+
locale={locale}
|
|
259
|
+
x={[-10, 10]}
|
|
260
|
+
y={[0, 1]}
|
|
261
|
+
>
|
|
262
|
+
<SceneAxes x={{ label: 'Bias' }} y={{ label: 'Chance of yes', format: { style: 'percent' } }} />
|
|
263
|
+
<SceneCurve id="chance" of={chance} resolution="fine" label="The chance of yes at each bias" />
|
|
264
|
+
<SceneRule id="even" y={0.5} text="even" label="An even chance" />
|
|
265
|
+
<ScenePoint
|
|
266
|
+
id="now"
|
|
267
|
+
at={[values.bias, values.yes]}
|
|
268
|
+
along={chance}
|
|
269
|
+
sets={{ x: 'bias' }}
|
|
270
|
+
label={`Bias ${bias}, chance of yes ${yes}. Move it to change the bias.`}
|
|
271
|
+
/>
|
|
272
|
+
</Scene>
|
|
273
|
+
);
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
/** The weights and the bias as cells, shaded around zero. */
|
|
277
|
+
export function WeightCells(): ReactNode {
|
|
278
|
+
const { values, locale } = useLesson(lesson);
|
|
279
|
+
|
|
280
|
+
return (
|
|
281
|
+
<Scene
|
|
282
|
+
title="What training changes"
|
|
283
|
+
description="The two weights and the bias, shaded one hue above zero and another below."
|
|
284
|
+
locale={locale}
|
|
285
|
+
x={[0, 2]}
|
|
286
|
+
y={[0, 1]}
|
|
287
|
+
height="compact"
|
|
288
|
+
>
|
|
289
|
+
<SceneCells
|
|
290
|
+
id="weights"
|
|
291
|
+
at={[1, 0.5]}
|
|
292
|
+
values={[values.heartWeight, values.spadeWeight, values.bias / 10]}
|
|
293
|
+
columnLabels={['heart weight', 'spade weight', 'bias ÷ 10']}
|
|
294
|
+
palette="diverging"
|
|
295
|
+
domain={[-1, 1]}
|
|
296
|
+
format={ONE_DECIMAL}
|
|
297
|
+
label="The heart weight, the spade weight and the bias"
|
|
298
|
+
/>
|
|
299
|
+
</Scene>
|
|
300
|
+
);
|
|
301
|
+
}
|
|
302
|
+
```
|
|
303
|
+
|
|
304
|
+
## `essay.tsx`
|
|
305
|
+
|
|
306
|
+
Every `Beat`, `Figure`, `Param`, `Predict` and `Challenge` is written as markup the article can walk: plain elements and
|
|
307
|
+
fragments, not a component of your own. The beats are one exported fragment, so the tutor in the `tutor.md` reference
|
|
308
|
+
reads the same markup through `articleOutline`. Each `Figure` lists the values its component reads. The prediction comes
|
|
309
|
+
before the figure that answers it.
|
|
310
|
+
|
|
311
|
+
```tsx
|
|
312
|
+
import { Article, Beat, Challenge, Figure, Predict, Scrolly, ScrollyStep, Term } from '@mechane-ai/elements/article';
|
|
313
|
+
import { Param, ParamSlider, Value } from '@mechane-ai/elements/lesson';
|
|
314
|
+
import { LessonFlow } from '@mechane-ai/elements/scene';
|
|
315
|
+
import type { ReactNode } from 'react';
|
|
316
|
+
import { ConfidenceScene, HandScene, VoteScene, WeightCells } from './figures.tsx';
|
|
317
|
+
import { lesson } from './lesson.ts';
|
|
318
|
+
|
|
319
|
+
/** The beats, written once. The article arranges them, and `articleOutline` reads them for the tutor. */
|
|
320
|
+
export const cardNeuronBeats = (
|
|
321
|
+
<>
|
|
322
|
+
<Beat id="hand">
|
|
323
|
+
<p>
|
|
324
|
+
A neuron reads numbers. Ours reads two playing cards, each as its rank. Deal a hand: <Param name="hand" />.
|
|
325
|
+
</p>
|
|
326
|
+
<Predict
|
|
327
|
+
id="bigger-hand"
|
|
328
|
+
prompt="Which hand adds up to more, before any weights?"
|
|
329
|
+
options={[
|
|
330
|
+
{ id: 'queen-seven', label: 'Queen and seven' },
|
|
331
|
+
{ id: 'two-king', label: 'Two and king' },
|
|
332
|
+
]}
|
|
333
|
+
answer="queen-seven"
|
|
334
|
+
>
|
|
335
|
+
<p>The queen and seven make 19; the two and king make 15. The king alone is not enough.</p>
|
|
336
|
+
</Predict>
|
|
337
|
+
<Figure
|
|
338
|
+
id="hand-scene"
|
|
339
|
+
caption="The hand dealt from the deck."
|
|
340
|
+
description="Two cards face up in a row, two face down in a pile beside them."
|
|
341
|
+
reads={['hand']}
|
|
342
|
+
>
|
|
343
|
+
<HandScene />
|
|
344
|
+
</Figure>
|
|
345
|
+
</Beat>
|
|
346
|
+
<Beat id="weights">
|
|
347
|
+
<p>
|
|
348
|
+
The neuron does not count every card the same. The <Term inspects="queen-hearts">Queen of Hearts</Term> counts
|
|
349
|
+
with a weight of <Param name="heartWeight" />, and the weighted sum is now <Value name="sum" />.
|
|
350
|
+
</p>
|
|
351
|
+
<Predict
|
|
352
|
+
id="negative-weight"
|
|
353
|
+
prompt="Make the heart weight −0.5. Does the weighted sum rise or fall?"
|
|
354
|
+
options={[
|
|
355
|
+
{ id: 'rise', label: 'It rises' },
|
|
356
|
+
{ id: 'fall', label: 'It falls' },
|
|
357
|
+
]}
|
|
358
|
+
answer="fall"
|
|
359
|
+
>
|
|
360
|
+
<p>A negative weight turns the queen into evidence against: 12 × −0.5 takes 6 away.</p>
|
|
361
|
+
</Predict>
|
|
362
|
+
<Figure
|
|
363
|
+
id="vote-scene"
|
|
364
|
+
caption="Each card counts by its weight."
|
|
365
|
+
description="Two cards wired to a circle holding the sum; the wire from the heart card thins and changes hue as its weight falls below zero."
|
|
366
|
+
reads={['hand', 'heartWeight', 'spadeWeight', 'sum']}
|
|
367
|
+
>
|
|
368
|
+
<VoteScene />
|
|
369
|
+
</Figure>
|
|
370
|
+
</Beat>
|
|
371
|
+
<Beat id="sum">
|
|
372
|
+
<p>
|
|
373
|
+
Give the spade a weight of <Param name="spadeWeight" />. Multiply, add, and check your sum against{' '}
|
|
374
|
+
<Value name="sum" /> in the figure.
|
|
375
|
+
</p>
|
|
376
|
+
<Figure
|
|
377
|
+
id="sum-flow"
|
|
378
|
+
caption="The sum, wired to every value it reads."
|
|
379
|
+
description="Boxes for the hand, the two weights and the bias, each wired into the weighted sum."
|
|
380
|
+
reads={['sum']}
|
|
381
|
+
>
|
|
382
|
+
<LessonFlow description="Each value, wired to the values it reads." names={['sum']} />
|
|
383
|
+
</Figure>
|
|
384
|
+
</Beat>
|
|
385
|
+
<Beat id="bias">
|
|
386
|
+
<p>
|
|
387
|
+
The bias is added whatever the hand. At a bias of <Param name="bias" /> the neuron says yes with a chance of{' '}
|
|
388
|
+
<Value name="yes" />.
|
|
389
|
+
</p>
|
|
390
|
+
<Figure
|
|
391
|
+
id="confidence"
|
|
392
|
+
caption="The sigmoid turns the sum into a chance. Drag the point to move the bias."
|
|
393
|
+
description="An S-shaped curve of the chance of yes against the bias, with a point at the current bias."
|
|
394
|
+
reads={['sum', 'yes', 'bias']}
|
|
395
|
+
>
|
|
396
|
+
<ConfidenceScene />
|
|
397
|
+
<ParamSlider name="bias" />
|
|
398
|
+
</Figure>
|
|
399
|
+
<Challenge
|
|
400
|
+
id="skeptic"
|
|
401
|
+
prompt="With a bias of −8, make the neuron at least 90% sure for the queen and seven."
|
|
402
|
+
isReached={(values) => values['bias'] === -8 && Number(values['yes']) >= 0.9}
|
|
403
|
+
hints={['At a bias of −8 the cards must add about 10 more.', 'Raise the weight on the queen.']}
|
|
404
|
+
>
|
|
405
|
+
<p>A skeptical neuron needs strong evidence: the weights must outvote the bias.</p>
|
|
406
|
+
</Challenge>
|
|
407
|
+
</Beat>
|
|
408
|
+
<Beat id="learning">
|
|
409
|
+
<Scrolly
|
|
410
|
+
figure={
|
|
411
|
+
<Figure
|
|
412
|
+
id="weight-cells"
|
|
413
|
+
caption="The weights and the bias."
|
|
414
|
+
description="Three cells: the heart weight, the spade weight and the bias, shaded by sign."
|
|
415
|
+
reads={['heartWeight', 'spadeWeight', 'bias']}
|
|
416
|
+
>
|
|
417
|
+
<WeightCells />
|
|
418
|
+
</Figure>
|
|
419
|
+
}
|
|
420
|
+
>
|
|
421
|
+
<ScrollyStep id="before" state="before">
|
|
422
|
+
<p>Before training, the neuron counts hearts against and spades a little for.</p>
|
|
423
|
+
</ScrollyStep>
|
|
424
|
+
<ScrollyStep id="after" state="after">
|
|
425
|
+
<p>Training moved only these three numbers. The cards never changed.</p>
|
|
426
|
+
</ScrollyStep>
|
|
427
|
+
</Scrolly>
|
|
428
|
+
</Beat>
|
|
429
|
+
</>
|
|
430
|
+
);
|
|
431
|
+
|
|
432
|
+
export function CardNeuronEssay(): ReactNode {
|
|
433
|
+
return (
|
|
434
|
+
<Article
|
|
435
|
+
lesson={lesson}
|
|
436
|
+
locale="en-US"
|
|
437
|
+
title="A neuron is a weighted vote"
|
|
438
|
+
summary="Two playing cards, two weights and a bias: everything one artificial neuron does. The hands are synthetic."
|
|
439
|
+
tones={{
|
|
440
|
+
'queen-hearts': 'negative',
|
|
441
|
+
'two-hearts': 'negative',
|
|
442
|
+
'seven-spades': 'series1',
|
|
443
|
+
'king-spades': 'series1',
|
|
444
|
+
}}
|
|
445
|
+
storageKey="card-neuron"
|
|
446
|
+
>
|
|
447
|
+
{cardNeuronBeats}
|
|
448
|
+
</Article>
|
|
449
|
+
);
|
|
450
|
+
}
|
|
451
|
+
```
|
|
452
|
+
|
|
453
|
+
## Check it
|
|
454
|
+
|
|
455
|
+
- `/?view=sheet` shows each beat twice, once per state. The `weights` row should show the heart wire flip sign; the
|
|
456
|
+
`bias` row should show the point slide down the curve.
|
|
457
|
+
- `/?view=static` prints each beat at its first state, the predictions with a "Show the answer" disclosure and each
|
|
458
|
+
scrolly step with the cells at that step's state.
|
|
459
|
+
- `checkLesson(lesson)` returns no findings.
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
# Working on this essay
|
|
2
|
+
|
|
3
|
+
- The essay is `src/essay.mdx`; the lesson it teaches is `src/lesson.ts`; the figures are `src/figures.tsx`.
|
|
4
|
+
- Plan first. Edit `plan.json` until "Lesson checks" shows no errors, then carry it into `lesson.ts`.
|
|
5
|
+
- Describe states, never animations. Give a beat `states` of param values and let the components move there.
|
|
6
|
+
- Every beat needs a `goal`, a `<Figure>` with a `description`, and at least one state. Tutor notes stay in `lesson.ts`.
|
|
7
|
+
- Write values into sentences with `<Param name="…" />` and `<Value name="…" />`. Never copy a number into the prose.
|
|
8
|
+
- Never start a line of prose with a tag such as `<Value />`. Put a word before it, or a formatter splits the paragraph.
|
|
9
|
+
- Elements parts need no imports in the MDX file: `Beat`, `Figure`, `Scene`, `Predict`, `Challenge`, `Aside`,
|
|
10
|
+
`Footnote`.
|
|
11
|
+
- Figures are components in `src/figures.tsx` that read `useLesson(lesson)`. Draw with Elements charts and `Scene`.
|
|
12
|
+
- After every change run `pnpm check`, then open `/?view=sheet` and read its "Checks" list. Fix every item.
|
|
13
|
+
- Say in the essay that synthetic data is synthetic. Do not call a paid model or a cloud account from the essay.
|
|
14
|
+
- Install the skills with `pnpm skills`, and use `explainerGuide` from `@mechane-ai/elements/lesson/spec` to pick parts.
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
# An explorable essay
|
|
2
|
+
|
|
3
|
+
One MDX file is the essay. `src/lesson.ts` declares what the reader can change, `src/figures.tsx` draws it, and
|
|
4
|
+
`src/essay.mdx` is the prose, with `<Param>` and `<Value>` in the sentences and `<Figure>` between them. The subject is
|
|
5
|
+
small and true: why a learning rate above 1 makes gradient descent on `w²` blow up. Its numbers are synthetic.
|
|
6
|
+
|
|
7
|
+
## Run
|
|
8
|
+
|
|
9
|
+
```sh
|
|
10
|
+
pnpm install
|
|
11
|
+
pnpm dev # http://localhost:5173
|
|
12
|
+
pnpm check # types, including the .mdx import
|
|
13
|
+
pnpm build
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
## Four views of the same file
|
|
17
|
+
|
|
18
|
+
Add `?view=` to the address. Every view renders the same essay.
|
|
19
|
+
|
|
20
|
+
| Address | What it is |
|
|
21
|
+
| ---------------- | -------------------------------------------------------------------------------------------- |
|
|
22
|
+
| `/` | The scrolling essay with a contents list that follows the reader. |
|
|
23
|
+
| `/?view=present` | One beat at a time. Right or Space goes on, Left goes back. |
|
|
24
|
+
| `/?view=static` | Every beat open at its first state, each figure followed by its description. Print this one. |
|
|
25
|
+
| `/?view=sheet` | The beat sheet: every beat in each of its declared states, then a list of checks. |
|
|
26
|
+
|
|
27
|
+
## Check the beat sheet
|
|
28
|
+
|
|
29
|
+
Open `/?view=sheet` after every change. Each beat appears once per state in `src/lesson.ts`, so you see what the reader
|
|
30
|
+
sees without moving a slider. The "Checks" list under it names a beat with no figure, a player with no transport, a
|
|
31
|
+
value in prose that no figure reads and a figure with no description. Fix each one. Under the essay, a "Lesson checks"
|
|
32
|
+
list shows what `checkLesson(lesson)` and the plan still get wrong.
|
|
33
|
+
|
|
34
|
+
## Plan before you write
|
|
35
|
+
|
|
36
|
+
`plan.json` is the lesson as plain data. Change it first: the "Lesson checks" list under the essay shows every finding
|
|
37
|
+
with a path and a sentence, and an error means `defineLesson` would refuse the plan. The plan's params and beats carry
|
|
38
|
+
over to `src/lesson.ts` unchanged.
|
|
39
|
+
|
|
40
|
+
## Skills for a coding agent
|
|
41
|
+
|
|
42
|
+
```sh
|
|
43
|
+
pnpm skills
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
copies the Elements skills into `.claude/skills`. `explainerGuide` from `@mechane-ai/elements/lesson/spec` lists every
|
|
47
|
+
teaching part with the question it answers. `AGENTS.md` tells an agent how to work on this essay.
|
|
48
|
+
|
|
49
|
+
## Math
|
|
50
|
+
|
|
51
|
+
The essay has no formulas, so it needs no typesetter. To write TeX, install `remark-math` and a typesetter such as
|
|
52
|
+
KaTeX, add `remarkPlugins: [remarkMath]` to `mdx()` in `vite.config.ts`, and pass `math={(tex, { isDisplay }) => …}` to
|
|
53
|
+
`<Essay>` in `src/main.tsx`. Then `$w^2$` and `$$ … $$` in the file reach `<TeX>`. Without a typesetter, `<TeX>` shows
|
|
54
|
+
the TeX source.
|
|
55
|
+
|
|
56
|
+
## Make it yours
|
|
57
|
+
|
|
58
|
+
Rename the lesson and beats, replace the figures, and rewrite the prose. Keep the beat ids in `lesson.ts` and
|
|
59
|
+
`essay.mdx` the same, and keep the sentence `The numbers are synthetic` only while they are.
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
<!doctype html>
|
|
2
|
+
<html lang="en">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="UTF-8" />
|
|
5
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
6
|
+
<title>Essay</title>
|
|
7
|
+
<style>
|
|
8
|
+
body {
|
|
9
|
+
margin: 0;
|
|
10
|
+
}
|
|
11
|
+
</style>
|
|
12
|
+
</head>
|
|
13
|
+
<body>
|
|
14
|
+
<div id="root"></div>
|
|
15
|
+
<script type="module" src="/src/main.tsx"></script>
|
|
16
|
+
</body>
|
|
17
|
+
</html>
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "__PACKAGE_NAME__",
|
|
3
|
+
"private": true,
|
|
4
|
+
"type": "module",
|
|
5
|
+
"scripts": {
|
|
6
|
+
"dev": "vite",
|
|
7
|
+
"build": "vite build",
|
|
8
|
+
"preview": "vite preview",
|
|
9
|
+
"check": "tsc --noEmit",
|
|
10
|
+
"skills": "mechane-elements-catalog --install-skills .claude/skills"
|
|
11
|
+
},
|
|
12
|
+
"dependencies": { "@mechane-ai/elements": "__ELEMENTS_VERSION__", "react": "19.3.1", "react-dom": "19.3.1" },
|
|
13
|
+
"devDependencies": {
|
|
14
|
+
"@mdx-js/rollup": "3.1.1",
|
|
15
|
+
"@types/react": "19.3.0",
|
|
16
|
+
"@types/react-dom": "19.3.0",
|
|
17
|
+
"@vitejs/plugin-react": "6.2.1",
|
|
18
|
+
"typescript": "7.0.2",
|
|
19
|
+
"vite": "8.3.5"
|
|
20
|
+
}
|
|
21
|
+
}
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
{
|
|
2
|
+
"id": "learning-rate",
|
|
3
|
+
"title": "Why a big learning rate blows up",
|
|
4
|
+
"audience": "Readers who know a model is trained by gradient descent but have not seen why the learning rate has an upper limit.",
|
|
5
|
+
"idea": "Each step multiplies the loss by (1 - 2 × rate) squared, so it falls for rates under 1 and grows past it.",
|
|
6
|
+
"params": {
|
|
7
|
+
"rate": {
|
|
8
|
+
"kind": "number",
|
|
9
|
+
"label": "Learning rate",
|
|
10
|
+
"value": 0.1,
|
|
11
|
+
"min": 0.05,
|
|
12
|
+
"max": 1.2,
|
|
13
|
+
"step": 0.05,
|
|
14
|
+
"format": { "maximumFractionDigits": 2 }
|
|
15
|
+
},
|
|
16
|
+
"steps": {
|
|
17
|
+
"kind": "number",
|
|
18
|
+
"label": "Steps taken",
|
|
19
|
+
"value": 0,
|
|
20
|
+
"min": 0,
|
|
21
|
+
"max": 10,
|
|
22
|
+
"step": 1,
|
|
23
|
+
"format": { "maximumFractionDigits": 0 }
|
|
24
|
+
}
|
|
25
|
+
},
|
|
26
|
+
"derived": {
|
|
27
|
+
"weight": {
|
|
28
|
+
"label": "Weight",
|
|
29
|
+
"format": { "maximumSignificantDigits": 3 },
|
|
30
|
+
"reads": ["rate", "steps"],
|
|
31
|
+
"formula": "(1 - 2 × rate) to the power of steps"
|
|
32
|
+
},
|
|
33
|
+
"loss": {
|
|
34
|
+
"label": "Loss",
|
|
35
|
+
"format": { "maximumSignificantDigits": 2 },
|
|
36
|
+
"reads": ["weight"],
|
|
37
|
+
"formula": "the weight squared"
|
|
38
|
+
},
|
|
39
|
+
"factor": {
|
|
40
|
+
"label": "Loss factor per step",
|
|
41
|
+
"format": { "maximumFractionDigits": 2 },
|
|
42
|
+
"reads": ["rate"],
|
|
43
|
+
"formula": "(1 - 2 × rate) squared"
|
|
44
|
+
}
|
|
45
|
+
},
|
|
46
|
+
"beats": [
|
|
47
|
+
{
|
|
48
|
+
"id": "update",
|
|
49
|
+
"title": "One step of gradient descent",
|
|
50
|
+
"goal": "See that a step moves the weight against its slope by a fixed fraction of that slope.",
|
|
51
|
+
"misconception": "That a bigger step always gets to the minimum sooner.",
|
|
52
|
+
"states": [
|
|
53
|
+
{ "id": "start", "label": "Before the first step", "values": { "rate": 0.1, "steps": 0 } },
|
|
54
|
+
{ "id": "one-step", "label": "After one step", "values": { "rate": 0.1, "steps": 1 } }
|
|
55
|
+
],
|
|
56
|
+
"figure": {
|
|
57
|
+
"part": "Scene",
|
|
58
|
+
"question": "How does one step turn a weight into the next weight?",
|
|
59
|
+
"shows": ["weight", "rate"]
|
|
60
|
+
}
|
|
61
|
+
},
|
|
62
|
+
{
|
|
63
|
+
"id": "rate",
|
|
64
|
+
"title": "The rate sets how fast the loss falls",
|
|
65
|
+
"goal": "Connect a larger rate with a smaller loss factor, up to the rate that lands on the minimum.",
|
|
66
|
+
"states": [
|
|
67
|
+
{ "id": "slow", "label": "Rate 0.1, ten steps", "values": { "rate": 0.1, "steps": 10 } },
|
|
68
|
+
{ "id": "fast", "label": "Rate 0.4, ten steps", "values": { "rate": 0.4, "steps": 10 } }
|
|
69
|
+
],
|
|
70
|
+
"figure": {
|
|
71
|
+
"part": "CurveChart",
|
|
72
|
+
"question": "How fast does the loss fall at this rate?",
|
|
73
|
+
"shows": ["loss", "rate"]
|
|
74
|
+
},
|
|
75
|
+
"ask": { "kind": "predict", "prompt": "After ten steps, which learning rate leaves the smaller loss?" }
|
|
76
|
+
},
|
|
77
|
+
{
|
|
78
|
+
"id": "blowup",
|
|
79
|
+
"title": "Past a rate of one, the loss grows",
|
|
80
|
+
"goal": "Find the rate where each step stops shrinking the loss and starts growing it.",
|
|
81
|
+
"states": [
|
|
82
|
+
{ "id": "edge", "label": "Rate 1, ten steps", "values": { "rate": 1, "steps": 10 } },
|
|
83
|
+
{ "id": "blown", "label": "Rate 1.1, ten steps", "values": { "rate": 1.1, "steps": 10 } }
|
|
84
|
+
],
|
|
85
|
+
"figure": {
|
|
86
|
+
"part": "CurveChart",
|
|
87
|
+
"question": "Does the loss fall, stay flat or climb at this rate?",
|
|
88
|
+
"shows": ["loss", "rate", "factor"]
|
|
89
|
+
},
|
|
90
|
+
"ask": {
|
|
91
|
+
"kind": "challenge",
|
|
92
|
+
"prompt": "Find the largest learning rate on the slider that still makes the loss fall."
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
]
|
|
96
|
+
}
|