LLM Selection and Deployment: Architecture, Specifications, Cost, and Data Security
Large language models have evolved from simple text generators into versatile platforms capable of reasoning, writing code, and invoking external systems. When deploying LLMs in an enterprise environment, four key questions must be answered: which architecture to choose, which specification to select, how to control costs, and how to ensure data security. This article explores these four aspects and provides actionable, item-by-item checklists for each.
Large language models have evolved from simple text generators into versatile platforms capable of reasoning, writing code, and invoking external systems. When deploying LLMs in an enterprise environment, four key questions must typically be answered: which architecture to choose, which specification to select, how to control costs, and how to ensure data security. This article explores these four questions and provides actionable, item-by-item inspection methods for each.
1. Key Takeaways
- Architecture Selection: Look at both unit inference cost and VRAM footprint simultaneously. Total parameter count is just one number.
- Specification Selection: Evaluate using your own real-world tasks first, then refer to public leaderboards.
- Cost Calculation: Price input and output tokens separately, and include the costs of cache misses, retries, and tool calls.
- Deployment: Before launching an Agent or RAG system, define tool permissions and data access boundaries first.
2. How Mixture of Experts (MoE) Architecture Saves Compute
Traditional dense models activate all parameters during every inference. MoE models split the feedforward network into multiple expert networks. A gating network (router) selects the top-scoring experts for each token, computing only the outputs of those few experts. While the model’s total parameter count can be massive, the parameters actually involved in computation per token represent only a fraction.
You can think of this as a triage desk: a request goes through triage first, then gets handed off to the appropriate department. If the triage makes a mistake, no matter how professional the department is, it won’t help.
This design comes with two often-overlooked costs:
First, expert parameters typically must reside in VRAM constantly. Although compute is reduced, the VRAM requirement does not necessarily decrease proportionally. Whether you can save VRAM depends on whether the deployment framework supports expert offloading and whether multi-GPU sharding is employed. During selection, estimate VRAM usage independently; do not just look at the activated parameters.
Second, routing is prone to imbalance. If most tokens converge on a few experts, those experts become bottlenecks while the rest sit idle. In engineering, an auxiliary load balancing loss is usually added to constrain routing, alongside an expert capacity factor. Tokens exceeding capacity are either dropped or routed through alternative paths. If the capacity factor is too small, quality degrades; if too large, compute is wasted. When inspecting, track two metrics: the ratio of dropped tokens and the load variance across experts.
3. How to Choose the Right Model Specification
The same provider usually offers multiple specifications, differing mainly in parameter count, context length, and unit price. The table below outlines a general decision-making framework; specific values should be based on the provider’s documentation and your own evaluation results.
| Specification | Suitable Tasks | Main Risks |
|---|---|---|
| Flagship | Multi-step reasoning, complex code, high-precision analysis | High unit price, slow response, high cost for batch tasks |
| Mid-range | Enterprise internal assistants, regular customer service, document Q&A | Requires self-evaluation to find the best cost-performance balance |
| Lightweight | Classification, summarization, simple Q&A, rewriting | Quality drops for complex reasoning and long-chain tasks |
For tasks like classification, summarization, and simple Q&A, as long as the prompts are thoroughly crafted, a lightweight model’s results can approach those of a flagship model. In complex reasoning, long-context, and high-precision scenarios, the gap between the two usually becomes apparent. For these types of tasks, you should test different specifications using the same batch of real samples, recording accuracy, latency, and per-call cost before making a decision.
If the lightweight model is to be deployed on edge devices, you must also verify whether the device has sufficient memory and VRAM. Even if an MoE model only activates a portion of its experts per run, the entire weight must still be loaded.
4. How to Interpret Evaluation Scores
Performance in math, code, and knowledge Q&A depends on the training data, post-training methods (like Reinforcement Learning from Human Feedback, RLHF), and evaluation settings. Common public evaluations include MMLU (multi-disciplinary knowledge), GSM8K (grade-school math), and HumanEval (function-level code generation). The same model can yield very different scores across different evaluation sets, prompts, or decoding parameters.
When citing scores, you should simultaneously record the following information:
- Evaluation set name and version
- Prompting method (zero-shot or few-shot, number of examples)
- Decoding parameters (temperature, top_p, maximum output length)
- Whether tools were used
- Sample size
Scores lacking this information can only serve as references and cannot be directly used for comparison.
5. How to Estimate Costs
The cost of a single call can be estimated using the following formula:
Cost per call = Input tokens / 1,000,000 × Input unit price + Output tokens / 1,000,000 × Output unit price + Tool and retrieval call costs
The actual cost must also be multiplied by the retry amplification factor, while the cache-hit portion is recalculated at a discounted unit price. Concurrency primarily affects peak throughput and queuing latency. It usually does not directly change the single-call price, but it determines how much resource capacity needs to be reserved.
Here is an illustrative example. Assume an input price of 2 cost units per million tokens and an output price of 8 cost units per million tokens—these numbers are not quotes from any specific provider. A single request with 2,000 input tokens and 500 output tokens has a base cost of 2,000 / 1,000,000 × 2 + 500 / 1,000,000 × 8 = 0.008 cost units. If the retry rate is 5%, the cost becomes 0.008 × 1.05 = 0.0084 cost units. If the daily request volume is 10,000, the daily cost is approximately 84 cost units.
When estimating, the measurement metrics to record include: cache hit rate, average concurrency, number of retries, average input and output token counts, and the number of tools called per request. If the metrics differ, the cost figures for the same system can vary by several multiples.
6. Agents: Enabling Models to Call Tools
An Agent is a system where the model understands a task, breaks it down into steps, and completes operations through tools. Tools can be web searches, code execution, or database queries. While capabilities are enhanced, risks also increase. The model might select the wrong tool, pass incorrect parameters, be misled by input text, or execute write operations beyond its permissions.
The pseudocode below demonstrates an execution loop with permission validation, human confirmation, and termination conditions. The model is only responsible for proposing actions; the actual execution is carried out by controlled code.
import jsonimport timeimport loggingfrom jsonschema import validate, ValidationErrorlogger = logging.getLogger("agent.audit")# Tool whitelist: only listed tools can be called, with declared permission levelsTOOL_REGISTRY = {"search_docs": {"level": "read", "schema": {...}, "fn": search_docs},"query_orders": {"level": "read", "schema": {...}, "fn": query_orders},"update_ticket": {"level": "write", "schema": {...}, "fn": update_ticket},}MAX_STEPS = 8 # Termination condition: maximum number of stepsMAX_RETRY = 2 # Maximum retries for a single toolTIMEOUT_SEC = 10 # Timeout for a single tool call in secondsdef run_agent(task, user, llm, confirm):history = [{"role": "user", "content": task}]for _ in range(MAX_STEPS):action = llm.plan(history) # Model outputs suggestions, does not execute directlyif action.type == "final":return action.answerspec = TOOL_REGISTRY.get(action.tool)if spec is None: # Wrong tool: rejected if not in whitelistaudit(user, action, "rejected: tool not allowed")history.append(tool_error("Tool not in whitelist"))continueif not user.has_permission(action.tool, spec["level"]): # Least privilegeaudit(user, action, "rejected: no permission")history.append(tool_error("No permission for this tool"))continuetry: # Parameter overreach or format error: validate against schemavalidate(instance=action.args, schema=spec["schema"])except ValidationError as e:audit(user, action, f"rejected: bad args {e.message}")history.append(tool_error("Invalid parameters"))
