Deep Dive: Architecture & Operations
Tổng quan Intro
Architecture của LLM Wiki trông deceptively simple: 3 lớp, 3 operations, 2 special files. Nhưng sự đơn giản này là có chủ đích. Karpathy thiết kế để bất kỳ ai có folder và Claude account có thể bắt đầu trong 30 phút — không cần server, không cần embeddings, không cần code.
Deep dive này đi vào từng quyết định thiết kế: tại sao raw sources phải immutable, tại sao CLAUDE.md là "real product", tại sao index.md đủ tốt đến 200 pages, và ingest/query/lint prompt templates cụ thể.
Architecture — Ba lớp Architecture
1. Three Layers — Tại sao mỗi lớp tồn tại
1Layer 1: Raw Sources — Immutability là tính năng
Raw sources không bao giờ được modify bởi LLM. Đây là design decision quan trọng nhất trong toàn bộ kiến trúc. Tại sao?
Layer 2: Wiki — LLM owns this completely
Đây là điểm khác biệt với mọi knowledge tool khác: bạn không viết wiki. LLM viết. Bạn chỉ đọc, provide direction, và occasionally curate. Điều này eliminates bookkeeping burden — lý do #1 mọi người abandon wikis.
Layer 3: CLAUDE.md — Protocol, không phải data
CLAUDE.md không chứa content — nó chứa protocol. Nó trả lời: "Khi tôi gặp một source mới, tôi phải làm gì? Entity page format là gì? Confidence score được tính như thế nào?" Đây là interface giữa bạn và LLM cross sessions.
Ưu điểm
- Invariant rõ ràng → LLM ít confuse về "tôi được phép sửa file nào"
- Wiki có thể rebuild từ đầu nếu corrupted
- Schema shared → người khác có thể dùng cùng wiki ngay lập tức
- Layers có thể swap độc lập (ví dụ: đổi storage backend cho wiki)
Nhược điểm
- Phải maintain discipline không sửa raw sources thủ công
- Schema phải được sync với actual wiki behavior — drift gây inconsistency
2. Folder Structure — Every File Has a Job
2Cấu trúc đầy đủ
my-wiki/ — full structure
my-wiki/
│
├── CLAUDE.md ← Schema: conventions + workflows (bạn + LLM co-evolve)
│
├── raw/ ← IMMUTABLE sources (bạn curate, LLM chỉ đọc)
│ ├── papers/
│ │ ├── attention-2017.pdf
│ │ └── gpt3-2020.pdf
│ ├── articles/
│ │ └── scaling-laws-explained.md
│ └── notes/
│ └── meeting-2026-04-10.md
│
└── wiki/ ← LLM-OWNED content
├── index.md ← Catalog: tất cả pages + one-line summary
├── log.md ← Append-only chronological log
│
├── entities/ ← Concept/entity pages (1 file = 1 concept)
│ ├── attention-mechanism.md
│ ├── transformer-architecture.md
│ ├── bert.md
│ └── gpt-3.md
│
├── comparisons/ ← Cross-cutting comparisons
│ └── bert-vs-gpt.md
│
├── synthesis/ ← High-level synthesized views
│ └── timeline-llm-breakthroughs.md
│
└── _inbox/ ← Raw observations, pending processing
└── session-2026-04-11.md_inbox/,
rồi định kỳ ask Claude: "Look at my inbox folder and suggest where each note
should be filed." Không bao giờ để perfect be the enemy of useful.
3. CLAUDE.md Schema — Full Template
3CLAUDE.md template đầy đủ
CLAUDE.md — production template
# Wiki Schema
## Overview
This is a personal research wiki on [YOUR TOPIC].
You are the wiki maintainer. I curate sources; you do all the bookkeeping.
## Directory Structure
- raw/ — immutable source documents. NEVER modify.
- wiki/ — your domain. Create, update, maintain all files here.
- wiki/index.md — catalog of all pages (update after every ingest)
- wiki/log.md — append-only log (update after every operation)
- CLAUDE.md — this file
## Entity Page Format
```markdown
# [Entity Name]
**Type**: Concept | Person | Project | Library | Decision | Event
**Summary**: One sentence. Must be standalone (no "it" or "this").
**Tags**: #tag1 #tag2
**Sources**: [[raw/paper1.pdf]], [[raw/article1.md]]
**Last Updated**: YYYY-MM-DD
**Confidence**: 0.85 (2 sources, confirmed 2026-04-10)
---
## Overview
2-3 paragraph explanation for someone unfamiliar.
## Key Properties / Arguments
Bullet list of concrete, verifiable claims.
## Relationships
- **uses**: [[Entity A]] — why/how
- **depends_on**: [[Entity B]]
- **contradicts**: [[Entity C]] — what they disagree on
- **supersedes**: [[Entity D]] (as of 2026-04-10)
## Open Questions
Things still unclear or needing more sources.
## References
- [[raw/paper1.pdf]] — specific claim from here
```
## Ingest Workflow
When I say "ingest [source]":
1. Read the full source from raw/
2. List entities you found (confirm with me before writing)
3. For each entity:
a. Check if page exists in wiki/entities/
b. If yes: update, mark changed sections, update confidence, log supersessions
c. If no: create new page using format above
4. Update wiki/index.md (add new pages, update summaries of changed pages)
5. Append to wiki/log.md: \`## [DATE] ingest | SOURCE TITLE\`
6. Note: one source may touch 10-15 pages — be thorough
## Query Workflow
When I ask a question:
1. Read wiki/index.md to find relevant pages
2. Read those pages (and their linked pages if needed)
3. Synthesize answer with citations to wiki pages
4. If answer is valuable: offer to file as new wiki page
## Lint Workflow (run every ~20 new pages)
Check for:
- Contradictions between pages → flag both, propose resolution
- Stale claims (confidence < 0.4) → flag for re-verification
- Orphan pages (no inbound links) → suggest where to link
- Concepts mentioned but lacking own page → propose creation
- Missing cross-references → add them
Report findings before making changes.
## Conventions
- Always use [[wiki-links]] for cross-references (Obsidian format)
- Confidence = (number_of_supporting_sources * 0.3) * (1 - decay_factor)
- Decay: 0.02 per week since last confirmation
- When superseding: mark old claim with ~~strikethrough~~ + link to new
- Contradictions: add ⚠️ badge on both pages + log entryOperations — Chi tiết từng bước Operations
4. Ingest — Full Flow với Prompt Templates
4Minimal ingest prompt (for Claude.ai)
Paste vào Claude với PDFs attached
You are maintaining my research wiki. I'm uploading [N] sources on [TOPIC].
For each source:
1. Identify all key entities (concepts, people, systems, papers)
2. Create one markdown entity page per concept in wiki/ format (see template)
3. Add [[wiki-links]] connecting related concepts
4. Note any contradictions between sources
5. Create wiki/index.md listing all pages with one-line summaries
6. Create wiki/log.md with ingest entry
Use this entity page format:
[paste format from CLAUDE.md]
After writing all pages, give me a brief summary of what was created/updated.Update ingest prompt (existing wiki)
Khi wiki đã có content
Ingest this new source into my existing wiki.
First, read wiki/index.md to see what pages already exist.
Then read the source.
For each entity in the source:
- If page exists: UPDATE it (note changes, update confidence, log supersessions)
- If page doesn't exist: CREATE it
Important: this source may contradict existing claims.
If you find contradictions, flag them with ⚠️ on both pages.
After ingesting, update index.md and append to log.md.Flow diagram
Ưu điểm
- Ingest từng source một → bạn đọc summary, guide emphasis
- Batch ingest nhiều sources → faster nhưng ít control hơn
- LLM flags contradictions ngay lập tức — không cần remember
- "Good answers filed back as pages" — explorations compound như sources
Nhược điểm
- LLM có thể create duplicate pages với slightly different names
- Confidence scoring không hoàn hảo — cần occasional review
- Ingest lớn (>10K word source) có thể cần chunking
5. Query — Các modes và output formats
5Query modes
| Mode | Prompt | Output |
|---|---|---|
| Direct Q&A | "What do I know about attention mechanisms?" | Markdown answer với citations |
| Synthesis | "Compare BERT vs GPT based on my wiki" | Comparison table → file as wiki page |
| Gap finding | "What am I missing about scaling laws?" | List of gaps → suggest sources |
| Slide deck | "Create slides summarizing my transformer research" | Marp markdown → export PDF |
| Chart/visualization | "Chart the timeline of LLM breakthroughs in my wiki" | matplotlib code |
File-back pattern
File good answers back
# After receiving a good synthesis answer:
"This comparison is valuable. Please file it as wiki/comparisons/bert-vs-gpt.md
and add it to index.md with summary: 'Comparison of bidirectional vs autoregressive
pre-training: BERT vs GPT architectures'"
# After a research session:
"File the key insights from this session as wiki/synthesis/session-2026-04-20.md"6. Lint — Wiki Health Check
6Lint prompt template
Lint prompt
Run a health check on my wiki.
Read wiki/index.md and check all pages for:
1. CONTRADICTIONS: Claims on different pages that disagree
→ Flag both pages, propose which is more likely correct and why
2. STALE CLAIMS: Claims with confidence < 0.4 or last confirmed > 60 days ago
→ Mark for re-verification, suggest what source to look for
3. ORPHAN PAGES: Pages with no inbound [[wiki-links]]
→ Suggest where they should be linked from
4. MISSING PAGES: Concepts mentioned in passing but lacking own page
→ Propose page titles and stubs
5. BROKEN LINKS: [[wiki-links]] pointing to non-existent pages
→ Fix or flag
Report findings as a list. DON'T make changes yet.
After I review, I'll say "apply fixes" for each category.Lint cadence
Infrastructure Files Impl
7. index.md — Catalog Design
7index.md format chuẩn
wiki/index.md
# Wiki Index — [Your Topic]
Last updated: 2026-04-20 | Pages: 47 | Sources: 12
## Entities
### Architectures
| Page | Summary | Sources | Confidence |
|------|---------|---------|------------|
| [[transformer-architecture]] | Encoder-decoder with self-attention (Vaswani 2017) | 4 | 0.95 |
| [[bert]] | Bidirectional masked LM pre-training | 3 | 0.90 |
| [[gpt-3]] | Autoregressive LM with few-shot emergence | 2 | 0.85 |
### Concepts
| Page | Summary | Sources | Confidence |
|------|---------|---------|------------|
| [[attention-mechanism]] | Scaled dot-product attention over sequence | 5 | 0.98 |
| [[scaling-laws]] | Chinchilla: compute-optimal token/param ratio | 3 | 0.88 |
## Comparisons
- [[bert-vs-gpt]] — Bidirectional vs autoregressive pre-training tradeoffs
- [[rlhf-vs-dpo]] — Reward model vs direct preference tradeoffs
## Synthesis
- [[timeline-llm-breakthroughs]] — Chronological view of key developments
- [[open-questions]] — Unresolved questions and gaps
## ⚠️ Flagged Issues
- [[scaling-laws]]: Contradiction with [[chinchilla-paper]] on token ratio
- [[bert]]: Confidence 0.35 (last confirmed 2026-01-10, needs refresh)8. log.md — Audit Trail
8log.md format với unix parseability
wiki/log.md
## [2026-04-20] ingest | Attention Is All You Need (Vaswani et al. 2017)
Created: transformer-architecture.md, attention-mechanism.md, positional-encoding.md
Updated: index.md (+3 entries, updated architecture section)
Flags: None
## [2026-04-20] ingest | BERT: Pre-training Deep Bidirectional Transformers (2018)
Created: bert.md, masked-language-modeling.md, next-sentence-prediction.md
Updated: transformer-architecture.md (added BERT as derivative)
Flags: ⚠️ BERT contradicts GPT-* on directionality claim → flagged in both pages
## [2026-04-20] query | "How does multi-head attention differ from single-head?"
Filed as: wiki/comparisons/attention-single-vs-multi.md
Index updated: Yes
## [2026-04-20] lint | routine health check (47 pages, 12 sources)
Issues: 2 orphans linked, 1 contradiction flagged, 0 broken links
Actions: Applied all fixesUnix parsing tips
# Last 5 entries
grep "^## \[" log.md | tail -5
# All ingests
grep "^## .*ingest" log.md
# All flagged issues
grep "Flags: ⚠️" log.md -A1
# Count operations by type
grep "^## \[" log.md | grep -o "ingest\|query\|lint" | sort | uniq -c9. Schema Co-evolution — CLAUDE.md Lifecycle
9Schema evolution lifecycle
Signs schema needs update
Tổng kết Wrap
Architecture của LLM Wiki đơn giản đến mức có thể viết trên một tờ giấy: 3 folders, 2 special files, 3 operations, 1 schema file. Nhưng đằng sau sự đơn giản đó là những design decisions rất careful: immutable sources, LLM-owned wiki, co-evolved schema.
Bắt đầu với Tầng 1 Minimal Viable. Chạy 5 ingests. Chạy 1 lint. Đọc CLAUDE.md lại và update. Lặp lại. Schema tốt hơn sau mỗi cycle.