Building a Local Knowledge Base for Web Novels by Calling LLM APIs
This article explains why a local knowledge base does not require running a model locally, and how to build one by calling cloud LLM APIs. It breaks the system into a document layer, a retrieval layer, and an inference layer, then walks through the architecture, chunking strategy, model routing, hallucination control, cost management, and security practices for handling long-form unpublished text. Readers will find a practical, staged roadmap for setting up a stable and cost-predictable private text analysis workflow without high-end GPUs.
1. Why a “Local Knowledge Base” Is Not the Same as “Running a Model Locally”
When people first approach a private knowledge base, they often assume it means downloading a model and running it on their own machine. This is the most common misconception. A usable knowledge base system actually consists of three layers: a document layer (collecting, cleaning, and chunking source material), a retrieval layer (embedding, indexing, and recall), and an inference layer (the LLM that handles understanding, summarization, and generation). Only the inference layer demands high-end hardware; the document and retrieval layers can run on an ordinary office laptop.
So whether you deploy a model locally is essentially a question of inference-layer selection, not a deciding factor for whether the knowledge base can be built at all. Decoupling these three layers is the first step toward controlling cost and technical risk.
1.1 The Practical Barriers to Local Deployment
Large models place heavy demands on VRAM and memory bandwidth. Even with quantization, consumer-grade GPUs rarely deliver satisfactory results. More importantly, lightweight versions with drastically reduced parameter counts degrade noticeably on complex tasks such as multi-step reasoning, mapping character relationships, and identifying foreshadowing, and they tend to produce contradictions and factual errors. For scenarios that require processing hundreds of thousands of characters continuously, this degradation is amplified.
The conclusion is clear: unless you have compute resources that match the model’s scale, local deployment is unlikely to reach a usable standard. For most individual users and small teams, calling a cloud API is the more pragmatic choice.
1.2 Three Direct Benefits of Calling an API
- Capacity decoupling: Locally you only store chunked text fragments and indexes, so long documents are no longer constrained by the conversation window.
- Elastic concurrency: Batch tasks such as bulk summarization and bulk tagging can be submitted in parallel instead of queuing for local resources.
- Continuous upgrades: Inference capability is improved by the provider, so users do not have to maintain weights or inference frameworks themselves.
Note that service tiers differ in response speed. Free tiers may involve long queues during peak hours, while paid tiers typically offer more stable throughput. When choosing a service, the first principle should be “whether it can return results reliably,” rather than simply chasing first-token latency.
2. Overall Architecture
A local web-novel knowledge base meant for long-term maintenance should follow this layered structure:
Raw documents → Parsing & cleaning → Structured chunking → Embedding → Local index↓User question → Query rewriting → Hybrid retrieval → Context assembly → LLM inference → Answer with sources
Responsibilities and key points for each stage:
- Parsing and cleaning: Unify encoding, strip headers, footers, ads, and duplicate paragraphs, and preserve the chapter title hierarchy.
- Structured chunking: Split by chapter, scene, and dialogue turn; keep each fragment to a few hundred characters; and retain “work—volume—chapter” metadata.
- Embedding: Call a cloud embedding endpoint to generate vectors and store them locally to avoid repeated billing.
- Hybrid retrieval: Vector recall handles semantic similarity, while keyword recall handles exact matching of proper nouns such as character names, place names, and move names; the two result sets are merged and reranked.
- Context assembly: Select fragments by relevance, keep the total length within a safe range of the model’s window, and attach source markers.
3. Key Implementation Details
3.1 Chunking Strategy Sets the Ceiling for Retrieval
Web novels are characterized by long dialogues, multiple perspectives, and jumping timelines. Cutting rigidly by a fixed character count tends to break up a complete conversation, causing retrieval to return “half a sentence.” A more reliable approach is to split along natural structural boundaries first, then perform a secondary split within overly long chapters, keeping a small overlap between fragments to avoid losing boundary information.
3.2 A Division-of-Labor Approach to Model Selection
Reasoning-oriented models excel at divergence and causal inference, making them suitable for mapping character relationships and checking for plot holes. General-purpose chat models follow instructions more conservatively, making them suitable for factual queries, setting verification, and excerpt organization. In practice, you can route tasks to different models by task type instead of using one model for the entire workflow.
Illustrative call logic (pseudocode; refer to the actual service documentation for endpoint names):
def ask(question, task_type):fragments = hybrid_search(question, top_k=8)context = assemble(fragments, max_chars=12000)model = "reasoning" if task_type == "analysis" else "general"return chat_completion(model=model,messages=[{"role": "system", "content": SYSTEM_PROMPT},{"role": "user", "content": f"Source fragments:\n{context}\n\nQuestion: {question}"},],temperature=0.3 if task_type == "lookup" else 0.6,)
3.3 Suppressing Confident Fabrication
The most common failure mode in long-text question answering is the model filling in settings on its own when the material is insufficient. You can constrain this in three ways: explicitly instruct in the prompt to state when information is missing rather than inventing it; require the answer to cite fragment numbers item by item; and add a second verification pass for key conclusions, sending the model back to the source text to check before outputting.
3.4 Cost and Stability Control
- Set up a local cache so identical questions are not requested repeatedly;
- Generate embeddings once and reuse them long-term;
- Merge batch tasks into combined requests to lower per-unit cost;
- Configure backoff retries for failed requests to avoid giving up outright during peak hours;
- Log the fragment count and latency of each call for later optimization.
4. Security and Compliance
Unpublished manuscripts are high-value assets. When selecting a service, check whether the provider commits to not using request data for training and whether it supports no-persistence or encrypted transmission; on the local side, store indexes and caches encrypted and enforce access isolation. When the content involves others’ copyrighted material, limit use to personal study and research and avoid redistribution.
5. Recommended Rollout Path
In the first phase, get a minimal loop working: one document, one index, and one type of question. In the second phase, expand the corpus and introduce hybrid retrieval and citation labeling. In the third phase, add batch tasks, caching, and monitoring to form a knowledge base that can be operated sustainably. Following this path, even without a high-performance GPU, you can obtain stable, controllable, and cost-predictable private long-text analysis capability.
