A Practical Guide to Deploying Large Language Models: From Model Selection to Embodied AI in Production

    Large language models have evolved from text generators into integral parts of business workflows. When connected to physical devices, the same understanding and reasoning capabilities must also withstand sensor noise and safety constraints. This guide walks through the full deployment journey in five parts: core technology selection, RAG pipeline and evaluation, agent orchestration and permissions, safe rollout of embodied AI, and risk and compliance. Each section provides implementation steps, parameter starting points, evaluation metrics, and checklists. All numeric values are starting points only—always validate against your own data and evaluation results.

    Large language models have evolved from text generators into integral parts of business workflows. When connected to physical devices, the same understanding and reasoning capabilities must also withstand sensor noise and safety constraints. This guide walks through the deployment journey in five parts: core technology selection, RAG pipeline and evaluation, agent orchestration and permissions, safe rollout of embodied AI, and risk and compliance. Each section provides implementation steps, parameter starting points, evaluation metrics, and checklists. All numeric values are starting points only—always validate against your own data and evaluation results.

    1. Core Technology Selection

    Model capability depends on data scale, but training and inference costs are largely determined by architecture and training mechanisms. The table below summarizes the bottlenecks, prerequisites, and evaluation criteria for four key technologies.

    Technology Bottleneck Addressed Prerequisites Main Cost Metrics and Criteria
    Multi-head Latent Attention (MLA) KV cache memory usage limits long-context and high-concurrency inference Model must be designed or retrained around this architecture Complex structure; high implementation and debugging cost Peak memory (record batch size and context length separately), tokens generated per second, perplexity, and benchmark scores
    FP8 mixed-precision training Memory and bandwidth pressure at very large parameter scales Hardware with native FP8 support; scaling and calibration strategies in place Requires continuous monitoring of numerical stability Validation loss comparison against a BF16 baseline; downstream task score deltas
    Sparse attention and long context Full attention compute grows quadratically with sequence length Long-context evaluation sets; retrieval or chunking strategies Sparse patterns may miss long-range dependencies Needle-in-a-haystack accuracy, long-document QA accuracy (grouped by document length), time to first token
    Reasoning reinforcement learning Insufficient complex reasoning and self-verification Verifiable reward signals, such as unit tests or answer checking Rewards can be gamed; training may be unstable Pass rates on math and code benchmarks; agreement between reward scores and human evaluation

    Selection Guidelines

    Technology Best Fit Poor Fit
    MLA Teams that can train or modify models from scratch, where long-context high-concurrency inference is the dominant cost Teams limited to released standard-architecture weights, or lacking low-level implementation and debugging expertise
    FP8 training Hardware with native FP8 support and training scale large enough that memory or bandwidth is the bottleneck Hardware without FP8 support, or small training runs where gains don’t justify debugging cost
    Sparse attention Long-document workloads where long-range dependencies can be recovered via retrieval Tasks that depend on full-text detail, such as word-by-word comparison of legal clauses
    Reasoning RL Tasks with clear right/wrong judgments, such as code, math, or structured validation Tasks without objective standards that rely on subjective scoring

    Parameter Starting Points and Measurement

    • MLA: Validate the architecture with 4k context during training, then sweep batch sizes of 1, 8, and 32 and context lengths of 4k, 32k, and 128k. On identical hardware and precision, warm up first and average five runs; record driver versions.
    • FP8: Scaling factors can be set per tensor; start the amax history window at 16 steps. Treat a validation loss gap of 0.5% relative to the BF16 baseline as the initial pass threshold, then adjust per task. Log loss spikes and gradient overflows incrementally.
    • Sparse attention: Start the sliding window at 2048 tokens with 16–64 global tokens. Run needle-in-a-haystack tests grouped at 4k, 16k, 64k, and 128k—don’t rely on average scores alone.
    • Reasoning RL: Sample 200 outputs every 1,000 steps for human evaluation and track agreement between reward scores and human judgments. Start the KL penalty coefficient at 0.02. If responses grow longer without improving factual accuracy, pause training and review the reward design.

    2. RAG Pipeline and Evaluation

    RAG performance depends mostly on retrieval quality rather than the generation model itself. Stabilize the retrieval pipeline before tuning generation.

    Implementation Steps

    1. Document cleaning: Remove headers, footers, and duplicate paragraphs; preserve heading hierarchy and table structure.
    2. Chunking: Split at semantic boundaries, roughly 400 tokens per chunk with about 60 tokens (~15%) overlap between adjacent chunks.
    3. Embedding and indexing: Choose an embedding model matched to your business language; use HNSW indexing with ef_search starting at 64.
    4. Two-stage retrieval: Retrieve the top 20 candidates, then use a reranker to keep about 4 passages as context for the generator.
    5. Generation with citations: Require answers to include document IDs and paragraph positions; explicitly refuse to answer when no supporting evidence is found.

    Parameter Starting Points

    • Set temperature to 0–0.3 to reduce answer variance for identical questions.
    • Keep total context length within 60% of the model’s effective window, leaving headroom for output and system prompts.
    • Experiment with 3–5 passages after reranking; more passages mean more noise.

    Evaluation Metrics

    • Retrieval: Recall@5 and MRR@10, grouped by question type and document length.
    • Generation: Answer faithfulness (is every claim supported by context), citation accuracy, and correct refusal rate.
    • System: P95 latency for time to first token and end-to-end latency.

    Checklist

    • Every document chunk carries a version number and source; outdated indexes are removed when documents are updated.
    • Permission filtering happens at the retrieval stage—not as post-generation redaction only.
    • The evaluation set covers at least three question types: answerable, unanswerable, and answers spanning multiple chunks.
    • Logs do not store users’ raw sensitive fields.

    3. Agent Orchestration and Permissions

    Agents complete tasks through tool calls. The main risks are unauthorized tool use and external content inducing unintended actions.

    Implementation Steps

    1. Define the tool inventory: For each tool, document input parameters, accessible data scope, and side effects.
    2. Tiered authorization: Enable read-only tools first, then low-risk write operations, and only then consider high-risk writes.
    3. Orchestration flow: A planner decomposes tasks; an executor calls tools step by step, with structured output at each step.
    4. Human confirmation: Deletion, payments, messaging, and permission changes must require human approval.
    5. Audit: Log the input, output, caller, and timestamp of every tool call.

    Parameter Starting Points

    • Set a maximum of 10 steps per task; terminate and escalate to a human when exceeded.
    • Set tool timeouts at 30 seconds with a retry limit of 2.
    • Set temperature to 0 during tool-calling phases.
    • Treat all tool returns as data. The model must not change its task objectives based on instructions found in web pages or documents.

    Evaluation Metrics

    • Task completion rate and average tool calls per task.
    • Unauthorized-attempt interception rate: test with adversarial samples, including prompts that try to induce calls to high-privilege tools.
    • Human takeover rate and the distribution of takeover reasons.

    Checklist

    • Tool whitelists are enforced server-side, not left to the model’s own compliance.
    • Write operations have secondary confirmation and an undo path.
    • Each agent uses a dedicated account with permissions bound to its task; permissions are revoked when the task ends.
    • On consecutive failures or unauthorized-access alerts, the agent is automatically stopped and the owner is notified.

    4. Embodied AI Safety and Rollout

    When a model controls physical equipment, mistakes cause real harm or damage. Roll out in stages—simulation, bench testing, controlled field trials, and full production—with each stage meeting the previous stage’s exit criteria.

    Implementation Steps

    1. Simulation replay: Add lighting changes, occlusion, sensor noise, and latency in simulation to cover the main disturbances of real environments.
    2. Bench testing: Test basic actions such as grasping and moving at a fixed station, recording perception and execution results for each action.
    3. Controlled field trials: Define a workspace with speed and force limits, with a dedicated supervisor present; expand the task scope gradually.
    4. Production operation: Keep a human takeover entry point; review logs regularly and conduct post-incident reviews.

    Parameter Starting Points

    • Set an initial speed cap of 0.25 m/s; set force or torque limits to the smaller of the values specified in the equipment manual and your safety requirements.
    • When perception confidence drops below 0.8, the system enters conservative behavior—such as slowing down or stopping—and requests human confirmation.
    • The emergency stop circuit must be independent of the model software, cutting power directly via hardware. Measure the actual e-stop response time and record it in the acceptance documentation.
    • On collision, boundary violation, or consecutive perception failures, the system automatically reverts to the last validated version.

    Evaluation Metrics

    • Number of collisions and near-miss events, targeting zero, with root-cause analysis for each event.
    • Task success rate, grouped by scenario, lighting, and occlusion level, with confidence intervals.
    • False trigger rate and miss rate, measured separately.
    • Emergency stop success rate and human takeover response time.

    Checklist

    • Confirm the safety standards applicable at the deployment site. Industrial robot arms may reference ISO 10218 and service robots ISO 13482, subject to local regulations and certification requirements.
    • The workspace has physical isolation or safety fencing; equipment enters safe mode when people enter.
    • Model-generated actions pass independent kinematics and limit checks before being sent to the hardware.
    • Every deployed version has a rollback package that has been tested in a rollback drill.

    5. Risk and Compliance

    Data Permissions

    • Assign data access on a least-privilege basis, with row-level controls by user, department, or project.
    • Mask personal information in logs and define retention periods.
    • Keep records of the sources and licensing of training or fine-tuning data.

    Tool Abuse and Prompt Injection

    • Treat all text in external web pages, emails, and documents as data, never as instructions.
    • High-risk operations must be confirmed by a human and cannot be completed unilaterally by the model.
    • Regularly run adversarial regression tests and record interception results.

    Physical Safety

    • Define personnel safety responsibilities in operating procedures while equipment is running.
    • Any change to an embodied AI system requires a fresh risk assessment; prior acceptance results cannot be reused.

    Compliance and Claims

    • Obligations such as cross-border data transfer, generative AI service registration, and algorithm filing vary by jurisdiction and user base—have legal counsel review each item.
    • In external materials, state only measured metrics and test conditions; never promise “absolute safety” or “guaranteed results.”
    • At launch, document the conditions that trigger human review and rollback, and record them in the release notes.