[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"project-115061":3},{"id":4,"name":5,"fullName":6,"owner":7,"repo":5,"description":8,"homepage":9,"htmlUrl":10,"language":11,"languages":10,"totalLinesOfCode":10,"stars":12,"forks":13,"watchers":14,"openIssues":15,"contributorsCount":16,"subscribersCount":16,"size":16,"stars1d":16,"stars7d":17,"stars30d":17,"stars90d":16,"forks30d":16,"starsTrendScore":18,"compositeScore":19,"rankGlobal":10,"rankLanguage":10,"license":20,"archived":21,"fork":21,"defaultBranch":22,"hasWiki":23,"hasPages":21,"topics":24,"createdAt":10,"pushedAt":39,"updatedAt":40,"readmeContent":41,"aiSummary":42,"trendingCount":16,"starSnapshotCount":16,"syncStatus":43,"lastSyncTime":44,"discoverSource":45},115061,"inside-llm","manuelgscom\u002Finside-llm","manuelgscom","See inside any GGUF: where two quantizations part ways, token by token, and what each sampler cuts. Live in your browser, powered by llama.cpp (CUDA or Vulkan).","https:\u002F\u002Fmanuelgs.com\u002Fen\u002Finside-llm\u002F",null,"TypeScript",122,12,58,1,0,46,10,67.94,"MIT License",false,"main",true,[25,26,27,28,29,30,31,32,33,34,35,36,37,38],"cpp","cuda","gguf","interpretability","llama-cpp","llm","local-llm","logit-lens","quantization","sampling","svelte","threejs","visualization","vulkan","2026-11-22 22:16:31","2026-11-22 14:28:00","# inside-llm\n\n[![Release](https:\u002F\u002Fimg.shields.io\u002Fgithub\u002Fv\u002Frelease\u002Fmanuelgscom\u002Finside-llm?logo=github&color=blue)](https:\u002F\u002Fgithub.com\u002Fmanuelgscom\u002Finside-llm\u002Freleases) [![License: MIT](https:\u002F\u002Fimg.shields.io\u002Fbadge\u002Flicense-MIT-blue)](https:\u002F\u002Fgithub.com\u002Fmanuelgscom\u002Finside-llm\u002Fblob\u002Fmain\u002FLICENSE) [![llama.cpp](https:\u002F\u002Fimg.shields.io\u002Fbadge\u002Fbuilt%20with-llama.cpp-informational)](https:\u002F\u002Fgithub.com\u002Fggml-org\u002Fllama.cpp) [![Runs on: CUDA · Vulkan](https:\u002F\u002Fimg.shields.io\u002Fbadge\u002Fruns%20on-CUDA%20%C2%B7%20Vulkan-informational)](#install) [![Platforms: Linux · Windows](https:\u002F\u002Fimg.shields.io\u002Fbadge\u002Fplatforms-Linux%20%C2%B7%20Windows-informational)](#install) [![Live demo](https:\u002F\u002Fimg.shields.io\u002Fbadge\u002Flive%20demo-try%20it%20in%20your%20browser-brightgreen)](https:\u002F\u002Fmanuelgs.com\u002Fen\u002Finside-llm\u002Fdemo\u002F)\n\n**See inside any GGUF: where two quantizations part ways, token by token, and what each sampler cuts. Live, in your browser.**\n\nhttps:\u002F\u002Fgithub.com\u002Fuser-attachments\u002Fassets\u002F5f9492ba-0ba4-4f40-94b3-93503a099475\n\n*`inside-llm` with Qwen3.5-4B at two quantizations, Q2_K and Q8_0: the token where their texts split, the candidates behind each pick, the sampler chain, branches and the relief of probabilities. Every number comes from the real engine running the two models.*\n\n`inside-llm` loads one or two GGUF models with [llama.cpp](https:\u002F\u002Fgithub.com\u002Fggml-org\u002Fllama.cpp) and shows in the browser what the model does while it generates: the probability of each token, the alternatives it discarded, what each sampler removes and, with two models (two quantizations, or a base model and its fine-tune), the divergence at every position and the exact token where their texts split. It is a single native binary that serves its own web page. Everything runs on your machine: no accounts, no API keys, no telemetry. A session can be recorded and replayed later in a static page, with no engine and no GPU.\n\n**[Try the live demo](https:\u002F\u002Fmanuelgs.com\u002Fen\u002Finside-llm\u002Fdemo\u002F)**: recorded sessions replayed in your browser, nothing to install.\n\n## What you see\n\n![inside-llm comparing Qwen3.5-4B Q2_K (A) and Q8_0 (B): at position 31 A picks \"six\" and B \"eight\", and their texts split there](assets\u002Finside-llm.png)\n\n- **Stream:** the generated text, one column per model (A | B). Brightness is the probability the model gave to each token; a magenta mark shows where A and B would pick differently. Two modes: *Same text* (lockstep: both models read the text written by the driver) and *Each its own* (free: each model follows its own picks until the texts split).\n- **Candidates:** the decision behind the selected token. Mirrored bars for A and B on each candidate, entropy, effective number of options, Jensen-Shannon divergence and KL in both directions. **Compare** puts the two distributions side by side.\n- **Gates:** the sampler chain of that decision (penalties, top-k, top-p, min-p, temperature and a GBNF grammar), with how many candidates survive each stage. Click a stage to see the distribution after it. The chain, its order and the seed are set in the **Samplers** panel.\n- **Metrics:** confidence, surprise, perplexity, margin, speed and latency of A and B, as sparklines along the text.\n- **Timeline:** entropy of A and B and their divergence along the text, with the tree of branches. Sweep it with the mouse and every panel follows.\n- **Relief 3D and Layers:** a surface whose height is a probability: the candidates at each position or, with `--lens`, what each layer would predict (logit lens), also as a 2D map.\n- **Branching:** click a candidate and generation continues from there. Nothing is lost: every branch stays in the tree and can be viewed or resumed, and the engine returns to any node exactly.\n- **Models:** pick model A and model B from the models folder, or search Hugging Face and download GGUF files, without restarting. The picker only offers B models that share A's tokenizer and warns when the pair will not fit in GPU memory.\n\n![Relief 3D: the candidates of every position as a surface; cyan is model A, amber model B, magenta where their picks differ](assets\u002Frelief.png)\n\nBoth models must share the same tokenizer: two quantizations of a model, a base model and its fine-tune, or two sizes of one family that keep the tokenizer (every Qwen3.5 size, for instance). Without model B, everything except the comparison works.\n\n## Install\n\nDownload the package for your system from the [latest release](https:\u002F\u002Fgithub.com\u002Fmanuelgscom\u002Finside-llm\u002Freleases\u002Flatest). Each one is self-contained: nothing else to install besides the GPU driver.\n\n| Package | For | Needs on the machine |\n|---|---|---|\n| `inside-llm-v1.0.0-linux-cuda.tar.gz` | Linux + NVIDIA | glibc 2.35 or newer, NVIDIA driver |\n| `inside-llm-v1.0.0-linux-vulkan.tar.gz` | Linux + any dedicated GPU (AMD, Intel Arc, NVIDIA) | glibc 2.35 or newer, the GPU's Vulkan driver and `libvulkan1` (present on any desktop) |\n| `inside-llm-v1.0.0-windows-cuda.zip` | Windows + NVIDIA | a recent NVIDIA driver |\n| `inside-llm-v1.0.0-windows-vulkan.zip` | Windows + any dedicated GPU | the GPU driver |\n\nglibc 2.35 or newer means Ubuntu 22.04, Debian 12, Fedora 36, Linux Mint 21 or later. The CUDA packages carry the CUDA runtime and cuBLAS, so no CUDA toolkit is needed.\n\n**Linux** (here with Vulkan; the CUDA package works the same way):\n\n```sh\ncurl -LO https:\u002F\u002Fgithub.com\u002Fmanuelgscom\u002Finside-llm\u002Freleases\u002Flatest\u002Fdownload\u002Finside-llm-v1.0.0-linux-vulkan.tar.gz\ntar -xzf inside-llm-v1.0.0-linux-vulkan.tar.gz\n.\u002Finside-llm-v1.0.0-linux-vulkan\u002Finside-llm\n```\n\nThe browser opens by itself (if not, go to http:\u002F\u002Flocalhost:8642) with the model picker. To load two models straight away: `inside-llm -a A.gguf -b B.gguf`.\n\n**Windows:** unzip `inside-llm-v1.0.0-windows-cuda.zip` (or `-vulkan`) and double-click `inside-llm.exe`. The browser opens by itself with the model picker. From a terminal, `inside-llm.exe -a A.gguf -b B.gguf` loads two models straight away.\n\nModels live in the `models` folder of the directory you start the engine from (created if missing; `--models-dir` picks another). Files downloaded from Hugging Face land there too.\n\nAt startup the engine prints the GPU it uses, or a warning if it found none. Integrated GPUs are never used: without a dedicated GPU the models run on the CPU, much slower.\n\n**Checking a download:** each release has a `SHA256SUMS` file. In the folder with the downloads:\n\n```sh\ncurl -LO https:\u002F\u002Fgithub.com\u002Fmanuelgscom\u002Finside-llm\u002Freleases\u002Flatest\u002Fdownload\u002FSHA256SUMS\nsha256sum -c --ignore-missing SHA256SUMS\n```\n\n## Try it without installing\n\n**Live demo: [manuelgs.com\u002Finside-llm\u002Fdemo\u002F](https:\u002F\u002Fmanuelgs.com\u002Fen\u002Finside-llm\u002Fdemo\u002F)**. Recorded sessions play back in a static build of the same web page: no engine, no models, no GPU. Pick a session in the gallery and press **Replay**: selection, sweeping, the recorded branches, gates and the relief all work; anything that would send a command to the engine is disabled.\n\nTo serve the same page yourself, from a clone of this repository (see [Build from source](#build-from-source)), with Docker:\n\n```sh\nmake image               # toolchain images (once)\nmake web-static          # builds the static web with the recorded sessions\nmake web-static-serve    # serves it on http:\u002F\u002Flocalhost:4173 (STATIC_PORT=… to change)\n```\n\nWithout parameters the page shows a gallery of the recorded sessions in `sessions\u002Fsamples\u002F` (listed in `sessions\u002Findex.json`). `?session=\u003Curl of an .ils file>` opens one directly. A live session can be downloaded from the bar (**Session**) and replayed the same way.\n\n## Command-line options\n\n```\ninside-llm [-a \u003Ca.gguf> [-b \u003Cb.gguf>]] [options]\n```\n\nWithout `-a` the engine starts with no model and the browser opens the model picker.\n\n| Option | Meaning |\n|---|---|\n| `-a FILE` | Model A (GGUF), loaded at startup; any path |\n| `-b FILE` | Model B (GGUF), to compare with A; same tokenizer |\n| `--models-dir DIR` | Folder the browser picks models from and downloads into (default `models`) |\n| `--ctx N` | Context size of each model (default 4096) |\n| `--gpu-layers-a N`, `--gpu-layers-b N` | Layers of A \u002F B on the GPU (default: all) |\n| `--snapshot-mem MIB` | MiB of state snapshots each model may keep in RAM, used to jump back to a node exactly (default 3072) |\n| `--lens` | Logit lens: what each layer would predict, projected on the CPU (about 2 GB of RAM per model and some 30 ms per step) |\n| `--lens-layers LIST` | Layers of the lens, from 0, like `0,6,12,23` (at most 16; implies `--lens`; default: 8 spread evenly, the last one included) |\n| `--host ADDR` | Listen address (default 127.0.0.1) |\n| `--port N` | Port (default 8642; 0 picks a free one) |\n| `--no-browser` | Do not open the browser at startup |\n| `--allow-origin URL` | Extra origin accepted on the WebSocket (repeatable) |\n| `--help` | Show the help |\n\nThe engine listens on `127.0.0.1` only unless you pass `--host`.\n\n## Models\n\nAny GGUF of a text-generating model that llama.cpp loads (Llama, Qwen, Gemma, Mistral, Phi, DeepSeek, MoE models…), at any quantization, as long as it fits in GPU memory. Multimodal models work on text only. Not supported: embedding-only models and GGUF files split in several parts. Some pairs to start with (also offered as suggestions in the picker):\n\n| Use | Model A | Model B |\n|---|---|---|\n| Demo | `Qwen_Qwen3.5-4B-Q2_K.gguf` (bartowski, 2.2 GB) | `Qwen_Qwen3.5-4B-Q8_0.gguf` (bartowski, 4.6 GB) |\n| Smaller | `Qwen3.5-2B-UD-Q2_K_XL.gguf` (unsloth, 1.0 GB) | `Qwen3.5-2B-Q8_0.gguf` (unsloth, 2.0 GB) |\n| Smallest | `Qwen3.5-0.8B-Q4_K_M.gguf` (unsloth) | `Qwen3.5-0.8B-Q8_0.gguf` (unsloth) |\n\n**From Hugging Face:** the **Hugging Face** tab of the model picker searches public GGUF repositories; tick two quantizations of one repository and **Download & compare** downloads both into the models folder and loads them as A and B. Downloads resume after a cancel. For gated repositories set `HF_TOKEN` in the engine's environment; `HF_ENDPOINT` points at a mirror.\n\n## How it works\n\n```\n ┌──────────────────────── inside-llm (one process) ─────────────────────────┐\n │                                                                           │\n │  model A ──┐                                                              │\n │ (llama.cpp)│   logits ─► sampler chain ─► pick ─► tree of tokens          │\n │  model B ──┘   (per step,  (penalties, top-k,        (branches, cursors, │\n │ (llama.cpp)     A and B)    top-p, min-p, temp,       state snapshots)    │\n │                             grammar), traced                              │\n │                                   │                                       │\n │                       binary frames over a WebSocket                      │\n └───────────────────────────────────┼───────────────────────────────────────┘\n                                     ▼\n              browser: Svelte 5 + Canvas 2D (+ three.js for the relief)\n              ──► the same frames, saved to disk, are a recorded session\n```\n\n- **Engine (C++17):** links llama.cpp directly. For every step it reads the full distribution of A (and of B on the same context), computes entropy, divergence and the sampler chain stage by stage, and draws the token with its own seeded sampler. Each model keeps snapshots of its state so that jumping to another node of the tree is exact, not re-generated.\n- **Protocol:** compact binary frames for each step plus JSON commands from the browser. A recorded session (`.ils`) is the same stream of frames, compressed.\n- **Web:** Svelte 5 for the panels; the per-step data skips reactivity and is painted on canvases by one `requestAnimationFrame` loop. The relief is three.js, loaded only when opened. The page is embedded in the binary.\n\n## Build from source\n\nEverything builds and runs in Docker; nothing is installed on the host. Running on the GPU needs an NVIDIA GPU and the [NVIDIA Container Toolkit](https:\u002F\u002Fdocs.nvidia.com\u002Fdatacenter\u002Fcloud-native\u002Fcontainer-toolkit\u002Flatest\u002Finstall-guide.html) (`BACKEND=vulkan` builds and runs with Vulkan instead).\n\n```sh\ngit clone --recursive https:\u002F\u002Fgithub.com\u002Fmanuelgscom\u002Finside-llm.git\ncd inside-llm\nmake image          # toolchain images (once)\nmake build          # the web and the binary\nmake test-unit      # engine and web tests: no GPU, no model\nmake models         # download the GGUF pairs above into models\u002F (optional)\nmake run            # then open http:\u002F\u002Flocalhost:8642 and pick the models\nmake run A=Qwen_Qwen3.5-4B-Q2_K.gguf B=Qwen_Qwen3.5-4B-Q8_0.gguf   # or load two of models\u002F at startup\n```\n\n`--recursive` also fetches llama.cpp, which is a git submodule. `make run` takes extra options with `ARGS=\"--lens --ctx 8192\"`. `make test-gpu` runs the integration tests on the GPU with a real model, and `make run-fake` starts the engine with a scripted fake model (no GGUF, no GPU) for working on the web. The CUDA kernels are built for one architecture (`CUDA_ARCH`, default `120-real`; e.g. `make build CUDA_ARCH=89-real` for an RTX 40).\n\n**Packages:** `make dist-linux-cuda` and `make dist-linux-vulkan` build the portable Linux binaries on Ubuntu 22.04 (in Docker) and pack them with the libraries they need in `dist\u002F`. The Windows zips are built natively with MSVC: `packaging\u002Fwindows\u002Fsetup-tools.ps1` installs the toolchain once and `packaging\u002Fwindows\u002Fbuild.ps1` builds both variants. `make dist-sums` writes `dist\u002FSHA256SUMS`.\n\n### Repository layout\n\n```\nCMakeLists.txt, Makefile   build (everything through Docker)\nengine\u002F\n  src\u002F        the engine: llama.cpp models, sampler chain, metrics, logit lens, tree and\n              snapshots, session coordinator, binary frames, HTTP\u002FWebSocket server,\n              model catalog and Hugging Face downloads\n  tests\u002F      unit tests, golden sessions, a fake engine, GPU integration tests\nweb\u002F\n  src\u002F        Svelte 5 app: panels, canvas renderers, store, frame decoder, e2e tests\n  scripts\u002F    static build of the recorded sessions, screenshots\nsessions\u002F     golden\u002F (the protocol contract, synthetic) and samples\u002F (recorded sessions)\ndocker\u002F       toolchain images\npackaging\u002F    Linux (Ubuntu 22.04) and Windows (MSVC) packages\nthird_party\u002F  llama.cpp (submodule)\n```\n\n## Limitations\n\n- Model A and model B must share the tokenizer.\n- Both models must fit in GPU memory at once; the picker estimates it before loading.\n- One GPU at a time. Integrated GPUs are never used; without a dedicated GPU it runs on the CPU, much slower.\n- Text only: multimodal models load, but only their text side is shown.\n- The engine is meant for your own machine: it listens on localhost and has no authentication.\n\n## License\n\nThe code is under the [MIT](LICENSE) license. The packages also contain llama.cpp\u002Fggml, cpp-httplib, nlohmann\u002Fjson, zlib, LibreSSL, Svelte, three.js, the Inter and JetBrains Mono fonts and, depending on the package, the NVIDIA CUDA runtime and cuBLAS, the Microsoft Visual C++ runtime or the GCC OpenMP runtime; their licenses and notices are in [THIRD_PARTY_NOTICES](THIRD_PARTY_NOTICES).\n\ninside-llm is an independent project, not affiliated with or endorsed by the authors of llama.cpp, Qwen or any model it loads.\n\n---\n\nAuthor: [Manuel García](https:\u002F\u002Fmanuelgs.com)\n","inside-llm 是一个面向本地大语言模型（LLM）的浏览器内可视化调试工具，用于深入分析 GGUF 格式模型在推理过程中的内部行为。它支持加载单个或两个 GGUF 模型（如不同量化精度版本），逐 token 展示 logits 分布、采样器链（temperature\u002Ftop-k\u002Ftop-p\u002Fmin-p\u002FGBNF 等）各阶段的候选筛选过程、概率分布差异（JS 散度、KL 散度）、以及多模型间文本分叉点。基于 llama.cpp（CUDA\u002FVulkan 后端）本地运行，无需联网或云端服务，支持录制与离线回放。适用于 LLM 量化效果评估、采样策略调优、模型行为可解释性研究及教学演示等场景。",2,"2026-11-24 04:50:13","CREATED_QUERY"]