How vasiniks/lobotomy works
lobotomy is a local model-inspection and intervention app. A user chats through the browser; the server streams a reply from the loaded model, records internal activations, and serves those recordings to visualizations and analysis tools. Users can inspect the 3D layer stack, individual layers and tokens, compare answers, scan or explain predictions, and apply reversible edits before asking again. The README documents both MLX and PyTorch runtimes; sampled code confirms the engine/backend boundary, while several feature-specific routes were not excerpted, so their internal links are omitted where unverified.
Main entry points: engine.py Chat engine · main.js App routing · base.py Backend contract · components.js Shared controls
Components 23
Browser interface
- App routing
src/lobotomy/web/js/main.js - Chat view
src/lobotomy/web/js/views/chat.js - 3D layer stack
src/lobotomy/web/js/views/stack3d.js - Layer view
src/lobotomy/web/js/views/layer.js - Token view
src/lobotomy/web/js/views/token.js - Compare view
src/lobotomy/web/js/views/compare.js - Shared controls
src/lobotomy/web/js/components.js - App state
src/lobotomy/web/js/store.js - API client
src/lobotomy/web/js/api.js
Local API
- HTTP and streaming API
src/lobotomy/server.py
Model runtime
- Chat engine
src/lobotomy/engine.py - GGUF loader
src/lobotomy/gguf_loader.py - Tokenizer
src/lobotomy/tokenizer.py - Model configuration
src/lobotomy/config.py - Backend contract
src/lobotomy/backends/base.py - MLX backend
src/lobotomy/backends/mlx/backend.py - PyTorch backend
src/lobotomy/backends/pytorch/backend.py - Text sampling
src/lobotomy/sampling.py
Inspection and edits
- Activation recordings
src/lobotomy/backends/base.py - Activation analysis
src/lobotomy/analysis.py - Reversible edits
src/lobotomy/edits.py - Edit presets
src/lobotomy/presets.py
Other components
- User
Connections 30
- User → App routing: uses
README.md - App routing → Chat view: routes to
src/lobotomy/web/js/main.js - App routing → Layer view: routes to
src/lobotomy/web/js/main.js - App routing → Token view: routes to
src/lobotomy/web/js/main.js - App routing → Compare view: routes to
src/lobotomy/web/js/main.js - Chat view → 3D layer stack: renders
src/lobotomy/web/js/views/chat.js - Chat view → Shared controls: uses
src/lobotomy/web/js/views/chat.js - Layer view → Shared controls: uses
src/lobotomy/web/js/views/layer.js - Token view → Shared controls: uses
src/lobotomy/web/js/views/token.js - Compare view → Shared controls: uses
src/lobotomy/web/js/views/compare.js - App state → API client: requests
src/lobotomy/web/js/store.js - App routing → App state: loads state
src/lobotomy/web/js/main.js - API client → HTTP and streaming API: HTTP requests
src/lobotomy/web/js/api.js - HTTP and streaming API → Chat engine: dispatches chat
src/lobotomy/server.py - Chat engine → GGUF loader: opens weights
src/lobotomy/engine.py - Chat engine → Tokenizer: uses
src/lobotomy/engine.py - Chat engine → Model configuration: uses
src/lobotomy/engine.py - Chat engine → Backend contract: calls backend
src/lobotomy/engine.py - Backend contract → MLX backend: implemented by
src/lobotomy/backends/mlx/backend.py - Backend contract → PyTorch backend: implemented by
README.md - Chat engine → Text sampling: samples replies
src/lobotomy/engine.py - Backend contract → Activation recordings: produces
src/lobotomy/backends/base.py - Chat engine → Reversible edits: applies and undoes
src/lobotomy/engine.py - Reversible edits → Backend contract: maps to weight ops
src/lobotomy/edits.py - HTTP and streaming API → Activation analysis: computes insights
src/lobotomy/server.py - HTTP and streaming API → Edit presets: lists presets
src/lobotomy/server.py - User → Chat engine: asks and edits
README.md - Activation recordings → 3D layer stack: visualized as activity
README.md - Activation analysis → Layer view: supports inspection
README.md - Edit presets → Shared controls: shown as recipes
src/lobotomy/web/js/components.js