Development workflow
Small AI Models in Native Software: From Experiment to Useful Feature
Running AI locally opens interesting possibilities for desktop applications. Making it useful takes careful choices about tasks, hardware, integration and testing.
There is something appealing about software that can work with your own files, on your own machine, without sending every question to a remote service. Small language models make that worth exploring: summarising selected documents, explaining unfamiliar terminology, organising notes or helping users navigate information already available inside an application.
The most promising starting point is a specific task with a recognisable result. “Summarise these three reports and identify the unresolved questions” gives a developer something concrete to evaluate. It defines the input, the expected output and the limits of what the model can reasonably know.
Before choosing a model, collect representative examples and decide what a useful answer looks like. Include situations where the information is incomplete and the correct response must acknowledge that. Compare the proposed feature with an ordinary search, filter or template, too. The extra complexity should earn its place in the application.
“Small” is relative to the computer running it. A model that feels comfortable on a development workstation may compete heavily with other applications on a laptop. Parameter count and download size provide only part of the picture. Runtime memory also includes working buffers, context storage and the surrounding application. For many transformer models, the attention cache adds a substantial memory cost whose behaviour depends on the model and cache strategy. Hugging Face’s cache documentation [1] explains these trade-offs.
Quantisation can reduce the memory needed for model weights by representing them at lower precision. Its effect on response quality and speed needs testing on the intended hardware; a smaller representation does not guarantee lower latency. The inference optimisation guide [2] describes this distinction.
Measure the complete workload: loading the model, processing the input, generating the answer and returning it to the interface. Record peak memory as well as steady usage. Test with the rest of the application open and doing useful work. A successful load establishes that one configuration can initialise; generation quality still needs its own evaluation.
Native integration offers several architectural choices. An application can call an inference library through a native interface, or communicate with a separate local worker process. Existing C inference APIs [3] demonstrate how model execution can sit behind a conventional programming interface.
An embedded library can provide close integration, while sharing the application’s process and failure conditions. A separate worker introduces communication and lifecycle management, but makes it easier to restart inference independently and replace the runtime later. For an early implementation, a worker owned by the application is often a manageable starting point.
Give that worker a narrow contract. Each request should identify the task, carry only the necessary input and specify its limits. Each response should include the request identifier and an explicit outcome: completed, cancelled, timed out or failed. Keep loading and generation away from the interface thread, and ensure cancellation actually stops the work.
Consider a document viewer that offers “Explain this selection.” The application can send the selected passage and a few relevant excerpts, each with a stable source identifier. The worker returns an explanation with references. The application checks those references and lets the user open the original text. A reference pointing to a real passage establishes traceability; whether the passage supports the explanation still needs scrutiny.
Structured output makes this easier to handle. Grammar-constrained generation can restrict responses to formats such as JSON, as described in the llama.cpp grammar documentation [4]. The receiving application should still parse the complete response, validate its schema and check the values against the supplied data. A well-formed response can contain an invented identifier or an unsupported conclusion.
Place limits around the entire exchange: input size, generated tokens, response bytes, elapsed time and concurrent requests. Count everything the receiver processes, including whitespace and formatting. A limit on one text field does not bound the complete response. Treat interrupted or incomplete output as an explicit outcome, and keep provisional streamed text distinct from a completed result.
Testing should cover the situations users will actually encounter:
• Ordinary examples with clear, verifiable answers.
• Missing or contradictory information.
• Long inputs, unusual characters and truncated responses.
• Documents containing instructions that try to redirect the model.
• Cancellation, worker crashes, memory pressure and repeated requests.
Separate delivery reliability from answer quality. Did the model finish within its resource budget? Was the response accepted by the receiver? Was the answer supported and useful? Track these separately so that an improvement in one area cannot conceal a failure in another.
Tokens per second can help diagnose performance, but users experience the whole operation. Measure time to a usable answer, interface responsiveness, cancellation delay and the proportion of requests that produce acceptable results within the budget. Repeat tests, retain failures and reserve examples that are not used while tuning prompts.
Reproducibility also requires more than saving the prompt. Record the exact model revision, quantisation, tokenizer, runtime, generation settings and chat template. Chat models expect particular message formatting, and incorrect control tokens can substantially affect performance. The chat template documentation [5] explains why these details belong in the configuration being tested.
Local execution gives developers greater control over where processing happens. Privacy still depends on the complete application: downloads, telemetry, logs, temporary files and any optional network services. Verify offline behaviour directly. Keep document contents separate from trusted application instructions, and enforce permissions in native code. A separate process provides a useful failure boundary; security isolation requires additional controls.
The everyday experience deserves equal attention. Show when a model is loading, make cancellation easy, preserve access to the original material and allow the AI feature to be disabled. Core workflows should remain usable when the model is unavailable. Treat model and runtime updates as software changes that need regression testing and a recoverable previous version.
A useful local AI feature can be modest: a clearer explanation, a better route through documentation or a draft that saves someone time. Its value becomes convincing when the surrounding software makes its sources, limits and failures understandable—and the feature keeps helping after the demonstration is over.