A Guide to Selecting General-Purpose LLMs: Architecture, Multimodality, and Engineering Implementation
This article provides a comprehensive guide to selecting general-purpose Large Language Models (LLMs), focusing on MoE architectures, million-token context windows, and native multimodal capabilities. It explores engineering practices for long-horizon programming, including closed-loop workflows, and outlines enterprise integration strategies such as API gateways and logging. Finally, it emphasizes the necessity of evaluating models based on real-world tasks rather than solely on benchmark scores.
Over the past year or two, Large Language Models (LLMs) have evolved from single, specialized capabilities to comprehensive general-purpose systems. A new generation of Mixture of Experts (MoE) models targets scenarios such as long-horizon programming, deep research, video understanding, and front-end development. This guide explores this evolution across four dimensions: architecture, input capabilities, engineering practices, and model selection. Please note that the figures and performance claims mentioned are derived from public statements by vendors or the community; specific values should be verified against official technical reports and your own internal evaluations.
1. MoE Architecture: Total Parameters vs. Active Computation
MoE models consist of multiple expert sub-networks and a router. For each input token, the router selects a small number of experts to participate in the computation, while the remaining experts do not perform forward passes. As a result, the model’s total parameter count can be massive, while the active parameter count per inference remains relatively small.
This design yields two direct outcomes. First, the model can accommodate more knowledge, with total parameter scales reaching the trillion level. Second, the computational cost per inference is determined by the active parameters, not the total parameters. When evaluating “total parameter” figures, readers should also pay attention to active parameters, the total number of experts, and the number of experts activated per forward pass, as these metrics collectively determine actual costs.
Regarding attention mechanisms, some new models have publicized improvements in deep information transmission and long-context attention. Terms like “Delta Attention” and “attention residual” are specific vendor or paper nomenclatures, not industry-standard terms. During evaluation, consult the corresponding papers or technical documentation to confirm the specific form of the improvement.
Claims such as “efficiency improved several times” are common in marketing materials. These rely on specific evaluation datasets, hardware, and comparison baselines. Without this contextual information, such claims should be treated as directional signals rather than directly applicable conclusions.
2. Million-Token Context and Native Multimodality
A million-token context window allows for single-pass input of massive amounts of material, but there are boundaries in both capability and cost. The table below lists three common scenarios:
| Scenario | Typical Input Scale | Main Limitations | Common Failure Modes |
|---|---|---|---|
| Large Codebases | Thousands of files with complex dependencies | Requires filtering and sorting when files are excessive; cost grows with input length | Missing cross-module calls, or treating outdated comments as current logic |
| Technical Docs & API Manuals | Hundreds of thousands to millions of tokens | If document versions are inconsistent, the model may mix old and new interfaces | Referencing deprecated parameter names |
| Long Videos or Academic Papers | Videos require frame extraction; papers require formula and chart parsing | Frame extraction frequency affects detail; formula and table parsing quality is unstable | Missing key frames, or misreading chart values |
Long context does not mean you can abandon retrieval strategies. When dealing with large-scale codebases, it is typically still necessary to retrieve relevant files first and then place the results into the context window.
Native multimodality refers to models receiving image and video data during the pre-training phase, rather than relying on external recognition modules to convert images to text. Such models can directly read UI design mockups, hand-drawn sketches, and error screenshots to output code or modification suggestions. Actual effectiveness depends on image clarity, annotation quality, and task complexity. Complex layouts, tiny text, and dynamic interactions remain common challenges.
3. Engineering Closed Loops for Long-Horizon Programming
Long-horizon programming refers to the model completing multi-step tasks with minimal human intervention: reading code, modifying files, running tests, and fixing issues based on error outputs. Compared to simply “generating a snippet of code,” this closed loop demands higher reliability in tool invocation, error recovery, and context management.
The pseudocode below illustrates a front-end closed-loop workflow. It is for demonstration purposes only and cannot be run directly. The llm_model and write_files functions must be implemented by your project, and the execution phase should be placed in an isolated sandbox environment.
# Pseudocode: Front-end closed-loop process based on multimodal models (for illustration only, not directly runnable)import subprocessfrom dataclasses import dataclass@dataclassclass RunResult:success: boolstderr: strscreenshot_path: str | None = Nonedef run_in_sandbox(project_dir: str, timeout_s: int = 120) -> RunResult:"""Execute build in an isolated environment, returning a structured result."""try:# Use list arguments instead of shell strings to prevent model output from being executed as command injectionproc = subprocess.run(["npm", "run", "build"],cwd=project_dir,capture_output=True,text=True,timeout=timeout_s,)return RunResult(success=proc.returncode == 0, stderr=proc.stderr)except subprocess.TimeoutExpired:return RunResult(success=False, stderr="Build timeout")def frontend_loop(design_image: str, requirement: str, project_dir: str, max_rounds: int = 3) -> str:code = llm_model.generate(image=design_image,prompt=f"Based on the design image, implement using React and Tailwind CSS: {requirement}. Output the complete file contents.",)for _ in range(max_rounds):write_files(project_dir, code)result = run_in_sandbox(project_dir)if result.success:return codecode = llm_model.generate(image=result.screenshot_path,prompt=f"Build failed with the following error:\n{result.stderr}\nPlease locate the cause and fix the code.\nCurrent code:\n{code}",)raise RuntimeError("Exceeded maximum repair rounds, manual intervention required")
This code contains three key design points. First, there is an upper limit on repair rounds to prevent the model from getting stuck in an infinite, ineffective loop. Second, a timeout is set for command execution to avoid build hangs. Third, failure results are returned as structured objects, allowing the caller to determine the next step based on this information.
Community case studies show that models perform well in tasks such as front-end prototyping, mini-game logic, and performance optimization. However, these cases are often cherry-picked by authors and lack a unified task set and failure statistics. It is recommended that teams record their own success rates, average repair rounds, and typical failure cases to make informed judgments.
4. Enterprise Integration: Gateways, Keys, and Observability
Enterprise integration typically involves web interfaces, desktop clients, command-line tools, and open APIs. When building your own invocation chain, a three-tier architecture design is recommended:
- Compute & Deployment: For private inference needs, utilize container platforms and GPU instances, configuring auto-scaling based on load. If only calling cloud APIs, there is no need to build your own GPU infrastructure. Mainstream cloud service providers offer such infrastructure; simply compare pricing, regions, and compliance certifications during selection.
- API Gateway: Centrally responsible for authentication, quotas, rate limiting, and auditing. Each team should use independent API keys and quotas to facilitate usage tracking and fault isolation.
- Data & Logging: Multimodal training or evaluation data should be stored in object storage with strict access permissions. Invocation logs must be desensitized to avoid recording complete source code or personally identifiable information.
The following example demonstrates basic protective measures during API calls: reading keys from environment variables, setting timeouts, applying limited retries for retriable errors, and throwing explicit errors when response fields are missing.
# Dependency: requests (recommended to pin the version in requirements.txt)import osimport timeimport requestsAPI_URL = os.environ.get("LLM_API_URL", "https://api.example.com/v1/chat/completions")# The API key must be read from environment variables. The value here is just a placeholder; never hardcode real keys in code or commit them to repositories.API_KEY = os.environ["LLM_API_KEY"]def call_llm(prompt: str, timeout_s: int = 60, max_retries: int = 2) -> str:headers = {"Content-Type": "application/json","Authorization": f"Bearer {API_KEY}",}payload = {"model": "your-model-name", # Follow the model name specified in the vendor's documentation"messages": [{"role": "user", "content": prompt}],"max_tokens": 2048,}last_error = Nonefor attempt in range(max_retries + 1):try:resp = requests.post(API_URL, headers=headers, json=payload, timeout=timeout_s)# 429 (rate limit) and 5xx can be retried with backoff; other 4xx errors are usually request issues, retrying is meaninglessif resp.status_code == 429 or resp.status_code >= 500:last_error = f"HTTP {resp.status_code}"time.sleep(2 ** attempt)continueresp.raise_for_status()data = resp.json()choices = data.get("choices") or []if not choices:raise ValueError(f"Response missing 'choices' field: {data}")return choices[0]["message"]["content"]except requests.RequestException as e:last_error = etime.sleep(2 ** attempt)raise RuntimeError(f"API call failed after {max_retries} retries: {last_error}")
Request formats vary significantly across different vendors. The names and structures of fields such as context files and image inputs must be adjusted according to their respective official documentation and cannot be applied directly from the example above.
5. Selection Checklist
When selecting a model, it is recommended to evaluate based on real-world tasks rather than relying solely on benchmark scores. Refer to a checklist that outlines inspection items and verification methods, keeping in mind that the specific pass criteria must be defined by your team according to your business requirements.
