prj_rga Project
prj_rga is a project that experiments with a Retrieval-Generation-Augmentation pipeline, going beyond standard RAG. It ran through April 2025 across 5 commits.
RAG vs RGA
graph TD
subgraph RAG["기존 RAG"]
A1[Retrieve] --> B1[Augment] --> C1[Generate]
end
subgraph RGA["RGA"]
A2[Retrieve] --> B2[Generate 초안]
B2 --> C2[Augment 보강]
C2 --> D2{품질 검증}
D2 -->|부족| A2
D2 -->|충분| E2[최종 출력]
end
Core Idea
- Retrieve: Search for relevant documents
- Generate: Produce a draft from the retrieved results
- Augment: Fill gaps in the draft with additional retrieval
- Iterate: Repeat until quality is sufficient
Implementation
def rga_pipeline(query: str, max_iterations: int = 3):
for i in range(max_iterations):
# Retrieve
docs = retriever.get_relevant_documents(query)
# Generate
draft = llm.invoke(
f"문서: {docs}\n질문: {query}\n초안을 작성하세요."
)
# Augment - 부족한 부분 파악
gaps = llm.invoke(
f"초안: {draft}\n부족한 정보를 파악하세요."
)
if "충분함" in gaps:
return draft
# 부족한 부분으로 추가 검색
query = gaps
return draft
A small experiment spanning just 5 commits, but it validated the potential of an iterative retrieve-generate loop.