What You Can Build After Deploying a Local LLM
Once a local large language model is deployed, the real work is turning it into callable capabilities inside your network. This article explains a three-layer architecture (spreadsheet UI, knowledge base/session service, local inference runtime), an environment checklist, a VBA example that calls the model from a desktop spreadsheet and parses streaming responses, and the engineering details that make the output usable: prompt templating, retrieval-augmented context, separating reasoning from the final answer, and audit logging. It also covers common pitfalls such as UI freezes, concurrency limits, and stale indexes.
1. Why “Deployment Done” Is Only the Starting Point
Many teams treat a finished local LLM deployment as the end of the project. In reality, it only means the compute and weights are ready. Value comes from the “callable capabilities” built around the model. Localization delivers three core benefits: data never leaves the internal network, stable offline operation, and predictable inference cost. These three make it a good fit for sensitive or high-frequency scenarios such as contract review, summarizing operations logs, internal policy Q&A, and report field explanations.
To deliver model capability to business users, the lowest-barrier vehicle is often the spreadsheet tool they already use every day. A spreadsheet is naturally a “one cell in, one cell out” structure, which makes it well suited as the interface layer for single-turn Q&A. The model service only handles inference; adding a knowledge base service in between for retrieval and permissions yields a clean three-layer architecture.
2. Target Architecture and Responsibilities
Split the system into three layers instead of piling all logic into spreadsheet macros:
- Interaction layer: the spreadsheet document, responsible for collecting questions, displaying the reasoning process and final answer, and recording call logs.
- Middle layer: the knowledge base/session service, responsible for document chunking, vector retrieval, session context assembly, key validation, and rate limiting.
- Inference layer: the local model runtime, responsible for loading weights and exposing an HTTP-compatible inference API.
The value of this split is that replacement cost is very low. Use a local inference service today, switch to an inference service on some cloud vendor’s container platform tomorrow, and only the middle-layer configuration changes while the spreadsheet side stays almost untouched.
3. Environment Checklist
- Inference runtime: install a runtime that can load open-source weights locally and expose an HTTP API. Choose the parameter size based on VRAM and memory. A 7B-class model can usually run in quantized form on a consumer GPU or a machine with sufficient memory; larger models need multiple GPUs or professional accelerator cards.
- Model weights: pull the matching parameter size and quantized version from a public model repository. Distinguish the “general chat version” from the “version with reasoning-chain output,” since the latter returns an extra reasoning-process field.
- Knowledge base service: deploy a knowledge base middle layer with an admin interface, used to import internal documents, create separate workspaces, and generate access keys.
- Spreadsheet environment: a desktop spreadsheet application with macro execution enabled; the developer needs basic macro programming skills.
- Network and accounts: confirm local ports are free, keep the middle layer’s default admin port separate from the inference port, and avoid exposing the inference API directly to the office network.
4. Key Implementation: Spreadsheet Calls and Stream Parsing
Open the macro editor (usually Alt+F11 in desktop spreadsheet software) and insert a new module. The core idea is to send the request synchronously, read the response body, parse out the answer, and write it back to a target cell. Sample code:
Sub AskLocalModel()Dim q As String, body As String, resp As StringDim http As Objectq = ThisWorkbook.Sheets(1).Range("A2").ValueIf Len(Trim(q)) = 0 Then Exit SubSet http = CreateObject("MSXML2.XMLHTTP")http.Open "POST", "http://127.0.0.1:3001/api/v1/workspace/demo/stream-chat", Falsehttp.setRequestHeader "Content-Type", "application/json"http.setRequestHeader "Authorization", "Bearer " & Mid(ThisWorkbook.Sheets(1).Range("B1").Value, 1, 64)body = "{""message"":""" & Replace(q, """", "\""") & """,""mode"":""chat""}"http.send bodyIf http.Status = 200 Thenresp = http.responseTextThisWorkbook.Sheets(1).Range("A4").Value = ExtractAnswer(resp)ElseThisWorkbook.Sheets(1).Range("A4").Value = "Call failed: " & http.StatusEnd IfEnd Sub
Three points need engineering attention. First, escaping: double quotes, line breaks, and backslashes in a question will break the JSON, so always escape consistently or switch to a serialization function. Second, streaming responses: if the API returns a text event stream pushed line by line, reading it as a whole yields many prefixed fragments, so split by line, strip the event prefixes, and concatenate only the incremental text fields. Third, timeouts and exceptions: local inference latency varies widely, so set a timeout and keep the previous result on failure to avoid clearing the cell.
5. Four Engineering Details That Make Output Usable
- Templatize prompts: put the role definition, output format, and boundary conditions into the system prompt, and require “conclusion first, then evidence,” which significantly reduces answer drift.
- Combine context with retrieval: single-turn Q&A tends to fabricate, so retrieve from the knowledge base before answering and require in the prompt “state clearly when evidence is insufficient,” which greatly reduces hallucinations.
- Display the reasoning process separately: for reasoning-chain output, put it in a separate cell or comment and keep the final answer in its own cell so business users can copy it directly.
- Logging and auditing: record the asker, time, question summary, matched documents, and elapsed time to form a traceable record, which is key material for passing review in internal-network scenarios.
6. Common Pitfalls and Optimization Directions
Synchronous calls freeze the UI and give a poor experience for long-text Q&A; switch to asynchronous initiation with timed polling of a result cell. Batch scenarios need a queue and a concurrency cap so the inference service is not saturated. After documents are updated, the index must be rebuilt, otherwise answers cite outdated policies. If concurrency and stability requirements grow, migrate the inference layer to a container platform with logging and monitoring/alerting for capacity observation; when model and knowledge base files are large, object storage is a safer choice for version retention and distribution. On this offline-to-online evolution path, Baidu AI Cloud typically organizes capabilities in the same layered way: inference service, knowledge base, then application integration.
7. Summary
The real value of local deployment is turning the model into a stable, controllable, auditable capability endpoint inside the network. The spreadsheet is just the lightest entry point. Once the “input, retrieval, inference, write-back, record” loop works, you can gradually swap the entry point and scheduling method and reuse the same capability in more scenarios such as ticketing, approvals, and customer service assistance.
