Spaces:
Sleeping
Sleeping
File size: 6,952 Bytes
115612d | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 | # Model Selection Guide for CloudSOC Testing
## Quick Recommendation
**For testing: Start with `gpt-3.5-turbo` or local `Llama 2` via Ollama**
| Model | Cost | Speed | Quality | Setup |
|-------|------|-------|---------|-------|
| **gpt-3.5-turbo** β | $0.50/1M tokens | Fast | Good | 1 min |
| **gpt-4o-mini** | $0.15/1M tokens | Very Fast | Better | 1 min |
| **Llama 2 (Local)** | Free | Slow | Fair | 10 min |
| **Mistral (Local)** | Free | Medium | Good | 10 min |
| gpt-4-turbo | $10/1M tokens | Medium | Excellent | 1 min |
---
## Option 1: Cloud Models (Easiest) β **RECOMMENDED**
### Setup (1 minute)
1. Get API key from [platform.openai.com](https://platform.openai.com/api-keys)
2. Set environment variables:
```bash
# Windows PowerShell
$env:HF_TOKEN = "sk-..." # Your OpenAI API key
$env:API_BASE_URL = "https://api.openai.com/v1"
$env:MODEL_NAME = "gpt-3.5-turbo" # or gpt-4o-mini
```
3. Run test:
```bash
python inference.py --task easy --seed 42 --max_steps 10
```
### Cost Estimates (Easy Task, ~10-15 steps)
- **gpt-3.5-turbo**: $0.01-0.05 per run
- **gpt-4o-mini**: $0.003-0.01 per run
- **gpt-4-turbo**: $0.20-0.50 per run
### Why gpt-3.5-turbo?
β
Cheap ($0.50 per 1M input tokens)
β
Fast (1-2 sec per action)
β
Good at JSON parsing
β
Reliable
β Sometimes verbose/redundant
### Why gpt-4o-mini?
β
Cheaper than 3.5 ($0.15 per 1M)
β
Better reasoning
β
Better JSON quality
β
Faster overall
β
**BEST for testing**
---
## Option 2: Local Models via Ollama (Free but Slow)
### Setup (10 minutes)
1. Install Ollama from [ollama.ai](https://ollama.ai)
2. Pull a model:
```bash
ollama pull mistral # Fast, ~7B params (recommended)
ollama pull llama2 # Slower, ~7B params
ollama pull neural-chat # Medium, ~7B params
```
3. Start Ollama server:
```bash
ollama serve # Runs on http://localhost:11434
```
4. Set environment variables:
```bash
$env:HF_TOKEN = "dummy-token" # Can be anything
$env:API_BASE_URL = "http://localhost:11434/v1"
$env:MODEL_NAME = "mistral" # or llama2
```
5. Run test:
```bash
python inference.py --task easy --seed 42 --max_steps 5
```
### Pros & Cons
β
FREE (no API costs)
β
Private (no data to OpenAI)
β
100% offline
β SLOW (10-30 sec per action)
β Lower reasoning quality
β RAM intensive (~8GB for 7B model)
### Local Model Recommendations
| Model | Size | Speed | Quality | RAM |
|-------|------|-------|---------|-----|
| **Mistral** | 7B | βββ | ββ | 8GB |
| **Llama 2** | 7B | ββ | ββ | 8GB |
| **Neural Chat** | 7B | βββ | ββ | 8GB |
| Phi 2 | 2.7B | ββββ | β | 4GB |
---
## Option 3: Hugging Face Inference API
### Setup (2 minutes)
1. Get Hugging Face token from [huggingface.co/settings/tokens](https://huggingface.co/settings/tokens)
2. Set environment:
```bash
$env:HF_TOKEN = "hf_XXX..."
$env:API_BASE_URL = "https://api-inference.huggingface.co/v1"
$env:MODEL_NAME = "meta-llama/Llama-2-7b-chat-hf" # or another model
```
3. Run test:
```bash
python inference.py --task easy --seed 42
```
### Available Models
- `meta-llama/Llama-2-7b-chat-hf`
- `mistralai/Mistral-7B-Instruct-v0.1`
- `NousResearch/Nous-Hermes-2-Mixtral-8x7B-DPO`
### Pros & Cons
β
Free tier available
β
No GPU needed
β
Wide model selection
β Rate limited
β Variable speed (depends on queue)
β Less reliable than OpenAI
---
## Quick Start Decision Tree
```
Do you have an OpenAI API key?
ββ YES β Use gpt-4o-mini (cheapest, fastest, best)
ββ NO
ββ Do you want to pay for inference?
β ββ YES β Get OpenAI key, use gpt-4o-mini
β ββ NO
β ββ Do you have 8GB+ RAM free?
β ββ YES β Use Ollama + Mistral (free, offline)
β ββ NO β Use Hugging Face Inference API (free tier)
```
---
## Testing Strategy (Recommended)
### Phase 1: Validation (Free/Cheap)
```bash
# Test with gpt-4o-mini (cheapest, $0.003-0.01 per run)
python test_cloudsoc.py --quick # Validates env β
python inference.py --task easy --seed 42 --max_steps 5 # Quick test
```
**Cost:** ~$0.01
**Time:** 2 min
### Phase 2: Medium Testing ($0.05-0.20)
```bash
# Run all 3 difficulty levels
for task in easy medium hard:
python inference.py --task $task --seed 42 --max_steps 50
```
**Cost:** ~$0.15
**Time:** 30 min
### Phase 3: Production (Scale Up)
```bash
# Deploy to Hugging Face Spaces with gpt-4o or gpt-4-turbo
# (if budget allows for better quality)
```
---
## Testing Commands by Model
### gpt-4o-mini (Cloud - RECOMMENDED)
```bash
$env:HF_TOKEN = "sk-..."
$env:MODEL_NAME = "gpt-4o-mini"
$env:API_BASE_URL = "https://api.openai.com/v1"
python inference.py --task easy --seed 42 --max_steps 10
```
### gpt-3.5-turbo (Cloud - Budget)
```bash
$env:HF_TOKEN = "sk-..."
$env:MODEL_NAME = "gpt-3.5-turbo"
python inference.py --task easy --seed 42
```
### Mistral (Local - Free)
```bash
# Terminal 1: Start Ollama
ollama serve
# Terminal 2: Run test
$env:HF_TOKEN = "dummy"
$env:API_BASE_URL = "http://localhost:11434/v1"
$env:MODEL_NAME = "mistral"
python inference.py --task easy --seed 42 --max_steps 5
```
---
## Expected Output (Each Model)
All should produce hackathon-compliant format:
```
[START] task=easy env=cloudsoc model=gpt-4o-mini
[STEP] step=1 action=aws.soc.get_alerts({}) reward=0.00 done=false error=null
[STEP] step=2 action=aws.cloudwatch.query_basic(...) reward=-0.01 done=false error=null
...
[END] success=true steps=N rewards=0.00,-0.01,...
```
---
## My Recommendation
1. **First time / Testing?** β **gpt-4o-mini** (cheapest, best quality)
2. **Budget conscious?** β **gpt-3.5-turbo** (still cheap, good)
3. **Want free?** β **Ollama + Mistral** (free, but slow)
4. **Production quality?** β **gpt-4-turbo** (expensive, best reasoning)
---
## Troubleshooting
### "API key invalid"
β Check your API key is correct
β Make sure you're using the right env var name (HF_TOKEN, not OPENAI_API_KEY)
### "Model not found"
β Check model name spelling
β Verify it's available on your provider
### "Connection refused"
β For local: Make sure `ollama serve` is running
β For cloud: Check internet connection
### "Rate limited"
β Wait a few seconds and retry
β Consider upgrading to paid tier
β Use local model instead
### Model gives bad JSON
β Try `--temperature 0.2` (more deterministic)
β Switch to gpt-4o-mini (better JSON)
β Use simpler task (easy instead of hard)
---
## Cost Comparison (Easy Task, 15 steps)
| Model | Per Run | 100 Runs | Notes |
|-------|---------|----------|-------|
| gpt-4o-mini | $0.01 | $1.00 | Best value β |
| gpt-3.5-turbo | $0.03 | $3.00 | Good value |
| Mistral (local) | $0.00 | $0.00 | Free, slow |
| gpt-4-turbo | $0.30 | $30.00 | Overkill for dev |
---
**TL;DR: Start with gpt-4o-mini ($0.01 per test), or free Ollama locally if you have 8GB RAM.**
|