Practical Ways to Use a Locally Deployed LLM: Building a Spreadsheet Assistant

    This article explains what actually changes after deploying a large language model locally, and why the first step should be picking a high-frequency, low-risk entry point rather than more tuning. It covers a four-layer architecture (inference, orchestration, invocation, data), environment and configuration essentials such as listen addresses, model identifiers, workspace naming, and key management, plus a VBA example that calls a local inference service from a spreadsheet. It also includes engineering details on escaping, streaming responses, and blocking calls, a troubleshooting checklist, advanced directions like RAG, batching, and observability, and security and compliance reminders.

    1. What Really Changes After Local Deployment

    Many teams hit a short dead zone after finishing a local LLM deployment: the model runs, the CLI chat works, but no business value shows up. The cause is usually not the model itself but the absence of a scenario to host it.

    Local deployment changes three things:

    • Data boundary control: inference happens entirely on your own host or intranet, so sensitive text never leaves the network. This is decisive for contracts, medical records, financial data, and internal policy documents.
    • Cost structure: usage is no longer tied to external billing; marginal cost is mainly GPU and electricity, which suits high-frequency, batch-oriented short tasks.
    • Customization room: prompt templates, context length, and decoding parameters are all under your control, making it easier to embed the model into existing systems instead of reshaping systems around it.

    So the first step after deployment is not more parameter tuning, but choosing a high-frequency, low-risk entry point. Office spreadsheets fit both conditions: nearly everyone uses them, and each task is small enough that failure is cheap.

    Reserve one cell for the question, another for the result, and have a script send the request to the local inference service when a button is clicked, then write the answer back to the target cell. The chain looks simple, yet it covers the core parts of most enterprise AI applications: interaction entry, service invocation, authentication, and result parsing and display.

    Its value:

    1. Business users never touch the command line; they use the model through a familiar interface.
    2. Prompts can be fixed in templates, so everyone does not invent their own inconsistent phrasing.
    3. Inputs and outputs stay in a local file, which naturally fits intranet compliance requirements.

    3. Overall Architecture: Four Layers

    Split the solution into four layers that communicate over standard protocols, so any layer can be replaced independently.

    Layer Responsibility Notes
    Inference Load and run model weights Handled by the local inference runtime, which exposes a compatible HTTP interface
    Orchestration Session management, knowledge base mounting, key validation Provides a single entry point and isolates business scripts from inference details
    Invocation Spreadsheet scripts, internal systems Call the orchestration layer over HTTP; never touch the model process directly
    Data Raw documents, vector index, logs Supports retrieval augmentation and later auditing

    The point of this split is decoupling: swapping the model only touches the inference layer; changing the knowledge base only touches the data layer; business scripts barely change.

    4. Environment Setup and Configuration

    Inference runtime: pick a runtime that loads local weights and exposes an HTTP interface, and confirm its listen address and port. If it only listens on the loopback address, same-machine calls work, but cross-machine access requires explicitly widening the listen range. This is the most common root cause of “cannot connect” issues later.

    Orchestration service: put the inference endpoint in the config file and specify the model identifier. Two things matter: the model identifier must exactly match the name actually loaded by the inference layer, and it is case sensitive; and workspace identifiers are lowercased in many implementations, so using lowercase consistently avoids path mismatches.

    Key management: create an access key for the orchestration layer. Business code holds only that key and never touches the model process. Keep the key in an environment variable or a separate config item, never hardcoded in scripts, and never shipped along with the file.

    5. Script Invocation and Streaming Results

    In the spreadsheet script editor (open it with Alt + F11), insert a new module and write the call logic. The sample below focuses on request construction and status handling:

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

    Three engineering details are easy to miss:

    • Escaping: if the question contains double quotes, newlines, or commas, concatenating JSON directly breaks the structure. Escape first, or better, build the body with a serialization function.
    • Streaming responses: with streaming enabled, the response is line-chunked event text. Split by line, strip the prefix fields, then concatenate; do not parse it as a single JSON object.
    • Synchronous blocking: the default synchronous call freezes the UI, which feels bad for long answers. Switch to an async request with an event callback, or move slow work to a background queue and let the main thread poll status.

    6. Troubleshooting Checklist

    • Connection refused: usually the listen address is local-only, or the port differs.
    • Auth failure: whitespace around the key, or a missing Bearer prefix.
    • Empty result: wrong model identifier, or streaming chunks not handled.
    • Occasional timeouts: context exceeds the model window; truncate or summarize in segments.
    • Garbled Chinese: mismatched request and response encodings; standardize on UTF-8.

    7. Advanced Directions

    Once the basic chain works, evolve in three directions. First, add a knowledge base: chunk and vectorize policy documents for retrieval augmentation so answers come with sources. Second, batch processing: merge a whole column of questions into one task and use a message queue to smooth peaks. Third, observability: log latency, input length, and failure reasons for each call, then add monitoring and alerts to form a loop for continuous improvement.

    8. Security and Compliance Reminders

    Local does not mean relaxed management. Enable authentication and least privilege on intranet endpoints, and split workspaces by department; mask sensitive data in inputs and outputs; keep necessary audit logs; treat model output as advisory only, with human review for any decision-making scenario. If you later need elastic scaling, move the stateless orchestration layer to a container platform while keeping the inference layer on your own GPU nodes, balancing elasticity with the data boundary.

    Overall, local deployment is only the starting point; the real payoff comes from embedding model capability into a concrete workflow. Starting from a low-barrier scenario like a spreadsheet assistant, then gradually adding knowledge base, batching, and observability, is a reliable and repeatable path to production.