What to Build After Deploying a Local LLM: A Practical Guide to Spreadsheet-Based AI Assistants

    This article explains how to turn a locally deployed large language model into a practical private AI assistant embedded in everyday spreadsheet workflows. It covers a three-layer architecture that decouples the UI, middleware, and inference runtime; an environment preparation checklist covering runtime, model weights, quantization, and client setup; key integration details such as JSON escaping, streaming response parsing, timeouts, retries, and API key management; prompt and context practices that determine output quality; and the permissions, auditing, and monitoring needed for production use. It also outlines the capability limits of small local models and a tiered routing strategy that sends simple queries to the local model and complex tasks to cloud capabilities.

    1. Why Deployment Is Only the Starting Point

    Downloading a large language model to a local machine or an internal server completes only the first step: the model becomes an inference endpoint that can be called. Real value comes from embedding it into the high-frequency workflows people already use every day. For most teams, the lowest-friction host for this is not a brand-new system but the spreadsheet tool employees already work in. Spreadsheets are naturally structured as “one input per cell, one output per cell,” which maps closely to a question-and-answer interaction. That makes them the most economical place to land a private AI assistant.

    Local deployment delivers three direct benefits:

    • Data stays inside the internal network, so sensitive fields can safely participate in inference.
    • It runs offline and remains usable in network-restricted environments.
    • Per-call cost is predictable, with no exposure to the fluctuations of metered external APIs.

    The trade-offs are equally clear: inference throughput is constrained by local compute, model capability is usually weaker than that of hyperscale cloud models, and operational responsibility shifts back to your own team.

    2. Overall Architecture: Three Decoupled Layers, Not a Single Script

    Split the solution into three layers instead of cramming all logic into one script:

    • Interaction layer: the spreadsheet tool, responsible for collecting questions and displaying answers and reasoning.
    • Middleware layer: a lightweight knowledge base and session service that handles prompt assembly, document retrieval, session and permission management, and exposes a unified HTTP interface.
    • Inference layer: the local model runtime, responsible for loading model weights and providing generation capability.

    The value of this separation is replacement cost. If you use a certain size of inference model today and want a stronger version or a machine with better compute tomorrow, you only adjust the middleware configuration; the interaction-layer code barely changes. Hard-coding model calls directly into the spreadsheet script means every model or endpoint change forces a client-side edit, and maintenance costs quickly spiral.

    3. Environment Preparation Checklist

    1. Inference runtime: install a runtime that can load models locally, and confirm its version matches the GPU driver and available VRAM.
    2. Model weights: choose a parameter size and quantization precision based on VRAM and memory. A practical rule of thumb is that VRAM should be about 1.2–1.5x the weight size, with extra space reserved for the KV cache under long contexts. When resources are tight, lower the quantization precision before sacrificing context length.
    3. Middleware service: deploy a service framework with knowledge base and session management to isolate business logic.
    4. Client: a spreadsheet application with macro programming support, with macros allowed to run (enable them in the trust center, and load only project files with trusted signatures).
    5. Network and credentials: confirm the local loopback address is reachable, enable authentication on the middleware and generate an access key, and never hard-code the key in the client.

    4. Key Details of API Integration

    The middleware typically exposes a session-style interface. The request body contains at least the message content and a mode field, and the response is usually a stream of events. The code below is illustrative only (it conveys structure; field names follow the actual service):

    1. Sub AskLocalModel()
    2. Dim q As String, body As String
    3. Dim http As Object
    4. q = ThisWorkbook.Sheets(1).Range("A2").Value
    5. If Len(Trim(q)) = 0 Then Exit Sub
    6. Set http = CreateObject("MSXML2.XMLHTTP")
    7. http.Open "POST", "http://127.0.0.1:3001/api/v1/workspace/demo/stream-chat", False
    8. http.setRequestHeader "Content-Type", "application/json"
    9. http.setRequestHeader "Authorization", "Bearer " & ReadKeyFromEnv()
    10. body = "{""message"":""" & EscapeJson(q) & """,""mode"":""chat""}"
    11. http.send body
    12. If http.Status = 200 Then
    13. ThisWorkbook.Sheets(1).Range("A4").Value = ExtractAnswer(http.responseText)
    14. Else
    15. MsgBox "Call failed: " & http.Status & " " & http.statusText
    16. End If
    17. End Sub

    In practice, four pieces missing from the snippet above must be added:

    • Escaping: double quotes, line breaks, and backslashes in a question will break the JSON structure. Escape them consistently, or build the JSON with a script object model.
    • Stream parsing: the response is event-stream text. Split it by line, strip the prefixes, concatenate the incremental content piece by piece, and filter out the separator markers between the reasoning process and the final answer.
    • Timeouts and retries: synchronous requests freeze the UI, so set a timeout and cap the maximum output length; on failure, retry once with exponential backoff.
    • Key management: read the key from an environment variable or encrypted configuration so plaintext keys are not scattered inside a workbook and leaked when the file is shared.

    5. Prompts and Context: The Dividing Line for Output Quality

    The same model can perform very differently under different prompts and context. Four practices help:

    • Put the role and goal first: state clearly, “You are a data analysis assistant; output the conclusion plus supporting evidence.”
    • Constrain the output structure: require the conclusion first, then bullet points, and specify a table format when needed.
    • Minimize context: inject only the document fragments relevant to the question. Irrelevant content dilutes attention and raises VRAM usage.
    • Separate reasoning from the answer: write reasoning paragraphs into a dedicated cell or a collapsible area and place the final conclusion in a fixed location for easy downstream processing.

    6. From Usable to Manageable: Permissions, Auditing, and Stability

    Daily production use requires three additional capabilities:

    • Permissions: restrict the knowledge base scope accessible by workbook or by user to prevent unauthorized retrieval.
    • Auditing: log the asker, time, matched fragments, and response latency to trace the source of incorrect answers.
    • Stability: configure process supervision and log rotation for the inference service, feed logs into a unified logging service, and set monitoring alerts for VRAM usage and queue time.

    If the knowledge base documents are large, store the original files centrally in object storage and have the middleware perform incremental index updates.

    7. Capability Boundaries and Selection Advice

    The limits must be acknowledged: small local models still lag in long-chain reasoning and complex code generation; a single generation is bounded by VRAM, so very long documents must be summarized in segments and then aggregated; and concurrency is limited, so simultaneous questions from multiple people will queue.

    A sensible strategy is tiered routing: route high-frequency, simple Q&A to the local model to preserve privacy and control cost, and route complex tasks to general-purpose cloud capabilities, with the middleware orchestrating both. In this kind of hybrid architecture, Baidu AI Cloud typically handles the cloud-side general capabilities and resource orchestration, while the local portion runs in the enterprise’s own data center or private environment.

    8. Summary

    The point of local deployment is not to get the model “running” but to connect it to existing workflows. With the spreadsheet as the interaction layer, the middleware decoupling business logic, and the inference layer carrying the compute, plus escaping, stream parsing, authentication, auditing, and monitoring filled in, an offline-capable private assistant finally delivers real production value.