TinkerLab
01 // HOMELABApple Silicon MacNVIDIA GPUStreaming / API~10 min read & lab

DeepSeek-R1 & Qwen2.5-Coder Local IDE Setup: <think> Token Budgets, FIM Autocomplete & Loop Fixes

Why using DeepSeek-R1 for tab autocomplete ruins IDE latency—and how to pair R1-14B (for architectural reasoning with 4K <think> budget) alongside Qwen2.5-Coder-7B (for sub-250ms FIM edits).

[KEY VERIFIED TAKEAWAY / TL;DR]In Tinker AI Lab's reproducible verification of "DeepSeek-R1 & Qwen2.5-Coder Local IDE Setup: <think> Token Budgets, FIM Autocomplete & Loop Fixes" (tested on MacBook Pro M3 Max (36GB Unified) & NVIDIA RTX 4070 Ti Super (16GB VRAM) with Ollama 0.5.7, Continue v1.0.x (VS Code), deepseek-r1:14b, qwen2.5-coder:7b, verified 2026-10-23): Why using DeepSeek-R1 for tab autocomplete ruins IDE latency—and how to pair R1-14B (for architectural reasoning with 4K <think> budget) alongside Qwen2.5-Coder-7B (for sub-250ms FIM edits). Offline capability is classified as "100% Air-Gapped Source Code Privacy" (All repository indexing (`bge-m3`), FIM tab completion, and multi-file refactoring stay strictly on localhost.), with key operational boundary: Never assign a reasoning model (`deepseek-r1`) to `tabAutocompleteModel`: it emits `<think>` tokens before every line completion, adding 3–8 seconds of lag.
REPRODUCIBILITY MANIFEST // TESTED SPECS & LIMITS
Last Verified: 2026-10-23
Tested Hardware & OS

MacBook Pro M3 Max (36GB Unified) & NVIDIA RTX 4070 Ti Super (16GB VRAM)

Pinned Stack & Model Versions
Ollama 0.5.7Continue v1.0.x (VS Code)deepseek-r1:14bqwen2.5-coder:7b
Offline & Network Boundary
100% Air-Gapped Source Code Privacy

All repository indexing (`bge-m3`), FIM tab completion, and multi-file refactoring stay strictly on localhost.

Known Limits & Failure Modes
  • Never assign a reasoning model (`deepseek-r1`) to `tabAutocompleteModel`: it emits `<think>` tokens before every line completion, adding 3–8 seconds of lag.
  • Setting `temperature: 0` on quantized DeepSeek-R1 distill models causes repetitive self-doubt loops ("Wait, let me re-verify..."); always use `temperature: 0.6, top_p: 0.95`.
Hit an edge-case failure?Open Troubleshooter →

1. Role Separation: Reasoning Model (Architect) vs FIM Model (Tab Edit)

Local coding assistants perform best when split into two specialized models: 1. **Architect & Bug Analyzer (`deepseek-r1:14b`)**: Spends 600–1,800 tokens inside `<think>...</think>` analyzing race conditions or multi-file refactors before writing code. Needs `maxTokens >= 4096` and `contextLength: 16384`. 2. **Fast Edit & Tab Autocomplete (`qwen2.5-coder:7b`)**: Trained natively on Fill-In-the-Middle (FIM) tokens (`<|fim_prefix|>`, `<|fim_suffix|>`). Delivers first-token latency under 180ms without chain-of-thought overhead.
Table 1: Local Coding Model Role, Token Budget & Latency Matrix (M3 Max 36GB / RTX 16GB)
IDE TaskRecommended ModelAvg <think> OverheadTime to Usable Code
Tab FIM Autocompleteqwen2.5-coder:7b (Q4_K_M)0 tokens (Direct FIM)140–220 ms
Tab Autocomplete (Misconfigured)deepseek-r1:14b (Anti-pattern!)350–900 <think> tokens6.5–14.0 s (Unusable)
Multi-File Bug Root-Cause Analysisdeepseek-r1:14b (temp=0.6)850–1,750 <think> tokens18–32 s (High accuracy)

2. Stripping `<think>` Blocks in Automated Scripts & Workflows

When calling `deepseek-r1` from a script or workflow to generate structured JSON or code patches, remember that `max_tokens` (`num_predict`) limits the **sum** of `<think>` tokens plus the final answer. If `num_predict` is left at 1024, the model often truncates mid-thought before `</think>`. Budget at least `4096` output tokens and strip the `<think>...</think>` block with a regex before parsing.
Safe DeepSeek-R1 Response Extractor (Strips <think> & Validates Closure)
export function extractR1FinalAnswer(rawText) {
  if (rawText.includes('<think>') && !rawText.includes('</think>')) {
    throw new Error('DeepSeek-R1 exhausted max_tokens inside <think> before emitting final code');
  }
  return rawText.replace(/<think>[\s\S]*?<\/think>/gi, '').trim();
}

3. Local Codebase Indexing (`@codebase`) with `bge-m3` & `.continueignore`

To let your local coding assistant search across your repository (`@codebase` in Continue), configure `"embeddingsProvider": { "provider": "ollama", "model": "bge-m3" }`. Create a `.continueignore` file at the project root excluding `dist/`, `node_modules/`, `.git/`, `*.lock`, and `*.min.js` so initial indexing completes in seconds and never pollutes context windows with generated build artifacts.
FIELD Q&A // 常见实测疑问与边界解答

Frequently Asked Questions & Edge Cases

Q: Can I keep both `deepseek-r1:14b` and `qwen2.5-coder:7b` loaded in memory at the same time?

On a 24GB GPU (RTX 3090/4090) or 36GB+ Mac, yes: `deepseek-r1:14b` (Q4_K_M, ~10.5 GB with Q8_0 KV) + `qwen2.5-coder:7b` (~5.2 GB) totals ~15.7 GB. On a 12GB–16GB machine, use `deepseek-r1:7b` + `qwen2.5-coder:1.5b` so both stay 100% on GPU.

Q: How do I stop DeepSeek-R1 from over-thinking for 2,000 tokens on simple coding questions?

Route quick single-function edits (`Cmd+I` inline edit) to `qwen2.5-coder:7b` or `qwen2.5-coder:14b` (non-reasoning instruct models), and reserve `deepseek-r1` specifically for architectural planning or tricky bug root-cause analysis.

REPRODUCIBLE ARTIFACT // 配套可参数化附件

Continue / VS Code Dual-Model Local Coding Config (DeepSeek-R1 + Qwen2.5-Coder)

Separates architectural reasoning (DeepSeek-R1 with 16K context & 4K max_tokens for <think>) from sub-200ms tab autocomplete (Qwen2.5-Coder-7B).

config.continue-local-r1.json ↗
Edit variables above to update the configuration live
{
  "models": [
    {
      "title": "Local DeepSeek-R1 (Architect & Debugger)",
      "provider": "ollama",
      "model": "deepseek-r1:14b",
      "apiBase": "http://127.0.0.1:11434",
      "contextLength": 16384,
      "completionOptions": {
        "temperature": 0.6,
        "topP": 0.95,
        "maxTokens": 4096
      }
    },
    {
      "title": "Local Qwen2.5-Coder (Fast Edit)",
      "provider": "ollama",
      "model": "qwen2.5-coder:7b",
      "apiBase": "http://127.0.0.1:11434",
      "contextLength": 16384,
      "completionOptions": {
        "temperature": 0.1,
        "maxTokens": 2048
      }
    }
  ],
  "tabAutocompleteModel": {
    "title": "Qwen2.5-Coder FIM Autocomplete",
    "provider": "ollama",
    "model": "qwen2.5-coder:7b",
    "apiBase": "http://127.0.0.1:11434",
    "completionOptions": {
      "maxTokens": 256,
      "temperature": 0.05
    }
  },
  "embeddingsProvider": {
    "provider": "ollama",
    "model": "bge-m3",
    "apiBase": "http://127.0.0.1:11434"
  }
}

More Reproducible Engineering Guides

View All 42 Guides →