C.W.K.
Stream
Lesson 02 of 10 · published

RAG는 마법풀이 아니야

~22 min · context, rag, retrieval

Level 0수련생
0 XP0/100 lessons0/14 achievements
0/120 XP to next level120 XP to go0% complete

RAG는 일단 search 문제

RAG는 종종 "모델이 너의 데이터 읽을 수 있어"로 묘사돼서 마법처럼 들려. LLM 위에 search 문제를 bolt on한 거야: relevant chunk retrieve, 프롬프트에 패킹, 모델한테 그 chunk만 써서 답하라고 요청. retrieval이 쓰레기 가져오면 모델이 citation 박힌 잘 쓰인 쓰레기를 만들어. bottleneck은 거의 항상 retrieval quality, LLM 아니야.

다섯 조각

  1. Chunking — 문서 어떻게 split.
  2. Embedding — chunk가 vector 되는 법.
  3. Index — vector 사는 곳 (FAISS, Chroma, Postgres pgvector, dedicated DB).
  4. Retrieval — query → top-K chunk. 종종 hybrid (dense + BM25).
  5. Synthesis — chunk를 답으로 바꾸는 LLM call.

대부분 RAG 시스템이 실패하는 곳

  • Chunk가 너무 큼 (LLM이 답 받지만 chunk가 무관 content로 가득).
  • Chunk가 너무 작음 (retrieval이 둘러싼 argument 놓치는 keyword match).
  • Top-K가 무작정 (default 5, 가끔 50이 도움, 가끔 1이 정답).
  • 초기 retrieval 후 reranking 없음.
  • Synthesis 프롬프트가 제공된 chunk만 citation 강요 안 함.

tuning 전에 진단

output 틀리면 체크: 맞는 chunk가 retrieve됐나? Yes면 synthesis 프롬프트 fix. No면 retrieval fix. retrieval 깨진 채로 LLM call tuning은 낭비.

Code

grounded 답 강요하는 synthesis 프롬프트·markdown
# System
Answer the user's question using only the chunks in <context>.
For each factual claim, cite the chunk id in square brackets, e.g. [chunk-7].
If no chunk supports the claim, prepend "Unverified:" to that sentence.
If the question cannot be answered from <context>, return:
  {"status": "insufficient_context", "missing": ["<topic>", ...]}

# User
Question: {{question}}

<context>
[chunk-1] ...
[chunk-2] ...
...
</context>

External links

Exercise

access 있는 RAG pipeline에서 log: (1) 각 query에 retrieve된 chunk, (2) response에서 실제 cite된 chunk. 맞는 chunk가 retrieve됐는데 무시된 query 하나, 잘못된 chunk가 retrieve된 query 하나 찾아.

Progress

Progress is local-only — sign in to sync across devices.
이 페이지에서 버그를 발견하셨거나 피드백이 있으세요?문제 신고

댓글 0

🔔 답글 알림 (로그인 필요)
로그인댓글을 남기려면 로그인해 주세요.

아직 댓글이 없어요. 첫 댓글을 남겨보세요.