llm_wiki README

项目的 README,来自 github.com/nashsu/llm_wiki。合并为一个 markdown 文件:README.md。

LLM Wiki

LLM Wiki Logo

A personal knowledge base that builds itself.
LLM reads your documents, builds a structured wiki, and keeps it current.

What is this? • Features • Tech Stack • Installation • Credits • License

English | 中文 | 日本語 | 한국어


Overview

Features

What is this?

LLM Wiki is a cross-platform desktop application that turns your documents into an organized, interlinked knowledge base — automatically. Instead of traditional RAG (retrieve-and-answer from scratch every time), the LLM incrementally builds and maintains a persistent wiki from your sources. Knowledge is compiled once and kept current, not re-derived on every query.

This project is based on Karpathy's LLM Wiki pattern — a methodology for building personal knowledge bases using LLMs. llm_wiki is created and maintained by nash_su, who implemented the core ideas as a full desktop application with significant enhancements.

LLM Wiki Architecture

Credits

The foundational methodology comes from Andrej Karpathy's llm-wiki.md, which describes the pattern of using LLMs to incrementally build and maintain a personal wiki. The original document is an abstract design pattern; this project is a concrete implementation with substantial extensions.

What We Kept from the Original

The core architecture follows Karpathy's design faithfully:

Obsidian Compatibility

What We Changed & Added

1. From CLI to Desktop Application

The original is an abstract pattern document designed to be copy-pasted to an LLM agent. We built it into a full cross-platform desktop application with:

2. Purpose.md — The Wiki's Soul

The original has Schema (how the wiki works) but no formal place for why the wiki exists. We added purpose.md:

3. Two-Step Chain-of-Thought Ingest

The original describes a single-step ingest where the LLM reads and writes simultaneously. We split it into two sequential LLM calls for significantly better quality:

Step 1 (Analysis): LLM reads source → structured analysis
  - Key entities, concepts, arguments
  - Connections to existing wiki content
  - Contradictions & tensions with existing knowledge
  - Recommendations for wiki structure

Step 2 (Generation): LLM takes analysis → generates wiki files
  - Source summary with frontmatter (type, title, sources[])
  - Entity pages, concept pages with cross-references
  - Updated index.md, log.md, overview.md
  - Review items for human judgment
  - Search queries for Deep Research

Additional ingest enhancements beyond the original:

4. Knowledge Graph with Relevance Model

Knowledge Graph

The original mentions [[wikilinks]] for cross-references but has no graph analysis. We built a full knowledge graph visualization and relevance engine:

4-Signal Relevance Model:

Signal Weight Description
Direct link ×3.0 Pages linked via [[wikilinks]]
Source overlap ×4.0 Pages sharing the same raw source (via frontmatter sources[])
Adamic-Adar ×1.5 Pages sharing common neighbors (weighted by neighbor degree)
Type affinity ×1.0 Bonus for same page type (entity↔entity, concept↔concept)

Graph Visualization (sigma.js + graphology + ForceAtlas2):

5. Louvain Community Detection

Not in the original. Automatic discovery of knowledge clusters using the Louvain algorithm (graphology-communities-louvain):

Louvain Community Detection

6. Graph Insights — Surprising Connections & Knowledge Gaps

Not in the original. The system automatically analyzes graph structure to surface actionable insights:

Surprising Connections:

Knowledge Gaps:

Interactive:

Graph Insights

7. Optimized Query Retrieval Pipeline

The original describes a simple query where the LLM reads relevant pages. We built a multi-phase retrieval pipeline with optional vector search and budget control:

Phase 1: Tokenized Search
  - English: word splitting + stop word removal
  - Chinese: CJK bigram tokenization (每个 → [每个, 个…])
  - Title match bonus (+10 score)
  - Searches both wiki/ and raw/sources/

Phase 1.5: Vector Semantic Search (optional)
  - Embedding via any OpenAI-compatible /v1/embeddings endpoint
  - Stored in LanceDB (Rust backend) for fast ANN retrieval
  - Cosine similarity finds semantically related pages even without keyword overlap
  - Results merged into search: boosts existing matches + adds new discoveries

Phase 2: Graph Expansion
  - Top search results used as seed nodes
  - 4-signal relevance model finds related pages
  - 2-hop traversal with decay for deeper connections

Phase 3: Budget Control
  - Configurable context window: 4K → 1M tokens
  - Proportional allocation: 60% wiki pages, 20% chat history, 5% index, 15% system
  - Pages prioritized by combined search + graph relevance score

Phase 4: Context Assembly
  - Numbered pages with full content (not just summaries)
  - System prompt includes: purpose.md, language rules, citation format, index.md
  - LLM instructed to cite pages by number: [1], [2], etc.

Vector Search is fully optional — disabled by default, enabled in Settings with independent endpoint, API key, and model configuration. When disabled, the pipeline falls back to tokenized search + graph expansion. Benchmark: overall recall improved from 58.2% to 71.4% with vector search enabled.

8. Multi-Conversation Chat with Persistence

The original has a single query interface. We built full multi-conversation support:

9. Rust Backend Chat Agent & Skills

Not in the original. Chat now runs through a Rust backend Agent runtime rather than a browser-only TypeScript loop:

10. Thinking / Reasoning Display

Not in the original. For LLMs that emit <think> blocks (DeepSeek, QwQ, etc.):

11. Markdown Rendering: KaTeX Math & Mermaid Diagrams

Not in the original. Rich Markdown rendering across chat and preview:

12. Review System (Async Human-in-the-Loop)

The original suggests staying involved during ingest. We added an asynchronous review queue:

13. Deep Research

Deep Research

Not in the original. When the LLM identifies knowledge gaps:

14. Browser Extension (Web Clipper)

Chrome Extension Web Clipper

The original mentions Obsidian Web Clipper. We built a dedicated Chrome Extension (Manifest V3):

15. Multi-format Document Support

The original focuses on text/markdown. We support structured extraction preserving document semantics:

Format Method
PDF Built-in pdf-extract (Rust) with file caching; optional MinerU Cloud, Local API, or Pipeline parsing for complex layouts
DOCX docx-rs — headings, bold/italic, lists, tables → structured Markdown
PPTX ZIP + XML — slide-by-slide extraction with heading/list structure
XLSX/XLS/ODS calamine — proper cell types, multi-sheet support, Markdown tables
EPUB/MOBI Electronic book metadata, chapters, and body text → ingest-ready content
Images Native preview (png, jpg, gif, webp, svg, etc.)
Video/Audio Built-in player
Web clips Readability.js + Turndown.js → clean Markdown

MinerU is optional. Use MinerU Cloud, an official Local API endpoint, or Local Pipeline mode for complex PDFs. Local modes keep processing on your machine, and extracted images are stored in the project-managed wiki/media directory. If MinerU fails, LLM Wiki falls back to the built-in parser.

16. File Deletion with Cascade Cleanup

The original has no deletion mechanism. We added intelligent cascade deletion:

17. Configurable Context Window

Not in the original. Users can configure how much context the LLM receives:

18. Cross-Platform Compatibility

The original is platform-agnostic (abstract pattern). We handle concrete cross-platform concerns:

19. Other Additions

Tech Stack

Layer Technology
Desktop Tauri v2 (Rust backend)
Frontend React 19 + TypeScript + Vite
UI shadcn/ui + Tailwind CSS v4
Editor Milkdown (ProseMirror-based WYSIWYG)
Graph sigma.js + graphology + ForceAtlas2
Search Tokenized search + graph relevance + optional vector (LanceDB)
Vector DB LanceDB (Rust, embedded, optional)
Documents pdf-extract + MinerU Cloud/Local + docx-rs + calamine + EPUB/MOBI extraction
i18n react-i18next
State Zustand
LLM Streaming fetch (OpenAI, Anthropic, Google, Ollama, Custom)
Web Search Tavily, SerpApi, SearXNG JSON API

Installation

Pre-built Binaries

Download from Releases:

Build from Source

# Prerequisites: Node.js 20+, Rust 1.88+, protoc
#   macOS:  brew install protobuf
#   Linux:  sudo apt install protobuf-compiler
#   Windows: choco install protoc
git clone https://github.com/nashsu/llm_wiki.git
cd llm_wiki
npm install
npm --prefix mcp-server ci && npm run mcp:build   # mcp-server/dist is bundled as a Tauri resource
npm run tauri dev      # Development
npm run tauri build    # Production build

Chrome Extension

  1. Open chrome://extensions
  2. Enable "Developer mode"
  3. Click "Load unpacked"
  4. Select the extension/ directory
  5. Clip the current page with Alt+Shift+L (Command+Shift+L on macOS). Customize it at chrome://extensions/shortcuts.

Quick Start

  1. Launch the app → Create a new project (choose a template)
  2. Go to Settings → Configure your LLM provider (API key + model)
  3. Optional: configure Web Search providers and source folder auto-watch in Settings
  4. Go to Sources → Import documents (PDF, DOCX, MD, etc.)
  5. Watch the Activity Panel — LLM automatically builds wiki pages
  6. Use Chat to query your knowledge base
  7. Browse the Knowledge Graph to see connections
  8. Check Review for items needing your attention
  9. Run Lint periodically to maintain wiki health

Local HTTP API + MCP Server + AI Agent Skill

LLM Wiki ships a built-in local HTTP API at http://127.0.0.1:19828 (token-protected, 127.0.0.1-only) so external tools — including AI agents like Claude Code, Codex, or any HTTP-capable script — can query your wiki:

Enable the API, generate a token, and choose whether local unauthenticated access is allowed in Settings → API + MCP.

For MCP-compatible clients, LLM Wiki also includes a local MCP server in mcp-server/. After building it with npm run mcp:build, Settings → API + MCP shows a copyable MCP client configuration with the correct local path for your machine. The MCP tools call the same API surface, so agent clients can list projects, read files, export unresolved Review items, run hybrid search, inspect the graph, trigger source rescans, and call the same Rust backend Agent chat endpoint without custom HTTP glue code.

Plug your AI agent in with one command

A ready-made agent skill for LLM Wiki lives in its own repo. Install it into Claude Code / Codex / any skills-compatible runtime:

npx skills add https://github.com/nashsu/llm_wiki_skill.git --skill llm-wiki

After install, the agent can answer prompts like "what does my LLM Wiki say about X", "search my 知识库 for Y", "show the neighborhood of node Z in my wiki graph", and "rescan my wiki sources" by talking to your locally-running app — read-only by default, citing wiki page paths so you can verify in-app.

Project Structure

my-wiki/
├── purpose.md              # Goals, key questions, research scope
├── schema.md               # Wiki structure rules, page types
├── raw/
│   ├── sources/            # Uploaded documents (immutable)
│   └── assets/             # Local images
├── wiki/
│   ├── index.md            # Content catalog
│   ├── log.md              # Operation history
│   ├── overview.md         # Global summary (auto-updated)
│   ├── entities/           # People, organizations, products
│   ├── concepts/           # Theories, methods, techniques
│   ├── sources/            # Source summaries
│   ├── queries/            # Saved chat answers + research
│   ├── synthesis/          # Cross-source analysis
│   └── comparisons/        # Side-by-side comparisons
├── .obsidian/              # Obsidian vault config (auto-generated)
└── .llm-wiki/              # App config, chat history, review items

Star History

Star History Chart

License

This project is licensed under the GNU General Public License v3.0 — see LICENSE for details.

llm_wiki (nashsu/llm_wiki)

正在搜索数据库…

这是什么?LLM Wiki 是一款跨平台桌面应用,能把你的文档变成持久保存、相互链接的知识库。它不像传统 RAG 那样每次都从头推导答案,而是由 LLM 增量地构建并持续更新你所有资料的 Wiki。
这基本上就是另一个 RAG 聊天机器人吗?不是。它不会每次查询都从头检索并重新作答,而是一次性编译出一个持久的 Wiki(包括页面、链接和知识图谱)并保持其更新;基于向量的检索只是可选的附加功能,与图谱搜索和分词搜索配合使用。
我该怎么开始构建我的 Wiki?导入你的资料,包括 PDF、Office 文档、EPUB/MOBI、Org mode、图片、网页剪藏、网址,或整个文件夹。应用的两步摄取流程会读取每份资料,然后自动写入或更新对应的 Wiki 页面。
我需要特定的 LLM 服务商或 API 密钥吗?你可以按项目配置模型,并且可以把对话(Chat)和摄取(Ingest)分别指向不同的服务商,包括任何兼容 OpenAI 的接口(可自定义请求头)。可选的向量搜索同样可以通过 LanceDB 使用任何兼容 OpenAI 的嵌入(embedding)接口。
使用它必须要有语义/向量搜索吗?不需要。向量搜索是可选的,默认关闭;不开启时,系统会退回到分词搜索加图谱扩展。项目自带的基准测试显示,关闭向量搜索后,召回率从 71.4% 降至 58.2%。
我的 Wiki 数据会留在我的电脑上吗?生成的 Wiki 以纯 Markdown 文件保存,与 Obsidian 库兼容。应用还会在 127.0.0.1 上提供仅限本地访问的 HTTP API,用于搜索和技能访问。实际的 LLM 调用则会发往你配置的模型服务商。
它的知识图谱有什么特别之处?页面之间通过一个 4 信号的相关性模型建立链接,包括直接的 wikilink、共同来源重叠、Adamic-Adar 共同邻居以及类型亲和度。图谱使用 sigma.js/graphology 渲染,并借助 Louvain 社区发现算法自动聚类。
我能在 Claude Code 或 Codex 里使用它吗?可以。内置的 MCP 服务器和一个现成的智能体技能,只需一条命令(npx skills add ...)即可安装到 Claude Code 或 Codex 中,让这些智能体获得混合搜索、图谱遍历和资料访问能力。
我能把网页直接保存到我的 Wiki 里吗?可以。有一个 Chrome 网页剪藏插件,一键即可抓取页面,并自动摄取到知识库中。
为什么要做这个?它是基于别人的想法吗?它实现并扩展了 Andrej Karpathy 的 llm-wiki.md 模式,保留了原始资料(Raw Sources)、Wiki、Schema 三层架构,以及 wikilink 和 frontmatter 约定。在此基础上,它增加了完整的桌面 UI、知识图谱、Rust 智能体运行时和持久化摄取队列。
作者
nashsu
大小
39.4 MB
星标
21.7K
时长
7个月
提交 · 90 天