검색과 생성을 결합하면 서비스 구조가 어떻게 달라질까
이 글에서는 RAG 원전 논문인 “Retrieval-Augmented Generation for Knowledge-Intensive NLP Tasks”를 백엔드 개발자 관점에서 읽어봅니다.
RAG를 처음 접하면 보통 “벡터 검색해서 LLM에 넣는 것” 정도로 이해합니다. 틀린 말은 아니지만, 실서비스를 만들기에는 부족합니다. RAG는 단순 기능이 아니라 지식의 저장 위치를 바꾸는 아키텍처입니다.
모델이 내부 파라미터에 가진 지식만 쓰는 것이 아니라, 외부 문서 저장소를 검색해서 답변에 반영합니다. 백엔드 관점에서는 “LLM이 모르는 지식을 어떻게 저장하고, 검색하고, 근거로 연결할 것인가”의 문제입니다.
분석 기준일: 2026-05-12
실습 기준 환경: PostgreSQL, pgvector, embedding model, LLM API
주요 참고자료: RAG Paper, pgvector Docs, OpenAI Evals Docs
핵심 요약
- RAG는 parametric memory와 non-parametric memory를 결합하는 접근이다.
- 백엔드 관점에서 RAG는 문서 저장소, 검색기, 생성기, 평가기의 조합이다.
- RAG의 핵심은 “검색했다”가 아니라 “근거 있는 답변을 안정적으로 제공한다”이다.
- 검색 품질과 생성 품질은 분리해서 평가해야 한다.
- citation, 권한, 최신성, 재색인은 RAG 운영의 핵심 문제다.
1. RAG를 왜 봐야 하는가
LLM은 많은 지식을 알고 있지만, 모든 것을 최신 상태로 알지는 못합니다. 조직 내부 문서, 최신 정책, 제품 매뉴얼, 장애 보고서, 코드베이스 문서는 모델의 학습 데이터에 없을 수 있습니다.
RAG는 이런 문제를 해결하기 위한 대표적인 구조입니다.
# 예시입니다.사용자 질문→ 관련 문서 검색→ 검색된 문서를 context로 구성→ LLM이 context 기반 답변 생성→ 출처와 함께 응답
2. 논문의 문제의식
RAG 논문은 대형 사전학습 모델이 factual knowledge를 파라미터에 저장하지만, 지식을 정확하게 접근하거나 업데이트하거나 출처를 제공하는 데 한계가 있다고 봅니다.
백엔드 관점으로 바꾸면 이렇습니다.
# 예시입니다.모델 내부 지식만으로는- 최신 문서 반영이 어렵다.- 출처 제공이 어렵다.- 조직별 지식 반영이 어렵다.- 잘못된 답변을 추적하기 어렵다.
그래서 외부 지식 저장소가 필요합니다.
3. Parametric Memory와 Non-parametric Memory
| 개념 | 논문 관점 | 백엔드 관점 |
|---|---|---|
| Parametric Memory | 모델 파라미터에 저장된 지식 | LLM 자체가 알고 있는 일반 지식 |
| Non-parametric Memory | 검색 가능한 외부 지식 | 문서 DB, vector index, search engine |
| Retriever | 관련 문서 검색 | embedding search, hybrid search |
| Generator | 답변 생성 | LLM API 또는 자체 모델 |
실무에서는 non-parametric memory가 매우 중요합니다. 문서가 바뀌면 모델을 다시 학습시키는 것이 아니라 index를 갱신할 수 있기 때문입니다.
4. Retriever와 Generator
RAG는 검색기와 생성기의 결합입니다.
# 예시입니다.Retriever:질문과 관련 있는 문서 chunk를 찾는다. Generator:검색된 chunk를 근거로 답변을 생성한다.
둘 중 하나만 좋아서는 충분하지 않습니다. 검색기가 잘못된 문서를 가져오면 generator가 아무리 좋아도 답변이 틀릴 수 있습니다. 반대로 좋은 문서를 가져와도 generator가 근거를 무시하면 품질이 떨어집니다.
5. 백엔드 아키텍처로 해석하기
RAG 서비스를 백엔드 구조로 그리면 다음과 같습니다.
# 예시입니다.Document Source→ Ingestion Worker→ Chunking→ Embedding→ Vector Store→ Retrieval API→ Prompt Builder→ LLM→ Response Validator→ Citation Renderer→ Eval Logger
이 구조에서 중요한 운영 포인트는 다음입니다.
| 레이어 | 운영 질문 |
|---|---|
| Ingestion | 문서 변경을 어떻게 감지할 것인가? |
| Chunking | 검색 품질에 맞는 chunk 크기는? |
| Embedding | 모델 변경 시 재색인할 것인가? |
| Vector Store | metadata filter와 권한을 어떻게 적용할 것인가? |
| Prompt Builder | 검색 결과를 얼마나 넣을 것인가? |
| LLM | 근거 없는 답변을 어떻게 막을 것인가? |
| Eval | 검색 실패와 생성 실패를 어떻게 분리할 것인가? |
6. RAG의 실패 유형
| 실패 유형 | 설명 | 대응 |
|---|---|---|
| Retrieval miss | 관련 문서를 못 찾음 | query rewrite, hybrid search |
| Retrieval noise | 관련 없는 문서가 섞임 | reranking, metadata filter |
| Context overflow | 문서가 너무 많음 | token budget, compression |
| Citation hallucination | 없는 출처를 만듦 | citation은 chunk_id에서만 선택 |
| Permission leak | 권한 없는 문서가 검색됨 | 서버 측 ACL filter |
| Stale index | 오래된 문서로 답변 | reindex trigger, versioning |
RAG에서 가장 위험한 것은 답변이 그럴듯하지만 근거가 틀린 경우입니다.
7. 검색 품질과 답변 품질 평가
RAG 평가는 두 단계로 나눠야 합니다.
| 평가 | 질문 |
|---|---|
| Retrieval Quality | 정답 문서가 검색 결과에 들어왔는가? |
| Answer Quality | 검색된 근거를 바탕으로 올바르게 답했는가? |
예시 지표:
# 예시입니다.retrieval_precision@kretrieval_recall@kanswer_correctnesscitation_accuracygroundedness
검색이 실패했는지, 생성이 실패했는지 분리해야 개선 방향이 보입니다.
8. 실무 적용 체크리스트
# 예시입니다.[ ] 문서 source와 version을 저장하는가?[ ] chunk_id가 citation과 연결되는가?[ ] embedding model 변경 시 재색인 계획이 있는가?[ ] vector search에 metadata filter를 적용하는가?[ ] 사용자 권한이 retrieval 단계에서 강제되는가?[ ] 검색 품질과 답변 품질을 분리해 평가하는가?[ ] stale index를 감지할 수 있는가?[ ] RAG 실패 케이스를 eval dataset으로 축적하는가?
9. Q&A
Q1. RAG는 fine-tuning을 대체하나요?
항상 그렇지는 않습니다. 최신 외부 지식, 조직 내부 문서, 출처 제공이 중요하면 RAG가 유리합니다. 특정 스타일이나 태스크 패턴을 학습시키는 데는 fine-tuning이 더 적합할 수 있습니다.
Q2. vector search만 쓰면 충분한가요?
초기에는 충분할 수 있습니다. 하지만 키워드가 중요한 문서, 숫자, 코드, 고유명사가 많은 경우 hybrid search가 필요할 수 있습니다.
Q3. RAG 품질은 어떻게 올리나요?
검색 쿼리, chunking, embedding, metadata filter, reranking, prompt, eval을 함께 개선해야 합니다. 하나만 바꿔서는 원인을 놓치기 쉽습니다.
10. 참고자료와 불확실성
참고자료
- RAG Paper: https://arxiv.org/abs/2005.11401
- pgvector: https://github.com/pgvector/pgvector
- OpenAI Evals: https://platform.openai.com/docs/guides/evals
불확실성
- RAG 논문의 구조와 현재 프로덕션 RAG 구현은 다를 수 있습니다.
- chunking, embedding, reranking의 최적 조합은 데이터셋마다 다릅니다.
백엔드 적용 예시: RAG 논문 용어를 서비스 구성요소로 바꾸기
논문이 직접 다루는 설명은 parametric memory와 non-parametric memory의 구분입니다.
여기까지가 논문 쪽 설명입니다. 백엔드 서비스로 옮기면 역할 분리가 필요합니다. 모델은 답변을 생성하지만, 문서 저장소와 retriever는 근거를 고르고, API 계층은 권한과 trace를 책임집니다.
| 논문 용어 | 서비스 구성요소 | 운영 질문 |
|---|---|---|
| retriever | 검색 API, vector index | 어떤 문서를 후보로 고를까 |
| generator | LLM 호출 계층 | 검색 결과만 근거로 답하는가 |
| non-parametric memory | 문서 DB와 embedding store | 버전과 권한이 관리되는가 |
| marginalization | 여러 후보 근거 결합 | 충돌하는 근거를 어떻게 다룰까 |
실패 사례는 RAG를 "vector search를 붙인 챗봇"으로만 이해하는 것입니다. 논문 쪽 설명은 검색과 생성을 결합해 지식 출처를 모델 바깥에 둔다는 데 있습니다.
이 글의 서비스 해석은 그 출처를 문서 버전, chunk id, 권한, citation으로 남겨야 한다는 것입니다. 그래야 답변이 틀렸을 때 prompt만 고치는 것이 아니라 검색 후보, chunk 정책, reranker, 평가 데이터 중 어디가 문제인지 나눠 볼 수 있습니다.
이 구분은 운영 회고에서도 필요합니다. 논문에서 말한 구조가 곧바로 특정 DB schema를 정해주지는 않습니다. schema, 권한, trace, eval dataset은 서비스 팀이 책임져야 하는 구현 해석입니다. 그래서 논문 사실과 제품 설계 결정을 같은 문단에서 섞지 않고, 근거와 적용을 따로 적어야 합니다.
How will the service structure change if you combine search and creation?
In this article, we read the RAG original paper “Retrieval-Augmented Generation for Knowledge-Intensive NLP Tasks” from the perspective of a back-end developer.
When people first encounter RAG, they usually understand it as “searching for vectors and putting them into LLM.” It's not wrong, but it's not enough to create an actual service. RAG is not a simple function, but an architecture that changes the storage location of knowledge.
The model not only uses the knowledge it has in internal parameters, but also searches an external document repository and reflects it in the answer. From a back-end perspective, the problem is “how to store, retrieve, and connect to evidence the knowledge that LLM does not know.”
Analysis base date: 2026-05-12 Practice reference environment: PostgreSQL, pgvector, embedding model, LLM API Main reference materials: RAG Paper, pgvector Docs, OpenAI Evals Docs
Key takeaways
- RAG is an approach that combines parametric memory and non-parametric memory.
- From a backend perspective, RAG is a combination of a document repository, searcher, generator, and evaluator.
- The core of RAG is not “I searched,” but “I reliably provide well-founded answers.”
- Search quality and generation quality should be assessed separately.
- Citation, authority, recency, and re-indexing are key issues in RAG operation.
1. Why you should watch RAG
LLMs have a lot of knowledge, but they don't know everything up to date. Your organization's internal documents, latest policies, product manuals, failure reports, and codebase documents may not be in your model's training data.
RAG is a representative structure for solving this problem.
# This is an example.user questionsto Search related documentsto Configure the searched documents into contextto LLM generates context-based answersto Reply with source
2. Critical awareness of the paper
The RAG paper believes that large pre-trained models store factual knowledge in parameters, but have limitations in accurately accessing, updating, or providing sources of knowledge.
If we change it to a backend perspective, it looks like this.
# This is an example.With only knowledge inside the model,- It is difficult to reflect the latest documents.- It is difficult to provide sources.- It is difficult to reflect knowledge by organization.- Difficult to track wrong answers.
So we need an external knowledge repository.
3. Parametric Memory and Non-parametric Memory
| concept | thesis perspective | backend perspective |
|---|---|---|
| Parametric Memory | Knowledge stored in model parameters | General knowledge that LLM itself knows |
| Non-parametric Memory | Searchable External Knowledge | Document DB, vector index, search engine |
| retriever | Search related documents | embedding search, hybrid search |
| Generator | Generate Answer | LLM API or own model |
In practice, non-parametric memory is very important. This is because if the document changes, the index can be updated rather than retraining the model.
4. retriever and Generator
RAG is a combination of a searcher and a generator.
# This is an example.retriever:Find document chunks related to your question. Generator:An answer is generated based on the retrieved chunk.
It is not enough to like just one of the two. If the searcher retrieves the wrong document, the answer may be wrong no matter how good the generator is. Conversely, even if you import a good document, if the generator ignores the evidence, the quality deteriorates.
5. Interpreting with backend architecture
If we draw the RAG service as a backend structure, it looks like this:
# This is an example.Document Source→ Ingestion Worker→ Chunking→ Embedding→ Vector Store→ Retrieval API→ Prompt Builder→ LLM→ Response Validator→ Citation Renderer→ Eval Logger
The important operational points in this structure are:
| layer | operational questions |
|---|---|
| Ingestion | How to detect document changes? |
| Chunking | What chunk size matches your search quality? |
| Embedding | Will you reindex when the model changes? |
| Vector Store | How to apply metadata filters and permissions? |
| Prompt Builder | How many search results will you include? |
| LLM | How do we prevent unfounded answers? |
| Eval | How to separate retrieval failures from creation failures? |
6. Failure types of RAG
| failure type | explanation | react |
|---|---|---|
| Retrieval miss | Couldn't find any related documentation | query rewrite, hybrid search |
| Retrieval noise | Mixed-up unrelated documents | reranking, metadata filter |
| Context overflow | Too many documents | token budget, compression |
| Citation hallucination | Create a source that doesn't exist | Citation is selected only from chunk_id |
| Permission leak | Unauthorized document detected | Server-side ACL filter |
| Stale index | Reply with an old document | reindex trigger, versioning |
The most dangerous thing about RAG is when the answer is plausible but the evidence is wrong.
7. Evaluate search quality and answer quality
RAG evaluation should be divided into two steps.
| evaluation | question |
|---|---|
| Retrieval Quality | Did the correct answer document appear in the search results? |
| Answer Quality | Did you answer correctly based on the searched evidence? |
Example metrics:
# This is an example.retrieval_precision@kretrieval_recall@kanswer_correctnesscitation_accuracygroundedness
Directions for improvement can only be seen by separating whether search or creation failed.
8. Practical application checklist
# This is an example.[ ] Do you save the document source and version?[ ] Is chunk_id connected to citation?[ ] Is there a plan for re-indexing when the embedding model changes?[ ] Is metadata filter applied to vector search?[ ] Are user rights enforced during the retrieval step?[ ] Are search quality and answer quality evaluated separately?[ ] Can the stale index be detected?[ ] Are RAG failure cases accumulated as an eval dataset?
9. Q&A
Q1. Does RAG replace fine-tuning?
This isn't always the case. If providing up-to-date external knowledge, internal organization documentation, and sources is important, RAG is beneficial. Fine-tuning may be more appropriate for learning a specific style or task pattern.
Q2. Is it enough to just use vector search?
This may be sufficient initially. However, if the keyword contains many important documents, numbers, codes, or proper nouns, a hybrid search may be necessary.
Q3. How do I increase RAG quality?
We need to improve search queries, chunking, embedding, metadata filter, reranking, prompt, and eval together. If you only change one thing, it's easy to miss the cause.
10. References and uncertainty
References
- RAG Paper:https://arxiv.org/abs/2005.11401
- pgvector:https://github.com/pgvector/pgvector
- OpenAI Evals:https://platform.openai.com/docs/guides/evals
uncertainty
- The structure of the RAG paper and the current production RAG implementation may differ.
- The optimal combination of chunking, embedding, and reranking varies from dataset to dataset.
Backend application example: Replacing RAG paper terminology with service components
The explanation directly addressed by the paper is the distinction between parametric memory and non-parametric memory.
This is the explanation in the paper. Moving to a backend service requires separation of roles. The model generates the answer, the document store and retriever pick the evidence, and the API layer is responsible for permissions and traces.
| thesis terminology | service component | operational questions |
|---|---|---|
| retriever | Search API, vector index | Which document should I choose as a candidate? |
| generator | LLM Call Hierarchy | Is the answer based only on search results? |
| non-parametric memory | Document DB and embedding store | Are versions and permissions managed? |
| marginalization | Combining multiple candidate grounds | How to deal with conflicting evidence |
A failure case is to understand RAG only as a “chatbot with vector search”. The explanation in the paper is that it combines search and generation to place the knowledge source outside the model.
The service interpretation of this article is that the source must be left as document version, chunk id, authority, and citation. That way, if the answer is wrong, you can not only correct the prompt, but also determine which of the search candidates, chunk policy, reranker, and evaluation data is the problem.
This distinction is also necessary in operational retrospectives. The structure mentioned in the paper does not directly determine a specific DB schema. Schema, permissions, trace, and eval dataset are implementation interpretations for which the service team is responsible. So, rather than mixing thesis facts and product design decisions in the same paragraph, you should write the rationale and application separately.

댓글
GitHub 계정으로 로그인하면 댓글을 남길 수 있습니다. 댓글은 GitHub Discussions를 통해 운영됩니다.