Midnight Ink:在瀏覽器內由 AI 撰寫鬼故事
Midnight Ink: Ghost Stories Written by AI Inside Your Browser
Midnight Ink 是一款在瀏覽器內運行開放權重 AI 模型的鬼故事生成器,用戶可選擇場景、鬧鬼物件和氣氛來生成故事。它採用 SmolLM2-360M-Instruct、Transformers.js 3.8.1 和 ONNX Runtime WebAssembly backend,並在 Web Worker 中生成文字。
This is a submission for the Hacktoberfest Open-Source AI Challenge Week 4: Ghost in the Machine.
What I Built
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.
Demo
The first generation downloads approximately 370 MB of model assets. No API key or paid inference service is required.
Code
The application uses HTML, CSS, JavaScript, and a dedicated Web Worker. Serve the included dist folder over HTTP to run it.
How I Built 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.
Why Does Open Innovation Matter?
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.
Credits and AI Disclosure
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.
來源:DEV Community · dev.to