# Multimodal Personal Knowledge Base & Obsidian

> A knowledge base for my own accumulated material — two generations of it: searchable, traceable, and connected to Obsidian.

- Period: 2025.12—2026.01
- Status: Frozen
- Type: Original work by the author
- Tags: Multimodal parsing, Hybrid retrieval, RAG, Obsidian
- Code: https://github.com/baifan11/multimodal-knowledge-base
- Cover: https://me.ai-clover.com/covers/cover-knowledge-base.webp
- Original: https://me.ai-clover.com/en/projects/knowledge-base/

My own material is a mess: PDFs, Word documents, slide decks, screenshots, and scans, and finding anything relied on memory. This project is a knowledge base I built for myself, local-first: the material stays on my own machine, parsing, retrieval, and Q&A run in a local service, and Obsidian — which I write in day to day — is connected too, so things I find can be settled back into it. What follows describes the second generation; the first is accounted for at the end.

## Parsing: turn material into something searchable first

More than 9 formats are supported. Parsing isn't a uniform plain-text extraction: slide decks first get layout recognition and go through a "PPT-first mode" — snapshotted page by page, then semantically chunked; tables inside PDFs and Excel files are recognized and handled separately; scans go through RapidOCR with automatic repair; images and charts are visually vectorized with Qwen-VL-Embedding, so they can be retrieved purely by visual semantics. Chunking keeps heading context, page references, and an AI visual summary, so a retrieval result can point back to "which document, which page, which image".

## Retrieval: three-way recall, then fusion

A query first passes through HyDE / intent rewriting, then three ways run in parallel: one is Postgres full-text search (keywords), one is BGE-M3 text vectors (semantics, stored in pgvector), and one is Qwen vision vectors (visual features). The three result sets are rank-fused with RRF, then fine-ranked with the DashScope Reranker, taking the Top-10 chunks by default to feed the model. The reason for three ways is direct: my material contains a lot of slide decks and scans — with text vectors alone, half of it simply never gets recalled.

## Agent research: more than Q&A

The Q&A layer is a LangGraph-based Agent, with nodes divided up as Router, Planner, Executor, Observer, Reflector, and Synthesizer. Simple questions go straight to retrieval via the Router; complex ones are planned first and executed in multiple steps, with tools able to choose between the local knowledge base and web search; the Observer checks whether the results are enough, the Reflector judges whether to search more or re-plan — at most 5 reflection iterations — and finally the Synthesizer composes an answer with sources. The interface has a Chat mode (a single hybrid retrieval, for looking up facts) and an Agent mode (Auto / Fast / Deep tiers, Deep being the deep-research setup above); the process streams, the chain of thought is visible, it can be interrupted at any time, and a dropped connection reconnects.

## Interface and management

- **Asset preview**: images or deck snapshots in the retrieval results can be clicked open full-screen to view the original image — no digging out the source file just to confirm one picture.
- **Obsidian sync**: research reports sync automatically into the Obsidian vault, with Dataview metadata and `[!abstract]` visual summaries, so they can be filtered by metadata right inside the notes.
- **Model management console**: providers such as DashScope, OpenAI, and Ollama are managed centrally and hot-switched; API keys and model parameters edited in the interface take effect immediately, without restarting the backend.
- **Usage statistics**: an Analytics dashboard records token consumption, latency, and cost by model and by session — even for my own use, I want to know where the money goes.

Stack: backend FastAPI + LangGraph + SQLAlchemy + Alembic; frontend React 18 + Vite + Tailwind CSS; database PostgreSQL + pgvector; models are Qwen-Max / Plus / VL-Max, text embeddings BGE-M3, vision embeddings Qwen-VL-Embedding, and reranking by the DashScope Reranker.

## Two generations and boundaries

It went through two generations: the first, kb_system, got the pipeline working; the second, v2.1, filled in parsing, retrieval, the Agent, and the interface, with a project summary and a PRD cross-check record. The summary contains a 95% self-assessment figure — my own measurement at the time — and I'm not moving that onto the website as a claim. Two things were clearly not done well: semantic merging of tables that span pages, and the vision model's concurrency performance — neither had been resolved by freeze time, and they're written here as they are.

## Diagrams

### Main flow

```mermaid
graph TD
  U[User question] --> R{Router}
  R -->|Simple| D[Direct retrieval]
  R -->|Complex| P[Planner]
  P --> E[Executor]
  E -->|Local| L[Local knowledge base]
  E -->|Web| W[Web search]
  L --> O[Observer]
  W --> O
  O --> F{Reflector}
  F -->|Approve| S[Synthesizer]
  F -->|Re-plan| P
  F -->|More search| E
  D --> S
  S --> A[Final answer]
```

### System architecture

```mermaid
graph TD
  Q[User question] --> P[HyDE rewrite]
  P --> S{Three-way retrieval}
  S -->|Keywords| F[Full-text search]
  S -->|Text vectors| V[Text vector search]
  S -->|Visual vectors| VL[Visual vector search]
  F --> R[RRF fusion]
  V --> R
  VL --> R
  R --> RK[Rerank]
  RK --> C[Top-10 context]
  C --> A[Agent generation]
```
