This is a submission for the Hacktoberfest Open-Source AI Challenge Week 4: Ghost in the Machine. Midnight Ink is a ghost-story generator powered by an open-weight AI model running inside your browser.
Choose an eerie setting, a haunted object, and a mood, then summon a story. Watch the words appear as they are generated, stop whenever you want, and copy or download the result.
My interpretation of “Ghost in the Machine” is literal: the storyteller lives on the visitor’s own device.
The first generation downloads approximately 370 MB of model assets. No API key or paid inference service is required.
The application uses HTML, CSS, JavaScript, and a dedicated Web Worker. Serve the included dist folder over HTTP to run it.
The application uses SmolLM2-360M-Instruct through its ONNX Community conversion, with Transformers.js 3.8.1 and ONNX Runtime’s WebAssembly backend.
The quantized model runs in a Web Worker, keeping the interface responsive while generated text streams into the manuscript panel.
Story prompts are processed locally. Initial library and model downloads require an internet connection; guaranteed offline startup is not implemented.
A successful browser test downloaded the model and streamed actual generated text. The small model sometimes writes poetry instead of prose, repeats itself, or misses requested details. There is no prewritten story fallback.
Downloadable model weights make on-device generation possible without sending story prompts to a remote inference API.
The model is visible and replaceable. Developers can experiment with compatible alternatives and balance writing quality, download size, memory, and speed.
The tradeoff is a substantial initial download and performance that depends on the visitor’s device.
Built with ChatGPT/Codex assistance for implementation, styling, testing, and this write-up.
Thanks to Hugging Face’s SmolLM team, ONNX Community, Transformers.js, and ONNX Runtime.