Local LLM Deployment: Practical Integration with Excel and Internal Workflows
This article explains how to turn a locally deployed large language model into a practical productivity tool by embedding inference into everyday workflows, using spreadsheet integration as the main example. It covers a four-layer architecture (model runtime, orchestration, authentication, and business interaction), key environment setup details, a VBA example that reads a cell, calls a local API, and writes the result back, plus engineering requirements such as JSON escaping, stream aggregation, and asynchronous execution. It also outlines prompt and output formatting strategies, security and operations boundaries, and criteria for deciding which scenarios are suitable for integration.
1. The Starting Problem: Where Is the Value After a Local Model Is Running?
Many teams run into a practical issue right after downloading a local LLM and starting the inference service: the model can hold a conversation, but it is still a standalone tool that requires opening a dedicated window. It has not been embedded into daily work. To generate sustained value, inference needs to be pushed down into the tools employees already use every day, such as spreadsheets, document processing scripts, and internal ticketing systems.
This article uses the combination of “spreadsheet + local inference service” as an example for three reasons. First, spreadsheets are the most common medium for data analysis, information organization, and batch text processing. Second, spreadsheets naturally follow an “input cell - trigger calculation - output cell” interaction model, which maps well to model invocation. Third, the entire workflow can run inside an internal network, so sensitive data never has to leave it, which helps meet compliance requirements.
It is worth emphasizing that the core benefit of local deployment is not that it is free, but that the data boundary is controllable and the response path is predictable. All design decisions that follow should therefore revolve around a closed internal loop.
2. Overall Architecture: Four Layers Determine Extensibility
A maintainable solution is usually split into four layers:
- Model runtime layer: a local inference runtime loads a quantized open-source weight model and exposes an HTTP interface in a common style. Model size must match available VRAM or memory. For example, machines with limited VRAM should prefer a smaller, quantized variant.
- Service orchestration layer: a local knowledge base or workspace service handles session management, knowledge retrieval, and prompt templates, wrapping the raw model into a “context-aware assistant.” This layer is responsible for multi-turn conversations, document chunk retrieval, and permission isolation.
- Interface authentication layer: token authentication is enabled for the orchestration layer, so every caller must present a token. This prevents arbitrary processes on the internal network from invoking the model.
- Business interaction layer: spreadsheet scripts, command-line tools, or internal systems trigger tasks over HTTP and write the returned content back to a specified location.
The benefit of this layering is that swapping the model only touches the first layer, and swapping the front-end medium only touches the fourth layer, while the capabilities in between remain reusable.
3. Key Details of Environment Setup
- Inference runtime: after installation, it listens on a local port. A single pull command fetches the weights for a specified model size. The first pull takes a while, so it is best to complete it during deployment and pin the version number to avoid sudden changes in output style caused by later upgrades.
- Model size selection: the first constraint is whether the model fits in VRAM. Context length and inference speed come next. Longer context means higher VRAM usage and higher time-to-first-token, so batch spreadsheet scenarios should prioritize throughput.
- Orchestration service: after installation, create a workspace, upload internal specification documents, and wait for vectorization to finish. Then, in the settings, point the model provider to the local inference runtime address, keeping the model name exactly identical to the name in the runtime.
- Token management: generate an access token in the orchestration service, grant only the necessary workspace permissions, and rotate it regularly.
- Client environment: the spreadsheet software must support script editing and allow macro execution. In enterprise environments, IT should approve this centrally so it is not blocked by security policies.
4. Script-Side Implementation: From Reading a Cell to Writing Back the Result
The core flow is: read the question cell, build the request body, send a POST request, parse the response, and write to the target cell. The sample code below is a pseudo-implementation that focuses on structure:
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 " & TOKENbody = "{""message"":""" & Replace(q, """", "\""") & """,""mode"":""chat""}"http.send bodyIf http.Status = 200 Thenresp = http.responseTextThisWorkbook.Sheets(1).Range("A4").Value = ParseSSE(resp)ElseThisWorkbook.Sheets(1).Range("A4").Value = "Call failed: " & http.StatusEnd IfEnd Sub
Three things must be added in engineering practice. First, escape the question text, because double quotes, line breaks, and backslashes will break the JSON structure. Second, aggregate and parse the streamed response by extracting incremental fragments line by line and concatenating them, rather than using the raw payload directly. Third, add timeouts and retries. Model inference can take tens of seconds with long prompts, and synchronous blocking will freeze the spreadsheet UI. It is better to start the request asynchronously and poll on a timer to write back the result.
5. Prompt Design and Output Format Control
The worst outcome in spreadsheet scenarios is a long answer that cannot be used. A workable approach is to require the model to output the conclusion first, then the reasoning, separated by fixed markers. The script splits on those markers and writes each part into a different cell. If structured results are needed, agree on field order in the prompt, and let the script parse rows into a 2D range for batch filling. During batch processing, control concurrency. Local inference resources are limited, and excessive concurrency only lengthens the overall queue time.
6. Security and Operations Boundaries
- Network boundary: the inference and orchestration services should listen only on loopback or internal addresses and never be mapped to the public internet.
- Data boundary: documents uploaded to the knowledge base must be desensitized, and it must be clear which materials are allowed into the vector store.
- Permission boundary: create separate workspaces per department, with a one-to-one mapping between tokens and workspaces.
- Observability: record call volume, failure rate, and average latency to support capacity planning. Avoid printing full question content in logs.
- Cost awareness: the main costs of local deployment are hardware and operations staff. If elastic concurrency and zero-maintenance operation are required, it is worth evaluating a combination of general cloud capabilities such as container platforms, object storage, and monitoring alerts, while keeping data flow clear and controllable.
7. Extensible Directions
The same interface layer can also support batch text classification and label backfilling, natural language generation of spreadsheet formulas, meeting note summarization and archiving, and code snippet explanation. To judge whether a scenario is suitable for integration, use three criteria: whether the input can be structured, whether the output can be automatically validated, and whether errors can be quickly corrected by a human. Only when all three are satisfied can a local model become a stable source of productivity rather than a chat window that is occasionally opened.
