What You Can Build After Deploying a Local LLM
This article explains what actually changes when you deploy a large language model on your own hardware, and why a spreadsheet is the best first place to put it to work. It covers a three-layer architecture that keeps scripts from calling the model directly, environment setup and model selection based on available VRAM, a working VBA example that reads a cell, calls the orchestration layer, and writes the answer back, plus notes on handling streaming responses, credentials, human review, observability, and cost control. It closes with additional scenarios that reuse the same pipeline.
1. Start With the Right Question: What Actually Changes With Local Deployment
Deploying a large language model locally looks like nothing more than moving inference from a remote data center to your own machine. The substantive changes are three:
- Data boundaries move back inside your network.
- You control latency and availability yourself.
- The cost per call shifts from pay-as-you-go billing to a one-time hardware investment.
These three points determine where a local model fits. It is not a replacement for every cloud capability; it takes over work that cannot leave the network, must leave an audit trail, is called frequently, and is relatively fixed in shape.
A common mistake is to assume that usage will happen naturally once the model is deployed. In practice the model is only an inference endpoint that can be called. It produces value only after it is embedded into the production tools people already use. Spreadsheet software is the ideal first target: nearly every role works with data in tables, inputs and outputs have clear structure, and the rework cost is low.
2. Overall Architecture: Three Decoupled Layers, No Scripts Calling the Model Directly
Split the chain into three layers instead of letting a spreadsheet script call the model directly:
- Interaction layer: the spreadsheet software. It collects the question, displays the result, and keeps a manual review entry point.
- Orchestration layer: a knowledge-base/middleware service. It handles workspace isolation, knowledge retrieval, prompt assembly, and credential validation.
- Inference layer: the local model runtime. It loads the weights, runs inference, and returns results either streamed or in one shot.
The benefit of this split is that model size, service ports, and credential policy can all be adjusted independently without touching the interaction layer. If scripts call the inference layer directly, replacing the model or adding retrieval augmentation forces a rewrite of every client.
3. Environment Setup and Key Configuration Points
- Local inference runtime: install a runtime that can load and host a model on the machine, confirm the address and port it listens on, and verify its health status.
- Obtaining and choosing model weights: pull weights of the target parameter size from a public model repository. Follow a “VRAM first” rule: required VRAM is roughly the parameter count multiplied by bytes per parameter, plus 20%–30% reserved for context and concurrency. If VRAM is insufficient, pick a smaller parameter size or a lower-precision quantized version rather than forcing it.
- Orchestration layer service: deploy middleware with knowledge-base support, register the inference layer’s endpoint and model identifier in its configuration, and generate a call credential valid only on the local machine.
- Client environment: confirm the spreadsheet software version supports script extensions and allows local scripts to make network requests.
The configuration relationship can be sketched as:
[spreadsheet script] --HTTP--> [orchestration layer :3001] --HTTP--> [inference layer :11434] --> local weights
4. Wiring Local Inference Into the Spreadsheet
Open the script editor (usually Alt + F11 on Windows), insert a new module, and implement the loop “read cell — send request — parse response — write back to cell”. Sample code:
Sub AskLocalModel()Dim q As String, body As String, resp As StringDim http As Object, url As String, token As Stringq = ThisWorkbook.Sheets(1).Range("A2").ValueIf Len(Trim(q)) = 0 Then Exit Suburl = "http://localhost:3001/api/v1/workspace/default/stream-chat"token = "locally generated call credential"Set http = CreateObject("MSXML2.XMLHTTP")http.Open "POST", url, Falsehttp.setRequestHeader "Content-Type", "application/json"http.setRequestHeader "Authorization", "Bearer " & tokenbody = "{""message"":""" & Replace(q, """", """""") & """,""mode"":""chat""}"http.send bodyIf http.Status = 200 Thenresp = http.responseTextThisWorkbook.Sheets(1).Range("A4").Value = ExtractText(resp)ElseThisWorkbook.Sheets(1).Range("A4").Value = "Call failed: " & http.StatusEnd IfEnd Sub
Three engineering details are mandatory. First, escape quotes in the question text so the assembled JSON is not truncated or injected into. Second, move the address, credential, and model identifier into configuration cells or environment variables instead of scattering them through the code. Third, set a timeout and a retry limit so the interface cannot hang.
5. Handling Streaming Responses
If the orchestration layer returns an event stream, the body is a structure of multiple event lines plus data blocks. The generated text usually sits in a nested field inside a data block and is followed by an end marker. A synchronous request waits for everything to arrive before returning, so the script side has to do two things: split by line, extract and concatenate the target field block by block, and stop parsing when the end marker appears. If you need to display text as it is generated, switch to an asynchronous request object and write incrementally into cells from the wait callback, but watch the timing between the script thread and interface refresh.
6. Reliability, Security, and Operations
- Credentials and network: never commit credentials to a database or a version repository; the orchestration layer listens on the loopback address by default. If the team needs to share it, keep it on the internal network with unified identity authentication and access auditing.
- Input and output governance: a local model produces wrong content too, so keep a manual review column for key conclusions. Stay alert to prompt injection and never splice external text directly into the system prompt as instructions.
- Observability: log the latency, input length, and return status of every call, and use a general logging service with monitoring alerts for threshold warnings. VRAM and concurrency are the most common local deployment bottlenecks.
- Cost control: turn high-frequency, templated tasks into prompt templates and cache the results; queue heavy tasks in batches so they do not compete for resources during interactive peaks.
7. Scenarios That Extend Naturally
With minor extensions, the same chain covers contract and policy Q&A, explanations of report definitions, ticket classification and summarization, and code and configuration inspection notes. To move closer to an enterprise-grade form, add object storage in front of the orchestration layer for document archiving, use a message queue to smooth task spikes, and run the inference service on a container platform for elastic scaling. Managed hosting and governance can also be handled with comparable general-purpose capabilities in environments such as Baidu AI Cloud, taking the setup from “it runs on this machine” to “the team can manage it, audit it, and keep evolving it”.
