Vấn đề
Khi dùng cloud AI tools, có một câu hỏi luôn là:
"Code của tôi có thực sự private không?"
Với:
- Proprietary algorithms
- Healthcare/finance regulations
- Internal APIs và credentials
- Client code under NDA
Cloud AI có thể không phải option.
Nhưng bạn vẫn muốn AI assistance. Ollama là câu trả lời.
Ollama là gì?
Ollama là local runtime cho open-source AI models. Giống như Docker cho containers, nhưng cho AI models.
# Cài đặt
curl -fsSL https://ollama.com/install.sh | sh
# Pull và chạy model
ollama pull llama3
ollama pull mistral
ollama pull codellama
# Sử dụng
ollama run llama3 "Explain this code:"
Supported Models cho Coding
| Model | Size | Best For |
|---|---|---|
| Llama3 | 8B/70B | General coding |
| Mistral | 7B | Fast responses |
| Codellama | 7B/13B | Code-optimized |
| Qwen2.5-Coder | 7B | Coding-specific |
| DeepSeek-Coder | 6.7B | Code generation |
Setup: Privacy-first Coding Environment
1. Ollama + VS Code
# Cài Ollama
brew install ollama # macOS
# Windows: winget install Ollama.Ollama
# Pull Codellama
ollama pull codellama:7b
# Install VS Code extension: "Ollama"
# (Search marketplace)
2. Ollama + Cline (BYOK Alternative)
# Cline đã hỗ trợ Ollama
# Setting > Cline > Advanced > Ollama API
#
# Endpoint: http://localhost:11434
# Model: codellama:7b
3. Ollama + OpenCode
# OpenCode với Ollama
opencode --provider local --model codellama:7b
Performance: So sánh Local vs Cloud
| Metric | Ollama (Codellama 7B) | Claude Code Pro |
|---|---|---|
| Setup | Local | Cloud |
| Privacy | 100% (code never leaves) | Partial (data processing) |
| Cost | Hardware only | $20-200/tháng |
| Speed | Depends on hardware | Fast |
| Quality | Good (code-specialized) | Best (frontier models) |
| Context window | 4K-16K (model dependent) | 200K |
Trade-off: Privacy vs Quality.
Khi nào Local AI đủ tốt
Đủ tốt cho:
- Code review — quick feedback, privacy maintained
- Documentation generation — không cần frontier model
- Boilerplate code — templates, standard patterns
- Debug assistance — explain errors, suggest fixes
- Learning — explain concepts, patterns
Không đủ cho:
- Complex refactors — frontier models better
- Architectural decisions — need deeper reasoning
- Production code generation — quality matters
- Long context tasks — limited window
Ollama trong CI/CD
# .github/workflows/ai-review.yml
name: Local AI Code Review
on: [pull_request]
jobs:
review:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Start Ollama
run: |
docker run -d -p 11434:11434 \
-v ollama:/root/.ollama \
ollama/ollama:latest
- name: Run Code Review
run: |
# Use Cline with Ollama backend
CLINE_OLLAMA_ENDPOINT=http://localhost:11434 \
npx cline review --diff ${{ github.event.pull_request.diff }}
Enterprise Use Cases
Ollama đặc biệt hữu ích cho:
- Regulated industries — Healthcare, fintech, legal
- Proprietary code — IP protection mandatory
- Air-gapped environments — no internet access
- Cost-sensitive teams — hardware cheaper than subscriptions
Case Study: Healthcare Startup
"Chúng tôi cần AI assist cho developers nhưng không thể gửi patient data ra ngoài. Ollama + Codellama cho phép developers get AI assistance locally. Code never leaves our network."
Setup Guide: macOS/Windows
macOS
# 1. Install
brew install ollama
# 2. Start service
brew services start ollama
# 3. Pull models
ollama pull codellama:7b
ollama pull llama3
# 4. API available at
# http://localhost:11434
Windows
# 1. Download từ ollama.com
# 2. Install
# 3. PowerShell:
ollama serve
# Another terminal:
ollama pull codellama:7b
So sánh: Ollama vs Tabby vs Continue.dev
| Feature | Ollama | Tabby | Continue.dev |
|---|---|---|---|
| Models | 100+ | Code-specialized | Multiple |
| Setup | Self-contained | Self-hosted | Extension |
| Privacy | Full local | Full local | BYOK |
| Code quality | Good | Good | Varies |
| Ease of use | High | Medium | High |
Góc nhìn từ team BKGlobal
Tại BKGlobal, chúng tôi recommend Ollama cho:
- Projects with privacy requirements — client code, proprietary algorithms
- Learning environments — students, training
- Cost-sensitive teams — hardware investment vs subscription
Khi nào chọn Ollama:
- Privacy is paramount
- Budget doesn't allow Claude Code subscription
- Air-gapped or restricted environment
Khi nào chọn cloud AI:
- Maximum quality required
- Complex reasoning tasks
- Long context needs
Hybrid approach: Ollama for simple tasks, Claude Code for complex — balance privacy và quality.
Takeaway
Ollama enables privacy-first AI coding — code never leaves your machine, no subscription costs, good enough for most tasks.
Đáng để setup nếu:
- Bạn có privacy requirements
- Bạn muốn reduce subscription costs
- Bạn thoải mái với slightly lower quality cho simple tasks
Setup takes < 10 minutes, models download automatically.
Son Do — BKGlobal Tech Team