Skip to content

Commit e08e1f1

Browse files
committed
Docs: Added Models CLI Docs
1 parent cf0e792 commit e08e1f1

File tree

1 file changed

+320
-0
lines changed

1 file changed

+320
-0
lines changed

docs/guides/model-management.md

Lines changed: 320 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,321 @@
1+
# 🤖 Model Management Guide
12

3+
LocalLab provides comprehensive model management capabilities through the `locallab models` command group. This allows you to download, manage, and organize AI models locally before starting the server.
4+
5+
## 📋 Overview
6+
7+
The model management system helps you:
8+
- **Download models locally** for offline use and faster startup
9+
- **List cached models** with detailed information
10+
- **Remove models** to free up disk space
11+
- **Discover available models** from registries and HuggingFace Hub
12+
- **Get detailed model information** including system compatibility
13+
- **Clean up cache** to remove orphaned files
14+
15+
## 🚀 Quick Start
16+
17+
```bash
18+
# Discover available models
19+
locallab models discover
20+
21+
# Download a model
22+
locallab models download microsoft/DialoGPT-medium
23+
24+
# List your cached models
25+
locallab models list
26+
27+
# Get detailed information about a model
28+
locallab models info microsoft/DialoGPT-medium
29+
30+
# Remove a model to free space
31+
locallab models remove microsoft/DialoGPT-medium
32+
```
33+
34+
## 📖 Command Reference
35+
36+
### List Models {#list-models}
37+
38+
List all locally cached models with detailed information.
39+
40+
```bash
41+
locallab models list [OPTIONS]
42+
```
43+
44+
**Options:**
45+
- `--format [table|json]` - Output format (default: table)
46+
- `--registry-only` - Show only registry models
47+
- `--custom-only` - Show only custom models
48+
49+
**Examples:**
50+
```bash
51+
# List all cached models in table format
52+
locallab models list
53+
54+
# List only registry models
55+
locallab models list --registry-only
56+
57+
# Export model list as JSON
58+
locallab models list --format json
59+
```
60+
61+
**Output includes:**
62+
- Model ID and name
63+
- Size on disk
64+
- Cache status and date
65+
- Model type (Registry/Custom)
66+
- Brief description
67+
68+
### Download Models {#download-models}
69+
70+
Download a model locally for offline use and faster server startup.
71+
72+
```bash
73+
locallab models download <model_id> [OPTIONS]
74+
```
75+
76+
**Options:**
77+
- `--force` - Force re-download even if model exists
78+
- `--no-cache-update` - Skip updating cache metadata
79+
80+
**Examples:**
81+
```bash
82+
# Download a registry model
83+
locallab models download microsoft/DialoGPT-medium
84+
85+
# Download a custom HuggingFace model
86+
locallab models download huggingface/CodeBERTa-small-v1
87+
88+
# Force re-download an existing model
89+
locallab models download microsoft/DialoGPT-medium --force
90+
```
91+
92+
**Features:**
93+
- Progress bar with download speed and ETA
94+
- Automatic validation of downloaded files
95+
- Integration with HuggingFace Hub authentication
96+
- Graceful error handling and retry logic
97+
- Cache metadata tracking
98+
99+
### Remove Models {#remove-models}
100+
101+
Remove locally cached models to free up disk space.
102+
103+
```bash
104+
locallab models remove <model_id> [OPTIONS]
105+
```
106+
107+
**Options:**
108+
- `--force` - Skip confirmation prompt
109+
110+
**Examples:**
111+
```bash
112+
# Remove a model with confirmation
113+
locallab models remove microsoft/DialoGPT-medium
114+
115+
# Remove without confirmation
116+
locallab models remove microsoft/DialoGPT-medium --force
117+
```
118+
119+
**Safety features:**
120+
- Confirmation prompt by default
121+
- Shows model size before removal
122+
- Cleans up all associated files
123+
- Updates cache metadata
124+
125+
### Discover Models {#discover-models}
126+
127+
Discover available models from the LocalLab registry and HuggingFace Hub.
128+
129+
```bash
130+
locallab models discover [OPTIONS]
131+
```
132+
133+
**Options:**
134+
- `--search <term>` - Search models by name or description
135+
- `--limit <number>` - Maximum number of models to show (default: 20)
136+
- `--format [table|json]` - Output format (default: table)
137+
138+
**Examples:**
139+
```bash
140+
# Discover all available models
141+
locallab models discover
142+
143+
# Search for specific models
144+
locallab models discover --search "dialog"
145+
146+
# Limit results and export as JSON
147+
locallab models discover --limit 10 --format json
148+
```
149+
150+
**Information shown:**
151+
- Model ID and name
152+
- Model size and type
153+
- Cache status (cached/available)
154+
- Brief description
155+
- Download availability
156+
157+
### Model Information {#model-info}
158+
159+
Get detailed information about a specific model.
160+
161+
```bash
162+
locallab models info <model_id>
163+
```
164+
165+
**Examples:**
166+
```bash
167+
# Get detailed info about a model
168+
locallab models info microsoft/DialoGPT-medium
169+
```
170+
171+
**Information includes:**
172+
- Model name and description
173+
- Size and requirements
174+
- Local cache status and location
175+
- System compatibility check
176+
- Available actions (download/remove)
177+
- Fallback model information
178+
179+
### Cache Cleanup {#cache-cleanup}
180+
181+
Clean up orphaned cache files and free disk space.
182+
183+
```bash
184+
locallab models clean
185+
```
186+
187+
**Features:**
188+
- Finds empty model directories
189+
- Identifies temporary and lock files
190+
- Shows what will be cleaned before removal
191+
- Confirmation prompt for safety
192+
- Reports space freed after cleanup
193+
194+
## 💾 Cache Management
195+
196+
### Cache Location
197+
198+
Models are cached in the standard HuggingFace Hub cache directory:
199+
- **Windows**: `%USERPROFILE%\.cache\huggingface\hub`
200+
- **macOS/Linux**: `~/.cache/huggingface/hub`
201+
202+
You can override this location by setting the `HF_HOME` environment variable.
203+
204+
### Cache Structure
205+
206+
```
207+
~/.cache/huggingface/hub/
208+
├── models--microsoft--DialoGPT-medium/
209+
│ ├── refs/
210+
│ ├── snapshots/
211+
│ └── blobs/
212+
└── models--huggingface--CodeBERTa-small-v1/
213+
├── refs/
214+
├── snapshots/
215+
└── blobs/
216+
```
217+
218+
### Metadata Tracking
219+
220+
LocalLab maintains additional metadata in `~/.locallab/model_cache.json`:
221+
- Download timestamps
222+
- Access counts
223+
- Download methods
224+
- Custom model information
225+
226+
## 🔧 Advanced Usage
227+
228+
### Environment Variables
229+
230+
- `HF_HOME` - Override HuggingFace cache directory
231+
- `HF_TOKEN` - HuggingFace authentication token for private models
232+
233+
### Integration with Server
234+
235+
Downloaded models are automatically available when starting the LocalLab server:
236+
237+
```bash
238+
# Download model first
239+
locallab models download microsoft/DialoGPT-medium
240+
241+
# Start server - model loads faster from cache
242+
locallab start --model microsoft/DialoGPT-medium
243+
```
244+
245+
### Batch Operations
246+
247+
Use shell scripting for batch operations:
248+
249+
```bash
250+
# Download multiple models
251+
for model in "microsoft/DialoGPT-medium" "microsoft/DialoGPT-large"; do
252+
locallab models download "$model"
253+
done
254+
255+
# Clean up old models
256+
locallab models list --format json | jq -r '.[] | select(.size > 1000000000) | .id' | \
257+
xargs -I {} locallab models remove {} --force
258+
```
259+
260+
## 🚨 Troubleshooting
261+
262+
### Common Issues
263+
264+
**Download fails with authentication error:**
265+
```bash
266+
# Set HuggingFace token
267+
export HF_TOKEN="your_token_here"
268+
locallab models download private/model
269+
```
270+
271+
**Model not found:**
272+
```bash
273+
# Check if model exists in registry
274+
locallab models discover --search "model_name"
275+
276+
# Try with full HuggingFace model ID
277+
locallab models download organization/model-name
278+
```
279+
280+
**Cache corruption:**
281+
```bash
282+
# Clean up corrupted cache
283+
locallab models clean
284+
285+
# Force re-download
286+
locallab models download model_id --force
287+
```
288+
289+
**Disk space issues:**
290+
```bash
291+
# Check cache size
292+
locallab models list
293+
294+
# Remove large unused models
295+
locallab models remove large_model_id
296+
297+
# Clean orphaned files
298+
locallab models clean
299+
```
300+
301+
### Getting Help
302+
303+
```bash
304+
# Get help for any command
305+
locallab models --help
306+
locallab models download --help
307+
locallab models list --help
308+
```
309+
310+
## 📊 Best Practices
311+
312+
1. **Download models before first use** for faster server startup
313+
2. **Regularly clean cache** to free up disk space
314+
3. **Use registry models** when possible for better support
315+
4. **Check system compatibility** before downloading large models
316+
5. **Set HF_TOKEN** for accessing private models
317+
6. **Monitor disk usage** with `locallab models list`
318+
319+
---
320+
321+
For more information, see the [CLI Reference](../cli/README.md) or [Configuration Guide](./configuration.md).

0 commit comments

Comments
 (0)