Understanding the RAG Algorithm
What is RAG?
RAG (Retrieval-Augmented Generation) is a technology where AI first retrieves relevant documents and then generates an answer based on that content.
In simple terms, it's like AI taking an "open-book exam." Instead of answering purely from memorized knowledge, it looks up relevant material first and then answers.
사용자 질문
│
▼
① 검색 (Retrieval)
"질문과 관련된 문서 조각을 찾아라"
│
▼
② 컨텍스트 구성
검색된 문서 조각들을 LLM에게 전달
│
▼
③ 생성 (Generation)
LLM이 문서를 참고하여 답변 생성
│
▼
답변 (출처 포함)
PlantPulse RAG Pipeline
Step 1: Document Indexing (Preparation)
This is the process of converting documents into a form AI can search.
원본 문서 (PDF · DOCX · PPTX · XLSX · MD · TXT)
│
▼
┌─────────────────────────┐
│ Docling 파서 │
│ 문서 → 텍스트 + 이미지 │
│ + 테이블 구조 추출 │
└────────────┬────────────┘
│
▼
┌─────────────────────────┐
│ 청킹 (Chunking) │
│ 긴 문서를 제목·문단 단위로│
│ 적절한 크기로 분할 │
└────────────┬────────────┘
│
▼
┌─────────────────────────┐
│ 임베딩 (Embedding) │
│ 텍스트 → 2560차원 벡터 │
│ 의미를 숫자 배열로 변환 │
└────────┬────────┬───────┘
│ │
▼ ▼
┌────────┐ ┌────────┐
│ Qdrant │ │ Neo4j │
│ 벡터DB │ │ 그래프 │
└────────┘ └────────┘
What Is Chunking?
Searching a 10-page manual as a whole is inefficient. Splitting it into appropriately sized pieces lets you find exactly the right part.
[원본 문서: 10페이지 매뉴얼]
↓ 청킹
[청크 1] 1장 개요 (제목 아래 문단들을 묶음)
[청크 2] 2장 점검 절차
[청크 3] 2장 표 · 그림 설명
...
| Document | Splitting Method |
|---|---|
| PDF · DOCX · PPTX · XLSX | Grouped along headings and paragraphs (target of about 2,000 tokens per chunk). Tables, figures, and formulas are extracted separately, and Aura attaches captions to figures |
| MD · TXT | Split into 1,200-token units, with 100-token overlap so context isn't cut off at the boundary |
Since PlantPulse installations don't separately specify chunk size, the engine defaults are used as-is.
What Is Embedding?
It converts the meaning of text into an array of numbers (a vector). Sentences with similar meaning are located close together in vector space.
"펌프 베어링 교체 방법" → [0.12, -0.34, 0.56, ..., 0.78] (2560차원)
"펌프 축수 정비 절차" → [0.11, -0.33, 0.55, ..., 0.77] ← 비슷한 벡터!
"오늘 날씨가 좋다" → [0.89, 0.23, -0.67, ..., 0.12] ← 다른 벡터
Step 2: Retrieval
When a user question comes in, relevant document chunks are found. PlantPulse's RAG engine (LightRAG) uses both vector search and a knowledge graph together.
Vector Search (Meaning-Based)
The question is vectorized using the same embedding model, and the closest matches in vector space are found.
질문: "주입기 베어링 교체 주기는?"
│
▼ 임베딩
질문 벡터: [0.13, -0.35, 0.54, ...]
│
▼ 코사인 유사도 계산
문서 청크 A (점수 0.92): "주입기 베어링은 6개월마다 교체..." ← 선택!
문서 청크 B (점수 0.85): "펌프 축수 정비 시 베어링 점검..." ← 선택!
문서 청크 C (점수 0.31): "작업장 안전 수칙..." ← 제외
Advantage: It understands semantic similarity, such as "replacement cycle" = "maintenance interval."
Knowledge Graph Search (Entities · Relationships)
It follows the entities (equipment, parts, procedures, etc.) extracted during indexing and the relationships between them.
질문: "주입기 베어링 교체 주기는?"
│
▼ 질문에서 키워드 추출
세부 키워드: ["주입기", "베어링"] → 엔티티 쪽 (local)
상위 키워드: ["정비 주기", "교체"] → 관계 쪽 (global)
│
▼ 그래프 탐색
주입기 ─(구성품)─▶ 베어링 ─(정비)─▶ 6개월 교체 절차
│
▼ 연결된 문서 조각을 모음
Advantage: It can find relationships scattered across multiple documents, even content not written entirely in a single document.
Older documentation described the default mode as "Dense + Sparse (BM25) combined," but the engine in use has no sparse (keyword) index like BM25. Names that need exact matching, such as equipment IDs, are handled by being extracted as entities and entered into the graph.
Hybrid Search (PlantPulse Default Mode)
hybrid combines local (entity-centered) + global (relationship-centered), and is the default mode for the RAG gateway and chat tools. It looks at both equipment/part names (entities) and "what affects what" (relationships) together.
Step 3: Reranking
The reranker model (aura-reranker-0.6b) is running on the stack, but it is not connected to the document search engine in the 2026.09 release (left disabled pending validation). Search results pass straight to answer generation in the same order produced by Step 2 above.
When the reranker is enabled, it re-compares the initial search results as question–document pairs and re-ranks them by relevance. This step catches subtle relevance that was missed during the search stage.
Step 4: Generation
The retrieved document chunks are passed to the LLM as context to generate an answer.
[시스템 프롬프트]
아래 문서를 참고하여 질문에 답하세요.
[검색된 문서]
문서 1: "주입기 베어링은 6개월마다 교체하며..."
문서 2: "교체 시 SKF 6205-2RS 규격을 사용..."
[사용자 질문]
주입기 베어링 교체 주기와 규격을 알려줘.
↓ LLM 생성
[답변]
주입기 베어링 교체 주기는 6개월이며, SKF 6205-2RS 규격을 사용합니다.
(출처: 정비 매뉴얼 3장)
Comparing the 4 Search Modes
| Mode | How It Works | Suitable Situations |
|---|---|---|
| hybrid | local + global (entities and relationships in the graph together) | General document search (default, recommended) |
| naive | Vector similarity of document chunks only — graph not used | Conceptual questions ("What is OEE?") |
| local | Centered on entities appearing in the question | Checking details of a specific piece of equipment or part |
| global | Centered on relationships between entities | Comprehensive information spanning multiple documents |
The engine also has other modes (such as mix), but PlantPulse's RAG gateway only accepts the four above.
Knowledge Graph RAG (Graph RAG)
Besides vector search, PlantPulse RAG also supports search using a Neo4j knowledge graph.
문서 인덱싱 시:
텍스트 → 엔티티 추출 → 관계 추출 → Neo4j 그래프 저장
검색 시 (local · global · hybrid 모드):
질문 → 관련 엔티티·관계 → 그래프 탐색 → 연결된 문서 청크
Advantage: Enables relationship-based search such as "all maintenance manuals related to the injector."
For each document chunk, Aura extracts entities and relationships. A single chunk can take several minutes, and if a chunk doesn't finish within the time limit, the entire document is left in a failed state → Troubleshooting