Running Large Language Models Locally and Connecting Them to Spreadsheets: A Private Q&A Assistant Blueprint

    This article presents a practical architecture for running large language models on local hardware and integrating them with office spreadsheets to build a private Q&A assistant. It covers the value and limitations of local deployment, a three-layer system design, memory estimation formulas, model selection guidance, and the required software components—giving teams a clear path to process internal data without sending it to the cloud.

    1. Why Run Models Locally?

    Deploying a large language model on your own machine delivers three core benefits: input data never leaves the local environment, downloaded models remain usable offline, and there are no per-call API costs. For teams that regularly handle internal materials, these three points often matter more than benchmark scores.

    Spreadsheets are a natural entry point for this setup because they already serve as carriers of large volumes of business data. Typical use cases include:

    • Summarizing, rewriting, or translating text descriptions in spreadsheets;
    • Generating explanations for field names, codes, or terminology;
    • Batch-generating Q&A drafts row by row, followed by human review;
    • Extracting key points from paragraphs in internal reports.

    Local deployment also has clear limitations. Response speed depends on your hardware, and answer quality depends on model size and quantization. Before choosing a model, accept the basic trade-off: smaller models are faster but less capable, while larger models are more capable but require more memory.

    2. Overall Architecture

    The solution is divided into three layers, each responsible for a single task, which makes components easy to replace and troubleshoot independently.

    1. Model runtime layer: Loads model weights and performs inference. This layer does not expose business interfaces directly.
    2. Service layer: Manages workspaces, sessions, and access keys, and exposes chat capabilities externally through HTTP interfaces.
    3. Spreadsheet interaction layer: Reads input cells via macro scripts, calls the service layer API, and writes the returned text back to output cells.

    A complete request flows as follows:

    • The user types a question into an input cell and triggers the macro;
    • The macro script escapes the question text, assembles the request body, and sends it to the service layer;
    • The service layer forwards the question to the model runtime layer, where the model generates a response;
    • The service layer returns the result as a stream, and the macro script parses it line by line and writes it into the output cell.

    The benefit of this layering is that switching models only requires changing the configuration of the model runtime layer—the spreadsheet-side code stays untouched.

    3. Environment Setup

    3.1 Hardware Assessment

    Whether a model can run depends first on whether your memory or VRAM can hold the weights. Use this rule-of-thumb formula for a rough estimate:

    Required memory ≈ parameter count × bytes per parameter × (1 + runtime overhead)

    The runtime overhead typically ranges from 20% to 30%, covering context caching and the runtime itself. For example, a 7-billion-parameter (7B) model with 4-bit quantization uses about 0.5 bytes per parameter, so the weights take up roughly 3.5 GB, and total memory needs come to about 4–5 GB after overhead. This is only an estimate—actual usage also depends on context length and the inference engine, so real-world testing is the final authority.

    3.2 Model Selection

    A common approach is to categorize models by parameter scale, such as 1.5B, 7B, 14B, and 32B. Follow these steps when selecting:

    1. Determine your available memory ceiling;
    2. Choose the largest model tier that fits within that ceiling;
    3. Within the same tier, prefer versions that maintain stable output after quantization.

    For short-text rewriting and summarization, a 7B-class model is usually sufficient. Consider larger models when dealing with complex reasoning or long-document analysis.

    3.3 Software Components

    Three types of software are required:

    • Local model runtime: Loads the model and provides inference capability;
    • Chat service: Handles workspace management and authentication, and exposes HTTP interfaces externally;
    • Office software: Must support built-in macro scripts.