LM Studio Setup Guide for Phase 2 Testing
Why LM Studio?
- ✅ FREE - No API costs
- ✅ Fast - Runs locally on your GPU
- ✅ Private - Your code never leaves your machine
- ✅ DeepSeek-R1 - Strong reasoning for code refactoring
Step 1: Download LM Studio
- Go to https://lmstudio.ai/
- Download for Windows
- Install and launch
Step 2: Download DeepSeek-R1 Model
In LM Studio:
- Click “Search” tab
- Search for:
deepseek-r1-distill-qwen-32b - Recommended model:
bartowski/DeepSeek-R1-Distill-Qwen-32B-GGUF- Download the Q4_K_M quantization (~20GB)
- Good balance of speed and quality
- Fits in 16GB RAM
Alternative (smaller):
DeepSeek-R1-Distill-Qwen-14B- Faster, requires ~10GB RAM
Step 3: Load Model
- Go to “Chat” tab
- Click “Select a model”
- Choose the downloaded DeepSeek-R1 model
- Wait for it to load (shows “Model loaded” in bottom right)
Step 4: Start Local Server
- Click “Local Server” tab (left sidebar)
- Click “Start Server” button
- Default endpoint:
http://localhost:1234/v1 - Keep LM Studio running!
Step 5: Test with Ouroboros
Open PowerShell in your project:
# Activate virtual environment
cd 'g:\Just a Idea'
.\venv\Scripts\Activate.ps1
$env:PYTHONPATH='g:\Just a Idea'
# Test connection
python scripts/generate_refactor_plan.py test-connection --provider lmstudio
# Generate refactor plan (FREE!)
python scripts/generate_refactor_plan.py generate "Rename function foo to bar" --file src/utils.py --provider lmstudio
Configuration Options
Environment Variables (Optional)
# Change LM Studio endpoint (if using different port)
$env:LMSTUDIO_BASE_URL = "http://localhost:1234/v1"
# Set as default provider
$env:REASONER_PROVIDER = "lmstudio"
Update Model Name
If you downloaded a different model, update src/reasoner/config.py:
LMSTUDIO_CONFIG = ModelConfig(
model_name="your-model-name-here", # Match LM Studio
max_tokens=8192,
context_window=32_000,
...
)
Troubleshooting
Error: “Connection refused”
- ✅ Make sure LM Studio Local Server is running
- ✅ Check the port is 1234 (default)
- ✅ Verify model is loaded in Chat tab
Error: “Model not found”
- ✅ Update
model_namein config.py to match LM Studio exactly - ✅ Check model name in LM Studio’s loaded models list
Slow responses
- ✅ Use smaller quantization (Q4_K_M or Q4_K_S)
- ✅ Try 14B model instead of 32B
- ✅ Enable GPU acceleration in LM Studio settings
Performance Tips
- GPU Acceleration:
- LM Studio Settings → Enable GPU offloading
- Set layers to offload = all available
- Context Length:
- Reduce
context_windowin config if model is slow - Start with 16K tokens for faster responses
- Reduce
- Quantization:
- Q4_K_M: Best balance (recommended)
- Q4_K_S: Faster, slightly lower quality
- Q5_K_M: Higher quality, slower
Comparing Providers
| Provider | Cost | Speed | Quality | Context |
|---|---|---|---|---|
| LM Studio (DeepSeek-R1) | FREE | Medium | High | 32K |
| Claude 3.5 Sonnet | $0.06/req | Fast | Highest | 200K |
| OpenAI GPT-4o | $0.025/req | Fast | High | 128K |
| Jamba 1.5 Mini | $0.001/req | Fast | Medium | 256K |
Next Steps
Once LM Studio is working:
- Test with simple refactors: “Rename function X to Y”
- Try complex tasks: “Extract validation logic into separate function”
- Compare quality with mock provider
- When ready, add OpenAI credits for production use
Questions? LM Studio has excellent docs at https://lmstudio.ai/docs