How unslothai/unsloth works
Unsloth is a desktop and web-based environment for running and training local AI models, with Unsloth Core also available as a code library. The principal workflow is a user choosing or supplying a model, Studio dispatching inference to a local engine, and the interface presenting the result. The product also covers chat tools and browser use, image/video generation, data preparation and fine-tuning, export, and remote/API access. Source excerpts are partial, so unverified runtime links are omitted or marked dashed rather than inferred from directory structure.
Main entry points: features Studio interface · llama_cpp.py Model engines · main.py Studio backend · inference.py Inference routes
Components 21
Studio application
- Desktop shell
studio/src-tauri/src/main.rs - Studio interface
studio/frontend/src/features - Accounts and keys
studio/backend/auth/storage.py - Chat API
studio/frontend/src/features/chat/api/chat-api.ts - Chat history
studio/frontend/src/features/chat/utils/chat-history-storage.ts
Model runtime
- Studio backend
studio/backend/main.py - Inference routes
studio/backend/routes/inference.py - Managed chat
studio/backend/routes/managed_engine_chat.py - Model engines
studio/backend/core/inference/llama_cpp.py - Engine setup
studio/backend/core/inference/engine_install.py - Hardware detection
studio/backend/utils/hardware/hardware.py - Image and video
studio/backend/core/inference - Search and RAG
studio/backend/core/rag
Training and data
- Data recipes
studio/backend/core/data_recipe - Fine-tuning
unsloth - Model export
studio/backend/core/export
Tools and deployment
- Agents and tools
studio/backend/core/inference - Remote access
studio/backend/cloudflare_tunnel.py - OpenAI-compatible API
studio/backend/routes - Unsloth CLI
unsloth_cli/commands/inference.py
Other components
- User
Connections 23
- User → Desktop shell: opens app
README.md - User → Studio interface: uses Studio
README.md - Studio interface → Studio backend: requests services
- Studio backend → Accounts and keys: checks credentials
- Studio interface → Chat API: submits chat
studio/frontend/src/features/chat/prompt-storage/prompt-storage-dialog.tsx - Chat API → Inference routes: sends requests
- Chat history → Chat API: syncs messages
studio/frontend/src/features/chat/utils/chat-history-storage.ts - Inference routes → Managed chat: dispatches chat
studio/backend/routes/managed_engine_chat.py - Managed chat → Model engines: streams generation
studio/backend/routes/managed_engine_chat.py - Inference routes → Model engines: runs inference
- Model engines → Hardware detection: selects device
studio/backend/utils/hardware/hardware.py - Studio backend → Engine setup: manages engines
- Studio interface → Image and video: requests generation
README.md - Studio interface → Search and RAG: uses retrieval
README.md - Studio interface → Data recipes: builds datasets
README.md - Data recipes → Fine-tuning: prepares data
- Studio interface → Fine-tuning: starts training
README.md - Fine-tuning → Model export: exports models
README.md - Studio interface → Agents and tools: uses tools
README.md - Agents and tools → Model engines: uses local models
README.md - User → Unsloth CLI: runs CLI
README.md - Model engines → Remote access: serves remotely
README.md - Model engines → OpenAI-compatible API: serves API
README.md