Spaces:
Runtime error
Runtime error
Upload README.md with huggingface_hub
Browse files
README.md
CHANGED
|
@@ -1,133 +1,18 @@
|
|
| 1 |
-
|
| 2 |
-
|
| 3 |
-
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
<img src="https://img.shields.io/badge/node-20+-339933.svg?logo=node.js&logoColor=white" alt="Node 20+">
|
| 11 |
-
</p>
|
| 12 |
-
|
| 13 |
---
|
| 14 |
|
| 15 |
-
Neural MRI Scanner
|
| 16 |
-
|
| 17 |
-
<p align="center">
|
| 18 |
-
<img src="docs/screenshots/fmri-scan.png" alt="Neural MRI β fMRI activation scan" width="800">
|
| 19 |
-
</p>
|
| 20 |
-
|
| 21 |
-
## Scan Modes
|
| 22 |
-
|
| 23 |
-
| Mode | Full Name | What It Shows |
|
| 24 |
-
|------|-----------|---------------|
|
| 25 |
-
| **T1** | Topology Layer 1 | Static architecture β layers, parameters, structure |
|
| 26 |
-
| **T2** | Tensor Layer 2 | Weight distribution & magnitude |
|
| 27 |
-
| **fMRI** | functional Model Resonance Imaging | Activation patterns for a given prompt |
|
| 28 |
-
| **DTI** | Data Tractography Imaging | Information flow pathways & circuits |
|
| 29 |
-
| **FLAIR** | Feature-Level Anomaly Identification & Reporting | Bias, hallucination & anomaly detection |
|
| 30 |
-
|
| 31 |
-
<p align="center">
|
| 32 |
-
<img src="docs/screenshots/dti-scan.png" alt="DTI circuit tracing" width="400">
|
| 33 |
-
<img src="docs/screenshots/flair-scan.png" alt="FLAIR anomaly detection" width="400">
|
| 34 |
-
</p>
|
| 35 |
-
|
| 36 |
-
## Features
|
| 37 |
-
|
| 38 |
-
- **5 scan modes** with real-time visualization (T1, T2, fMRI, DTI, FLAIR)
|
| 39 |
-
- **Token-by-token streaming** via WebSocket β watch activations unfold live
|
| 40 |
-
- **Perturbation engine** β zero, amplify, or ablate individual components and measure impact (KL divergence, logit shift)
|
| 41 |
-
- **Causal tracing** β clean/corrupt prompt comparison with layer-by-layer recovery scores
|
| 42 |
-
- **SAE integration** β Sparse Autoencoder feature analysis via SAE-Lens
|
| 43 |
-
- **Cross-model comparison** β run two models side-by-side on the same prompt
|
| 44 |
-
- **4 layout modes** β vertical, brain, network, radial
|
| 45 |
-
- **Recording & export** β WebM video, animated GIF, SVG/PNG snapshots, JSON data, Markdown reports
|
| 46 |
-
- **Real-time collaboration** β share scan sessions with peers via WebSocket
|
| 47 |
-
- **HuggingFace Hub search** β dynamically discover and load TransformerLens-compatible models
|
| 48 |
-
- **i18n** β English and Korean
|
| 49 |
-
- **Medical dark theme** β DICOM viewer aesthetic with CRT scan effects
|
| 50 |
-
|
| 51 |
-
## Quick Start
|
| 52 |
-
|
| 53 |
-
### Local
|
| 54 |
-
|
| 55 |
-
```bash
|
| 56 |
-
# Backend
|
| 57 |
-
cd backend
|
| 58 |
-
uv sync
|
| 59 |
-
uv run uvicorn neural_mri.main:app --reload --port 8000
|
| 60 |
-
|
| 61 |
-
# Frontend (new terminal)
|
| 62 |
-
cd frontend
|
| 63 |
-
pnpm install
|
| 64 |
-
pnpm dev
|
| 65 |
-
```
|
| 66 |
-
|
| 67 |
-
Open http://localhost:5173
|
| 68 |
-
|
| 69 |
-
### Docker
|
| 70 |
-
|
| 71 |
-
```bash
|
| 72 |
-
docker compose up --build
|
| 73 |
-
```
|
| 74 |
-
|
| 75 |
-
Open http://localhost
|
| 76 |
-
|
| 77 |
-
> See [INSTALL.md](INSTALL.md) for detailed setup instructions including GPU configuration and environment variables.
|
| 78 |
-
|
| 79 |
-
## Supported Models
|
| 80 |
-
|
| 81 |
-
Five models are available out of the box:
|
| 82 |
-
|
| 83 |
-
| Model | Parameters | Priority |
|
| 84 |
-
|-------|-----------|----------|
|
| 85 |
-
| GPT-2 | 124M | Default |
|
| 86 |
-
| GPT-2 Medium | 355M | Built-in |
|
| 87 |
-
| Pythia-1.4B | 1.4B | Built-in |
|
| 88 |
-
| Gemma-2-2B | 2B | Gated (requires HF token) |
|
| 89 |
-
| Llama-3.2-3B | 3B | Gated (requires HF token) |
|
| 90 |
-
|
| 91 |
-
Additional models can be loaded dynamically via **HuggingFace Hub search** β any model with a TransformerLens-compatible architecture works.
|
| 92 |
-
|
| 93 |
-
## Architecture
|
| 94 |
-
|
| 95 |
-
```
|
| 96 |
-
βββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 97 |
-
β Frontend β
|
| 98 |
-
β React 18 + TypeScript + D3.js + Zustand β
|
| 99 |
-
β ββββββββββββ ββββββββββββ ββββββββββββββββββββ β
|
| 100 |
-
β β ScanCanvasβ βModeTabs β β Panels (Perturb, β β
|
| 101 |
-
β β (D3 viz) β β(T1-FLAIR)β β CausalTrace,SAE) β β
|
| 102 |
-
β ββββββββββββ ββββββββββββ ββββββββββββββββββββ β
|
| 103 |
-
β β REST + WebSocket β β
|
| 104 |
-
βββββββββββββββββββββββββββββββββββββββββββββββββββ€
|
| 105 |
-
β Backend β
|
| 106 |
-
β FastAPI + TransformerLens + PyTorch β
|
| 107 |
-
β ββββββββββββ ββββββββββββ ββββββββββββββββββββ β
|
| 108 |
-
β β Scanner β β Model β β Perturbation β β
|
| 109 |
-
β β Engine β β Registry β β Engine β β
|
| 110 |
-
β ββββββββββββ ββββββββββββ ββββββββββββββββββββ β
|
| 111 |
-
β β TransformerLens β β
|
| 112 |
-
βββββββββββββββββββββββββββββββββββββββββββββββββββ€
|
| 113 |
-
β Model Weights β
|
| 114 |
-
β HuggingFace Hub / Local Cache β
|
| 115 |
-
βββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 116 |
-
```
|
| 117 |
-
|
| 118 |
-
## Tech Stack
|
| 119 |
-
|
| 120 |
-
| Layer | Technology |
|
| 121 |
-
|-------|-----------|
|
| 122 |
-
| Frontend | React 18, TypeScript, D3.js, Zustand, Tailwind CSS v3 |
|
| 123 |
-
| Backend | FastAPI, TransformerLens, PyTorch, SAE-Lens |
|
| 124 |
-
| Infra | Docker Compose, GitHub Actions CI |
|
| 125 |
-
| Theme | Medical Dark (DICOM viewer aesthetic) |
|
| 126 |
-
|
| 127 |
-
## Contributing
|
| 128 |
|
| 129 |
-
|
| 130 |
|
| 131 |
-
|
| 132 |
|
| 133 |
-
[
|
|
|
|
| 1 |
+
---
|
| 2 |
+
title: Neural MRI Scanner
|
| 3 |
+
emoji: π§
|
| 4 |
+
colorFrom: green
|
| 5 |
+
colorTo: blue
|
| 6 |
+
sdk: docker
|
| 7 |
+
app_port: 7860
|
| 8 |
+
license: mit
|
| 9 |
+
short_description: Visualize LLM internals like a brain MRI
|
|
|
|
|
|
|
|
|
|
| 10 |
---
|
| 11 |
|
| 12 |
+
# Neural MRI Scanner
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 13 |
|
| 14 |
+
**Model Resonance Imaging for AI Interpretability**
|
| 15 |
|
| 16 |
+
Visualize the internals of open-source LLMs like a brain MRI β 5 scan modes (T1, T2, fMRI, DTI, FLAIR).
|
| 17 |
|
| 18 |
+
See [GitHub](https://github.com/JihoonJeong/Neural-MRI) for full documentation.
|