brainy/docs/MODEL_LOADING_QUICK_REFERENCE.md
David Snelling 26c7d61185 CHECKPOINT: Brainy 2.0 API refactor - pre-fixes state
Current state:
- Unified augmentation system to BrainyAugmentation interface
- Changed methods to specific noun/verb naming (addNoun, getNoun, etc)
- Made old methods private
- Combined getNouns into single unified method
- Neural API exists and is complete
- Triple Intelligence uses correct Brainy operators (not MongoDB)

Issues identified:
- Documentation incorrectly shows MongoDB operators (code is correct)
- Need to ensure all features are properly exposed
- Need to verify nothing was lost in simplification

This commit serves as a rollback point before applying fixes.
2025-08-25 09:52:32 -07:00

83 lines
No EOL
1.9 KiB
Markdown

# 🤖 Model Loading Quick Reference
## 🚀 Common Scenarios
### ✅ Development (Zero Config)
```typescript
const brain = new BrainyData()
await brain.init() // Downloads automatically
```
### 🐳 Docker Production
```dockerfile
RUN npm run download-models
ENV BRAINY_ALLOW_REMOTE_MODELS=false
```
### ☁️ Serverless/Lambda
```bash
# Build step
npm run download-models
# Runtime
export BRAINY_ALLOW_REMOTE_MODELS=false
```
### 🔒 Air-Gapped/Offline
```bash
# Connected machine
npm run download-models
tar -czf brainy-models.tar.gz ./models
# Offline machine
tar -xzf brainy-models.tar.gz
export BRAINY_ALLOW_REMOTE_MODELS=false
```
### 🌐 Browser/CDN
```html
<!-- Automatic - no setup needed -->
<script type="module">
import { BrainyData } from 'brainy'
const brain = new BrainyData()
await brain.init() // Works in browser
</script>
```
## 🚨 Troubleshooting
| Error | Solution |
|-------|----------|
| "Failed to load embedding model" | `npm run download-models` |
| "ENOENT: no such file" | Check `BRAINY_MODELS_PATH` |
| "Network timeout" | Set `BRAINY_ALLOW_REMOTE_MODELS=false` |
| "Permission denied" | `chmod 755 ./models` |
| "Out of memory" | Increase container memory limit |
## 🎯 Environment Variables
| Variable | Values | Purpose |
|----------|--------|---------|
| `BRAINY_ALLOW_REMOTE_MODELS` | `true`/`false` | Allow/block downloads |
| `BRAINY_MODELS_PATH` | `./models` | Model storage path |
| `NODE_ENV` | `production` | Environment detection |
## 📦 Model Info
- **Model**: All-MiniLM-L6-v2
- **Dimensions**: 384 (fixed)
- **Size**: ~80MB download, ~330MB uncompressed
- **Location**: `./models/Xenova/all-MiniLM-L6-v2/`
## ✅ Verification Commands
```bash
# Check models exist
ls ./models/Xenova/all-MiniLM-L6-v2/onnx/model.onnx
# Test offline mode
BRAINY_ALLOW_REMOTE_MODELS=false npm test
# Download fresh models
rm -rf ./models && npm run download-models
```