My Ghost Writer and lite.koboldai.net, an overview
Some time ago I started drafting a text. Out of professional curiosity and sheer boredom, I wondered what kind of AI applications were feasible beyond the obvious text generation via prompts to LLMs.
In particular, I noticed that smaller LLM (Large Language Models) tend to repeat themselves and insert duplicate words. This led me to search for an open-source project I could run on my PC to identify duplicate words – but I found nothing useful or that did exactly what I wanted.
This ultimately led to the creation of My Ghost Writer, an open-source project now being integrated into lite.koboldai.net – a lightweight, dependency-free web interface for KoboldCpp.
lite.koboldai.net
lite.koboldai.net is a dependency-free web interface designed as a backend for large language models (LLM) like KoboldCpp. It runs entirely in the browser (no installation required) and is packaged as a single static HTML file:
- Multiple modes: Story mode, Chat mode, Instruction mode, and Adventure mode for different types of AI interaction.
- Broad compatibility: Works with KoboldAI Client, KoboldCpp, and AI Horde; supports both local and remote models.
- Creative tools: Includes a text editor, image generation via Stable Diffusion, and support for character sheets and scenarios.
- User-friendly: Easy to use, customizable UI styles, and features like auto-save, text-to-speech, and repeat/edit options.
It's a great option if you want a lightweight, flexible interface for storytelling, role-playing, or AI-assisted writing. However, the code structure is somewhat messy:
- A monolithic
index.html
with over 26,000 lines of JS, CSS, and HTML. - Only vanilla JS, no TypeScript obviously.
- Outdated third-party JS code.
- Missing E2E tests.
The Problem with WordSearch in lite.koboldai.net
The initial version of WordSearch
(based on my first implementation) in lite.koboldai.net used simple text search to detect duplicates, but had significant limitations:
- Identified irrelevant text fragments (e.g., the single letter "a" even when embedded in other words).
- Couldn't distinguish between semantically different words (e.g., "the" vs. "they").
The Solution: NLP Stemming with My Ghost Writer
To solve this, I reimplemented the duplicate detection logic using NLP stemming (via the Porter Stemming algorithm, already included in lite.koboldai.net), which reduces words to their root form (e.g., "running" → "run"). This approach:
- Groups semantically related words (e.g., "run", "running", "ran").
- Reduces false positives by focusing on real duplicates.
- Supports both manual input and file upload for flexibility.
Current Features and Limitations
Main Features
- Duplicate word detection via stemming.
- Thesaurus (work in progress):
- Powered by calls to WordsAPI.
- Optional data persistence with a local MongoDB database.
- Limited to common terms ⚠️, doesn't support (for now) proper nouns or multi-word expressions.
Technologies Used
- Backend:
- Python 3.10+ with FastAPI to run the webapp.
- Structlog for logging and error handling.
- Poetry for dependency management.
- Docker for containerization.
- Frontend:
- Vanilla JavaScript (no framework due to integration with lite.koboldai.net).
- Playwright for end-to-end (E2E) testing.