Building a Local-First Markdown Knowledge Base and an AI-Assisted Model Selection Guide
This guide explains how to build a local-first, plain-text knowledge base in Markdown and how to choose AI models for it in a rational, measurable way. It covers directory structure and naming conventions, front matter and templates, atomic notes and linking, full-text versus semantic retrieval, and the 3-2-1 backup principle. It then presents a practical evaluation workflow for LLM selection: define tasks first, build a small golden test set from real notes, standardize API calls behind one wrapper, and score candidates on correctness, format adherence, context grounding, stability, and unit cost. It also covers how to use free tiers and trial credits for evaluation, prompt and context strategies, security boundaries, and a four-week rollout plan.
1. Why Choose a Local-First, Plain-Text Knowledge Base
Local-first means the authoritative copy of your data lives on your own disk, while the cloud handles only synchronization and enhancement. Compared with locking notes inside a proprietary format, a plain-text approach offers three structural advantages.
- Portability: Markdown is plain text. Any editor can open it, so migration cost is close to zero.
- Versionability: Text is naturally suited to version control. Line-by-line diffs make it possible to answer “why did I write this last week?”
- Automatability: Scripts can process text in bulk—adding metadata, generating indexes, or enhancing whole-vault retrieval.
It is worth emphasizing that tools are only the carrier. What actually determines the value of a knowledge base is structural discipline and retrieval capability. The sections below follow the order: structure, content, retrieval, backup, and intelligent enhancement.
2. Directory Structure and Naming Conventions
Define the conventions before writing your first note. Keep the top-level layout flat to avoid the path-maintenance cost of deep nesting:
vault/├── 00-inbox/ # temporary capture, cleared daily├── 10-notes/ # atomic knowledge cards├── 20-maps/ # topic maps (MOCs, content index pages)├── 30-sources/ # source excerpts and references├── 40-templates/ # templates└── 90-assets/ # images and attachments
Naming suggestion: YYYYMMDD-topic-phrase.md. The date prefix guarantees stable sorting. Use a readable phrase in Chinese or English, without spaces or special characters. Store all attachments under 90-assets and reference them with relative paths in note bodies, so links keep working when the whole directory is moved.
3. Metadata and Templates
Front matter is the foundation for later automation and retrieval enhancement. A minimal usable template looks like this:
---title: Three Approaches to Index Constructioncreated: 2026-08-26tags: [retrieval, architecture]status: draftsource: 30-sources/20260820-source-excerpt.md---## ConclusionGive the answer first, then the derivation.## Details...## Related- [[20-maps/retrieval-topic-map]]
Keep fields few and stable: title, created, tags, status, source. The more fields you add, the heavier the maintenance burden, and the more likely the convention collapses.
4. Atomic Notes and Links: Making Knowledge Composable
One note expresses exactly one complete idea—that is atomicity. The benefit of atomicity is reuse: the same concept card can be referenced by multiple topic maps without copy-pasting. Links fall into two categories:
- Structural links: index pages point to cards, forming a map of content (MOC).
- Semantic links: cards express relationships such as “supports / refutes / extends.” It is best to write a one-line explanation next to the link.
The test is simple: if you need to copy content in order to reuse it, the granularity is too coarse.
5. Retrieval: From Full-Text Search to Semantic Search
The first layer is full-text keyword search: low cost, deterministic, and suitable for exact lookup. The second layer is semantic search: chunk cards, embed them into a vector index, and retrieve relevant fragments by asking questions in natural language. Three engineering details matter: chunk size and overlap, metadata filtering (narrowing by tag or time), and reranking of retrieved results. Semantic search handles “I can’t remember the keyword,” while full-text search handles “I need an exact match.” They should coexist rather than replace each other.
6. Backup and Reliability
Follow the 3-2-1 principle: at least three copies, two types of media, and one off-site. For a text vault, use version control for local history, then add an off-site sync on top. If you need a cloud tier, you can use general-purpose capabilities such as object storage, logging services, and monitoring and alerting from cloud providers for cold backup and observability, so that the only copy never lives in a single location.
7. AI-Assisted Model Selection: Use Free Tiers First, Then Decide on Paying
Once you connect your knowledge base to a large language model, the question of model selection follows. The rational path is to run a quantifiable evaluation using free quotas first, then decide whether to pay, rather than being led by parameter counts and leaderboards.
7.1 Define the Task, Not the Model
First write down the 3–5 things you want the model to do, for example: card summarization, tag completion, retrieval-result reranking, and long-document Q&A. Different tasks have different optimal answers. “Who is stronger” is meaningless outside of a task.
7.2 Build a Small Golden Test Set
Draw 30–50 real samples from your own vault and write reference answers by hand. Samples must come from real scenarios—this is what makes the evaluation valid.
7.3 Standardize Calls and Scoring
Use a unified wrapper to hide interface differences, so switching candidates only requires changing configuration:
import os, json, urllib.requestdef call_model(prompt: str, base_url: str, model: str) -> str:body = json.dumps({"model": model,"messages": [{"role": "user", "content": prompt}],"temperature": 0.2,}).encode("utf-8")req = urllib.request.Request(os.environ["LLM_BASE_URL"].rstrip("/") + "/chat/completions",data=body,headers={"Content-Type": "application/json","Authorization": "Bearer " + os.environ["LLM_API_KEY"]},)with urllib.request.urlopen(req, timeout=60) as resp:return json.load(resp)["choices"][0]["message"]["content"]
The scoring sheet should use five fixed dimensions, each scored 1–5: correctness, format adherence, context utilization (whether the model answers only from the given fragments), stability (consistency across repeated runs on the same input), and unit cost. Sum with weights and sort; adjust the weights by task.
7.4 How to Use Free Quotas
The general value of free quotas and trial credits is that they lower the cost of trial and error, but they come with expiration dates and rate limits. Practical advice: concentrate evaluation within the quota period, first run a small sample to validate the pipeline, then run the full set; also record input and output lengths per call so you can later estimate real costs after switching to paid usage. Note that free tiers often come with different data-usage terms. For sensitive content, prefer services with clear terms and the ability to disable data retention.
7.5 Prompt and Context Strategy
- Specify the role and output format, and require the model to “answer only from the provided material; if missing, say you do not know.”
- A long context is not the same as effective use. Retrieve first, then assemble, and control the number of injected fragments.
- Use a low temperature for extraction tasks and raise it moderately for creative tasks.
8. Security Boundaries
Redact before uploading anything to a cloud model: remove keys, internal addresses, and customer information. Read keys only from environment variables or a secret management service; never write them into note bodies. Assume external content is untrusted input, and prevent embedded instructions from altering model behavior.
9. Rollout Plan
- Week 1: set the directory and naming conventions, migrate existing material, and clear the inbox.
- Week 2: add templates and metadata, and create 2–3 topic maps.
- Week 3: connect full-text search and get backups running.
- Week 4: complete the golden-set evaluation using free quotas, and use the scoring sheet to decide whether to pay for a specific scenario.
10. Conclusion
The value of a knowledge base comes from structure, retrieval, and continuous maintenance; the model is only an amplifier. Use free quotas to make the evaluation solid first, then let budget follow quantifiable returns—the path with the lowest cost and the fewest reworks.
