Domain Literature RAG & Multi-Agent Editorial / Handout Automation Pipeline
An on-premise RAG and multi-agent pipeline unifying photography literature retrieval, optical diagram synthesis, and A4 print handout production
Domain Literature RAG & Multi-Agent Editorial / Handout Automation Pipeline
This project is a literature-grounded RAG (Retrieval-Augmented Generation) and multi-agent automation pipeline engineered to produce technical photography science columns, optical diagrams, and classroom print handouts with zero hallucinated formulas or tonal drift.
Single-prompt usage of general-purpose LLMs routinely fails on specialized photographic science—fabricating chemical ratios in sensitometry, misstating Zone System density relationships, or muddling optical aberration physics. Equally, a single text output cannot satisfy the distinct layout and diagram constraints required across long-form web articles, square social carousels, and A4/A5 classroom handouts.
Centered on a locally indexed corpus of vetted photography literature, this pipeline orchestrates a role-separated Directed Acyclic Graph (DAG) across planning, style-guided drafting, atomic diagram assembly, and reverse fact-checking, feeding directly into Satori and W3C Paged Media print typesetting.
1. Problem Statement & Engineering Bottlenecks
Three recurring technical bottlenecks limited scalable educational publishing:
- Domain Hallucination Risk: Beyond basic exposure concepts, general LLMs frequently introduced statistical errors in reciprocity failure formulas, MTF chart interpretation, and darkroom developer chemistry.
- Flat AI Prose & Voice Mismatch: Standard instruction-tuned models default to repetitive boilerplate phrasing, failing to capture the cadence of an experienced educator balancing academic precision with studio practice.
- Cross-Medium Layout Fragmentation: Re-authoring the same curriculum unit for long-form web reading, 1:1 social cards, and 300 DPI A4/A5 print handouts imposed heavy manual re-layout overhead.
2. Literature RAG & Knowledge Indexing Architecture
To enforce factual rigor, a curated corpus spanning classical photography science textbooks through modern digital optics papers is structured and indexed in a local vector store.
[Source Corpus] ──> [Hierarchical Chunking (512 tok)] ──> [BGE-M3 Embeddings] ──> [Local ChromaDB]
│
[Query Analyzer] ──> [Keyword & Intent Extraction] ───> [Hybrid Reranking] ──────────────┘
- Hierarchical Semantic Chunking: Rather than naive character slicing, a 512-token sliding window preserves heading hierarchy (
H1/H2/H3) and paragraph boundaries. Optical equations and tables retain intact Markdown structure so retrieval never severs formula context. - Dense + Sparse Hybrid Retrieval: BM25 sparse matching captures exact domain terms (e.g., focal length, depth of field, subtractive color synthesis) while dense BGE-M3 embeddings resolve conceptual queries.
- Authority-Tier Metadata Weighting: Sources carry explicit reliability tiers (Class A: standard academic texts, Class B: technical manuals, Class C: editorial essays), biasing retrieval toward authoritative references first.
3. Multi-Agent Orchestration DAG
To prevent context contamination common in monolithic prompts, each editorial stage runs as a single-responsibility agent node in a controlled DAG:
+──────────────────────────────────────────────────────────────────────────────+
| Multi-Agent Orchestration DAG |
+──────────────────────────────────────────────────────────────────────────────+
[Stage 1: Planning & Retrieval]
│ - Outline topic structure & technical learning objectives
│ - Retrieve Top-K mandatory literature citations from ChromaDB
▼
[Stage 2: Style-RAG Drafting]
│ - Synchronize pacing & paragraph rhythm from curated essay corpus
│ - Draft content grounded strictly in retrieved literature packets
▼
[Stage 3: Atomic Diagram Assembly]
│ - Map optical concepts to the 143-asset atomic SVG library
│ - Bind 3-Zone diagram labels & numeric parameters dynamically
▼
[Stage 4: Fact Verification & Self-Correction]
│ - Cross-check all numeric values & formulas back against sources
│ - On threshold failure, return structured critique to Stage 2
▼
[Stage 5: Multi-Channel Rendering & Print Export]
1) Planning & Retrieval Agent
Given a topic (e.g., "Scheimpflug principle in large-format camera movements"), this stage generates a structured outline and compiles a per-section context packet of verified equations and physical laws from ChromaDB.
2) Style-RAG Drafting Agent
To preserve authentic instructional prose, the drafter pairs factual citations with stylistic exemplars retrieved from curated past columns—maintaining consistent problem framing, practical set analogies, and clear conceptual synthesis.
3) Atomic SVG Mapping Agent
This node queries the 143-asset standardized optical and lighting SVG library to match each section with the right ray diagram, lighting plan, or shutter-curtain timing plate, injecting live numeric annotations programmatically.
4) Fact Audit & Self-Correction Loop
Every numerical claim (f-stops, shutter speeds, chemical dilutions) and quoted principle is verified backward against source chunks. Any discrepancy triggers a structured audit report routed back to Stage 2 for automated revision before rendering proceeds.
4. Multimodal Synthesis & On-Device Vision Privacy
Once prose and citations pass verification, the rendering subsystem assembles channel-ready visual assets:
- Satori Dynamic SVG Engine: Using JSX/CSS layout rules via Satori, the pipeline synthesizes 3-Zone instructional diagrams optimized for both light and darkroom themes.
- On-Device YuNet Portrait Privacy: Whenever practice photographs contain identifiable people, a lightweight local YuNet neural network runs on local NPU hardware without cloud vision calls, detecting face landmarks and applying Gaussian blur automatically to protect portrait rights.
- Playwright Rasterization Pipeline: Responsive long-form web graphics and 1:1 social carousel cards are rendered with verified subpixel typography and exported as lossless web assets.
5. A4/A5 Paged Media Print CSS Automation
To turn digital manuscripts directly into physical classroom handouts, the pipeline embeds a W3C Paged Media print stylesheet:
- Page-Break Guards (
break-inside: avoid): Prevents tables, code listings, and optical diagrams from splitting awkwardly across physical page boundaries. - Hairline Print Grid: Applies crisp 1px rules and 300 DPI-calibrated font metrics tuned against ink spread on standard office and commercial press stocks.
- Single Source of Truth: One verified Markdown manuscript renders simultaneously into a web article, social carousel, and print-ready PDF with zero content drift.
6. Engineering Outcomes
- 99% Fact-Verification Pass Rate: Literature-grounded retrieval combined with reverse-citation auditing virtually eliminated optical formula and numeric hallucinations.
- 85% Production Lead-Time Reduction: Compressed an average 6-hour workflow—research, drafting, diagramming, and print layout—into an ~20-minute agent-assisted review cycle.
- Complete Data Privacy: Local vector indexing and on-device portrait blurring ensure no unpublished instructional material or student workshop imagery ever traverses external networks.
Related Build Logs & Articles
0 postsDetailed English build logs for this project will be published sequentially.
Explore Journal →