This project was created to help an author maintain consistency in characters, plotlines, and world-building while writing an ongoing online novel.
It acts as:
- 📚 A private story library
- 🧠 A semantic memory engine
- 🔎 A fact-checking assistant
- 🧩 A plot consistency verifier
The goal is to ensure that as new chapters are written, the author can verify:
- Character motivations remain consistent
- Timeline continuity is maintained
- Plot threads are not contradicted
- Previously established facts are preserved
In long-running serialized fiction:
- Characters evolve over many chapters
- Minor details are easily forgotten
- Retcons accidentally occur
- Subplots may contradict earlier arcs
This system provides a searchable semantic memory of the entire novel, allowing the author to verify facts instantly instead of manually rereading everything.
Example questions:
- “Has this character ever met the king before?”
- “What was the original reason for the betrayal?”
- “Did I already define this magic rule earlier?”
- “Is this action consistent with Chapter 12?”
-
Chapters are stored as
.txtfiles. -
Text is:
- Split into chunks
- Converted into embeddings
- Stored in a vector database (ChromaDB)
-
When a question is asked:
- Relevant story fragments are retrieved
- Injected into the prompt
- The local LLM (
phi3) generates a context-aware response
This creates a lightweight Retrieval-Augmented Generation (RAG) pipeline optimized for fiction tracking.
- No external APIs
- No cloud dependency
- No data leaves your machine
- Safe for unpublished manuscripts
- Streamlit – User Interface
- ChromaDB – Vector Database
- Ollama – Local LLM Runtime
- phi3 – Fast inference model
- nomic-embed-text – Local embedding model
Follow these steps carefully.
Download and install from:
After installation, pull required models:
ollama pull phi3
ollama pull nomic-embed-textVerify Ollama is running:
ollama run phi3Then stop it with Ctrl+C.
Optional (check GPU usage on Apple Silicon):
ollama psIt should show:
PROCESSOR: gpu
Inside your project folder:
python3 -m venv venv
source venv/bin/activatepip install streamlit chromadb ollamaEnsure your structure looks like this:
NovelAssistant/
│
├── app.py
├── story_db/ # Auto-created vector database
├── my_novel_pages/ # Add your .txt chapters here
└── README.md
Place your novel chapters as .txt files inside:
my_novel_pages/
Example:
my_novel_pages/
├── chapter1.txt
├── chapter2.txt
├── notes.txt
From the project root directory:
streamlit run app.pyYour browser will open automatically.
Inside the sidebar:
Click:
“Sync New Chapters/Notes”
This will:
- Split chapters into chunks
- Generate embeddings
- Store them in ChromaDB
Once synced, you can start asking questions.
If you ever switch embedding models and get:
Embedding function conflict
Delete the vector database:
rm -rf story_dbThen restart and sync again.
For best performance:
- Use
phi3 - Keep chunk size around 600
- Use retrieval
k = 2 - Limit output tokens (
num_predict = 300)
Expected response time: 1–3 seconds on M1
- Character profile auto-extraction
- Timeline visualization
- Relationship graph mapping
- Contradiction detection alerts
- Arc-level summarization memory
Writers of serialized fiction who want:
- Long-term narrative consistency
- A private AI assistant
- Structured plot validation
"Write freely. Let the system remember everything."