Vấn đề
Khi bắt đầu build AI features, câu hỏi đầu tiên thường là "dùng model nào?". Năm 2023, câu trả lời đơn giản: "Dùng GPT-4, xong."
Nhưng năm 2026, landscape phức tạp hơn nhiều:
- Qwen3, DeepSeek, Llama 3 có thể run on-premise
- Claude có strengths rất khác so với GPT-4o
- Cost khác nhau 10-50x giữa các models
- Data sovereignty constraints ở nhiều dự án
Tôi hiện tại quản lý 4 AI features trên production - mỗi cái dùng model khác nhau. Đây là cách tôi quyết định.
Giải thích đơn giản: LLM landscape 2026
Hãy phân loại theo 3 trục:
Trục 1: Deployment mode
- Cloud API: GPT-4o (OpenAI), Claude (Anthropic), Gemini (Google)
- On-premise/self-hosted: Qwen3, DeepSeek, Llama 3, Mistral
Trục 2: Capability tier
- Frontier: GPT-4o, Claude 3.5/4.x, Gemini 1.5 Pro - state-of-the-art reasoning
- Advanced: Qwen3-72B, DeepSeek-V3 - very capable, lower cost
- Efficient: Qwen2.5-7B, Llama 3-8B - good enough cho nhiều tasks, very cheap
Trục 3: Strength
- Complex reasoning: Claude > GPT-4o > Qwen3-72B
- Code generation: GPT-4o ≈ Claude ≈ DeepSeek-Coder
- Tiếng Việt: Qwen3 > GPT-4o > Claude (training data)
- Speed: Small models > Large models (self-evident :D)
Framework quyết định: 5 câu hỏi
Q1: "Data có thể ra ngoài không?"
Nếu KHÔNG → On-premise only (Qwen3, DeepSeek, Llama 3)
Nếu CÓ → Có thể dùng cloud API
Q2: "Volume và cost budget?"
Token cost comparison (approximate, 2026):
- GPT-4o: ~$5-15 per 1M tokens
- Claude 3.5 Sonnet: ~$3-15 per 1M tokens
- Qwen3-72B (self-hosted): ~$0.3-0.5 per 1M tokens (infrastructure cost)
- Qwen2.5-7B (self-hosted): ~$0.05 per 1M tokens
Nếu volume > 10M tokens/ngày → self-hosted tiết kiệm hơn rất nhiều.
Q3: "Task complexity?"
Simple extraction, classification, summarization → Small model đủ
Complex reasoning, nuanced analysis → Frontier model cần thiết
Code generation → GPT-4o hoặc DeepSeek-Coder
Q4: "Language?"
Nếu Vietnamese-heavy content → Qwen3 often better than Claude/GPT-4o
Nếu English-only → Claude/GPT-4o excellent
Q5: "Latency requirements?"
Interactive (< 2s): Small model on-premise hoặc cloud API với streaming
Batch processing: Any model
Case studies từ dự án thực
Case 1: Customer support bot (B2C, tiếng Việt)
Constraints: Volume cao, tiếng Việt, acceptable latency 3-5s
Decision: Qwen3-14B self-hosted
Lý do:
- Tiếng Việt tốt hơn Claude/GPT-4o
- Volume ~500k requests/ngày → cloud cost ~$30-75/ngày, self-hosted ~$3/ngày
- 14B parameters đủ cho FAQ-style responses, không cần GPT-4o
Case 2: Contract review và legal analysis
Constraints: Data sensitivity, complex reasoning required, low volume
Decision: Claude API (claude-opus hoặc claude-sonnet)
Lý do:
- Documents không thể ra ngoài? → Phải dùng on-premise hoặc private cloud deployment
- Nếu được phép: Claude rất mạnh về long document analysis, nuanced reasoning
- Volume thấp (~1000 requests/ngày) → Cost acceptable
Case 3: Code generation trong IDE tool
Decision: GPT-4o hoặc Claude với streaming
Lý do:
- Code generation: GPT-4o và Claude Sonnet đều excellent
- Streaming quan trọng cho UX
- Data (code) thường ít sensitive hơn
Case 4: Batch data processing / classification
Decision: Qwen2.5-7B self-hosted
Lý do:
- Volume cực lớn (millions of items)
- Task đơn giản (classify, extract structured data)
- Speed over accuracy acceptable
- Cost là factor quyết định
Code minh họa: Multi-LLM Router
public interface ILLMClient
{
Task<string> CompleteAsync(string prompt, CompletionOptions options);
}
public class MultiLLMRouter
{
private readonly ILLMClient _claudeClient;
private readonly ILLMClient _gpt4oClient;
private readonly ILLMClient _qwenOnPremiseClient;
public async Task<string> RouteAsync(
string prompt,
LLMRoutingContext context)
{
var selectedClient = SelectClient(context);
return await selectedClient.CompleteAsync(prompt, context.Options);
}
private ILLMClient SelectClient(LLMRoutingContext context)
{
// Data sovereignty check
if (context.DataClassification == DataClassification.Sensitive)
return _qwenOnPremiseClient;
// Language preference
if (context.PrimaryLanguage == "vi" && context.Complexity < ComplexityLevel.High)
return _qwenOnPremiseClient;
// High volume, simple tasks
if (context.MonthlyVolumeEstimate > 1_000_000 && context.Complexity == ComplexityLevel.Low)
return _qwenOnPremiseClient;
// Complex reasoning tasks → Claude
if (context.TaskType == TaskType.Reasoning || context.TaskType == TaskType.LongDocumentAnalysis)
return _claudeClient;
// Code generation → GPT-4o or Claude (similar quality)
if (context.TaskType == TaskType.CodeGeneration)
return _gpt4oClient;
// Default: Claude Sonnet (good balance)
return _claudeClient;
}
}
// Usage
public class AIFeatureService
{
private readonly MultiLLMRouter _router;
public async Task<string> AnalyzeContractAsync(string contractText, bool isSensitive)
{
var context = new LLMRoutingContext
{
DataClassification = isSensitive
? DataClassification.Sensitive
: DataClassification.Internal,
TaskType = TaskType.LongDocumentAnalysis,
Complexity = ComplexityLevel.High,
PrimaryLanguage = "vi"
};
return await _router.RouteAsync(
BuildContractAnalysisPrompt(contractText),
context);
}
}
Monitoring và cost tracking
Với multi-LLM system, tracking cost là critical:
public class LLMUsageTracker
{
public async Task TrackAsync(LLMRequest request, LLMResponse response)
{
await _metricsStore.RecordAsync(new LLMUsageMetric
{
Provider = request.Provider, // "claude", "gpt4o", "qwen-on-prem"
Model = request.Model,
InputTokens = response.Usage.InputTokens,
OutputTokens = response.Usage.OutputTokens,
EstimatedCost = CalculateCost(request.Provider, response.Usage),
TaskType = request.TaskType,
Latency = response.LatencyMs,
Timestamp = DateTime.UtcNow
});
}
private decimal CalculateCost(string provider, TokenUsage usage)
{
return provider switch
{
"claude" => (usage.InputTokens * 0.000003m) + (usage.OutputTokens * 0.000015m),
"gpt4o" => (usage.InputTokens * 0.000005m) + (usage.OutputTokens * 0.000015m),
"qwen-on-prem" => (usage.InputTokens + usage.OutputTokens) * 0.0000003m, // infra cost
_ => 0
};
}
}
Best practices
- Start single, go multi when needed. Đừng implement multi-LLM từ đầu nếu không cần.
- Track cost từ ngày 1. Surprise cost bill là điều tệ nhất với AI features.
- Abstract LLM provider. Code của bạn không nên biết đang dùng Claude hay GPT - dùng interface.
- Fallback strategy. Nếu primary LLM down, fallback sang alternative. Đặc biệt quan trọng với on-premise.
- Evaluate regularly. Model landscape thay đổi nhanh - 6 tháng một lần review xem có model tốt hơn không.
/Son Do - believe in basic
#1percentbetter #AIArchitecture #LLM #Claude #GPT4o #Qwen #MultiLLM