How bbycroft/llm-viz works
Project Type & Purpose
• The repository is a multi-project full-stack application built with Next.js. It integrates a homepage, interactive LLM visualization, and a (work‐in‐progress) CPU simulation tool.
• LLM Visualization focuses on rendering complex neural network structures interactively (supporting both small and larger “GPT” models).
• CPU Simulation provides a digital schematic editor, complete with simulation of circuit execution, including RISC-V instruction sets and low-level gate–based interactions.
Main Components
• Frontend (Next.js Application):
– Pages and routes (see src/app folders for cpu, llm, fluidsim, homepage).
– UI components: Each project has its React components (e.g., in src/cpu, src/llm, etc.), styled using SCSS and Tailwind CSS.
• CPU Simulation Module:
– Schematic Editor: Components, guides, toolbars, and schematics (refer to src/cpu/guide, src/cpu/schematics, and src/cpu/toolbars).
– Execution Model & API: Backend API endpoints for operations like “save-schematic-to-file” (src/app/cpu/api) and simulation logic found in src/cpu modules.
– Test assets and example RISC-V binaries located in public/riscv.
• LLM Visualization Module:
– 3D Interactive Model components appear in src/llm and related component folders.
– Rendering logic includes WebGPU support (see src/llm/gpu) and WASM integration (src/llm/wasm) for intensive computations.
– Interaction components (like controls, commentary, and walk-through modules in src/llm/walkthrough).
• Shared Utilities & Assets:
– Common utilities in src/utils (for math, hooks, pointer events, etc.)
– Fonts and images found in public and fonts directories (which tie into the rendering of text/models).
– Global styling via styles/main.css, tailwind.config.js, etc.
• Deployment & Config:
– Next.js configurations (next.config.js, next-env.d.ts) and package.json for dependency management.
– Build scripts and configuration files (e.g., .editorconfig, tsconfig.json) that support the overall development environment.
Relationships & Interactions
• User Interaction Flow: End users interact via a browser that loads the Next.js application.
• Routing: Clear separation across the three main areas (homepage, LLM visualization, CPU simulation) via the app and page components.
• Component Communication:
– UI components call shared utilities for rendering updates.
– The CPU simulation API (e.g., “save-schematic-to-file”) accepts data from the schematic editor and saves or processes it.
– The LLM module works with rendering layers and WASM modules to perform heavy computations.
• Data Flow:
– Demonstrate dependency links such that both the LLM and CPU modules rely on shared utilities and styling resources.
Architectural Patterns & Technologies
• Modular, component-based design using React. Each major project is architected using modular React components and routes.
• Use of Next.js means SSR and API endpoints are integrated into a single project structure.
• Separation between presentation (React/SCSS) and logic (CPU simulation calculations, WASM-based LLM model).
• WebAssembly integration in the LLM module for performance-intensive tasks.
• Use of configuration management and build tooling (e.g., npm, yarn, and build scripts in the project).