Prompt ada di codebase β ganti prompt = deploy ulang (slow)
Tidak ada version history β βsiapa yang ngubah prompt kemarin?β
Tidak ada A/B testing β βapakah prompt baru lebih bagus?β
Prompt berantakan β inline string panjang di Python file
Prompt Management Tools
Tool
Versioning
A/B Test
Deploy Rollback
API
Self-host
Langfuse Prompts
β Git-like
β
β
β REST/SDK
β
LangSmith Hub
β
β
β
β
β
Portkey
β
β
β
β
β
Agenta
β
β
β
β
β
Prompt Engineering Workflow di Production
Dev: Tulis prompt di Langfuse UI atau code β test dengan dataset
Review: Bandingkan output old vs new prompt
Deploy: Publish version baru β SDK tarik versi terbaru secara real-time
Monitor: Bandingkan skor evaluasi antara prompt version
Rollback: Rollback ke versi sebelumnya 1 klik (tanpa deploy code)
Vector Database Operations
Index Maintenance
Operation
Frequency
Impact
Notes
Index Build
Once (initial)
Full rebuild β semua data
Pakai IVFFlat untuk fast build pertama
Incremental Insert
Continuous
Minimal β HNSW support dynamic insert
Tidak perlu rebuild
Index Optimize
Weekly / after bulk insert
Medium β rebuild HNSW graph
Vacuum + optimize
Reindex (full)
Monthly / schema change
High β downtime
Swap index, not rebuild in-place
Prune (delete)
As needed
Medium β tombstone segments
Rebuild after many deletes
Indexing Strategy
Strategy
Write Volume
Query Latency
Memory
Best For
Immediate index
Low
Low
High
Production, <100K docs
Batch index (interval)
High
Medium
Medium
Streaming pipeline
Hybrid (immediate + batch)
Variable
Low-Medium
High
Production, any scale
Separate indexes (hot/warm)
N/A
Hot=Low, Warm=Medium
Optimized
Tiered storage (SSD+HDD)
Monitoring Vector DB
Metric
What It Tells
Action If Bad
Recall@k
Fraction of relevant results in top-k
Reindex, check embedding model
Index fullness
% of capacity used
Scale up or prune
Avg query latency
Search speed
Optimize HNSW ef_construction, ef_search
Index size on disk
Storage cost
Quantization (SQ/PC)
Delete/update throughput
Churn rate
Schedule rebuild during low traffic
Cost Tracking & Optimization
LLM Cost Breakdown
Component
% of Total
Optimization
LLM API calls
60-80%
Model routing, caching, prompt compression
Vector DB
5-10%
Index optimization, tiered storage
Embedding
5-15%
Cache embeddings, batch embed
GPU serving (self-host)
10-30%
vLLM, quantization, batching
Infrastructure (network, k8s)
5-10%
Reserved instances, spot
Cost Optimization Strategies
1. Model Routing
# Cheap model untuk simple task, expensive untuk complexroute = { "classification": "gpt-4o-mini", # $0.15/1M tokens "summarization": "claude-3-haiku", # $0.25/1M "complex_reasoning": "claude-3-opus", # $15/1M "code_generation": "deepseek-v4", # $1/1M}
2. Semantic Caching
Cache response untuk query yang semantically mirip (bukan exact match).
Tanpa KV cache: tiap token baru recompute semua attention β O(nΒ²)
Dengan KV cache: simpan Key/Value dari token sebelumnya β O(n)
Ukuran KV cache per request:
2 (key+value) Γ n_layers Γ d_model Γ seq_len Γ precision
Llama 70B: ~1.5GB per request pada seq_len=4096
Production Deployment
Architecture Reference
User β Load Balancer β Guardrails β Router β LLM Provider
β
ββββββββββ΄βββββββββ
β β
Cache Hit Cache Miss
β β
Return Cache RAG Pipeline
β
Vector DB Query
β
LLM Call + Observability
β
Response + Cost Log
β
Return to User