ModelDuck — Making Local AI Run Better
Inspiration
Running large language models locally should not require becoming an inference-engine engineer.
I wanted a practical way to run GGUF models on ordinary hardware, understand their performance, and automatically find configurations that work best for each machine.
The problem is that local inference has many interacting variables: CPU threads, GPU offloading, context length, KV cache, batch size, sampling parameters and memory limits. A configuration that works beautifully on one computer can be inefficient or unusable on another.
Most applications expose these settings but leave optimization to the user.
I wanted ModelDuck to go further.
What it does
ModelDuck is a local-first GGUF model studio, inference server and hardware-aware optimization tool.
It brings together three capabilities:
- Model management: Discover, import and download GGUF models, with SHA-256 verification and resumable downloads.
- Local inference: Load models using CPU or supported GPU acceleration, configure their execution and expose an OpenAI-compatible API with streaming.
- Automatic optimization: Benchmark configurations, compare candidates and identify settings that offer a better balance between output quality, generation speed and resource consumption.
The tuning system evaluates model execution settings separately from sampling and prompting settings. It uses controlled comparisons, multiple-comparison correction and validation on unseen test items to avoid treating random benchmark fluctuations as improvements.
Optimization runs can be paused, resumed and inspected. Recommendations are based on measurements rather than arbitrary presets.
How I built it
ModelDuck is built with Node.js and JavaScript, using a lightweight native HTTP server, a vanilla JavaScript control panel and node-llama-cpp for local inference.
The application maintains its own model registry, engine lifecycle, download manager, configuration system, benchmark runner and tuning scheduler.
Its API exposes OpenAI-compatible model and completion endpoints, including server-sent event streaming. This allows existing AI applications and development tools to use a locally running ModelDuck instance.
Privacy was a deliberate architectural decision: model weights, conversations, prompts and settings remain on the user's computer. Network access is used for model downloads explicitly initiated by the user, not remote inference or telemetry.
Challenges
One of the biggest challenges was making optimization scientifically meaningful.
A faster configuration is not necessarily a better configuration if it compromises output quality. Benchmark noise, changing test sets, different runtime versions and model configurations can all produce misleading conclusions.
I addressed this with versioned benchmark suites, test hashes, runtime and model identity checks, repeatable comparisons and quality regression gates.
Another challenge was asynchronous reliability. Model loading, downloading, cancellation, tuning and benchmarking all involve long-running operations. I had to make their state transitions explicit and handle race conditions, interrupted jobs and failed operations without leaving the application in inconsistent states.
What I learned
Building ModelDuck changed how I think about local AI performance.
There is no universally optimal inference configuration. Performance is a property of the model, hardware, workload and execution strategy together.
I also learned that an optimization system needs to prove that an improvement is real. Token-per-second measurements alone are not enough; reproducibility, output quality and resource constraints matter just as much.
ModelDuck is my attempt to make local AI configuration something the computer can measure, understand and improve — rather than something users have to guess.
Built With
- ai-inference
- benchmarking
- cpu-optimization
- gguf
- gpu-acceleration
- hyperparameter-optimization
- javascript
- large-language-models
- local-ai
- model-evaluation
- node-llama-cpp
- node.js
- openai-api
- performance-optimization
- privacy
- vulkan