DH2026 · 시작 전 안내Before we begin
Build a Working RAG in Half a Day반나절 만에 만드는 작동하는 RAGA hands-on workshop · UN Policy Reports with LangChain
먼저 이 주소로 접속하세요Start here — open this address
github.com/littlekg87/DH2026
들어가서 Slides 를 찾아, 발표자료를 미리 열어 두세요.Once there, find Slides and open the presentation in advance.
1
구글 계정(Google ID)으로 먼저 로그인해 주세요.Sign in with your Google account first.
2
구글 Colab을 미리 열어 두세요.Open Google Colab in advance.
Build a Working RAG in Half a Day

반나절 만에 만드는
작동하는 RAG
Build a Working RAG
in Half a Day

UN 정책 보고서와 LangChain으로,
답변마다 전거(典據)가 따라붙는 파이프라인을 손으로 짓다
Hand-building a pipeline on UN policy reports with LangChain,
where every answer carries its provenance
공동 연구Co-researchers
정용호Yongho Jung 정수아Sua Chung 박지우Jiwoo Park 김준한Junhan Kim 김주희Juehee Kim 변혜진Hyejin Byun
서강대학교Sogang University
Kunha Kim
서강대학교 · Sogang UniversitySogang University
littlekg87@gmail.com Any Co-work, Welcome!
DH2026 UN SDG Report 2025 LangChain · FAISS · Qwen3 Google Colab
↓ 사이드바 목차를 눌러 원하는 단계로 바로 이동Use the sidebar to jump straight to any step
시작 전 · 자료Before we begin · Resources

GitHub · 참고자료GitHub · resources

모든 코드는 셀 단위로 공개돼 있다. 각 블록은 Colab 셀 하나에 대응한다.All the code is published cell by cell. Each block corresponds to one Colab cell.

코퍼스Corpus
SDG Report 2025
UN Statistics Division · 51쪽UN Statistics Division · 51 pp.
프레임워크Framework
LangChain
인코더Encoder
all-MiniLM-L6-v2
벡터 저장소Vector store
FAISS
LLM
Qwen3-0.6B
런타임Runtime
Colab · T4 GPU

DH2026 · Build a Working RAG in Half a Day · UN Policy Reports with LangChain

기조 · 고백Keynote · A confession

이 답변을 믿으시겠습니까?Would you trust this answer?

AI
Generated answer
“How many people still live in extreme poverty?”

2025년 기준 전 세계 극빈 인구는 약 6억 9,200만 명으로 추산됩니다.1 이는 팬데믹 이전 추세로의 회복이 지연된 결과이며, 사하라 이남 아프리카가 전체의 절반 이상을 차지합니다.2 현재 감소 속도가 유지될 경우 2030년 목표 달성은 어려울 것으로 전망됩니다.3

As of 2025, roughly 692 million people worldwide are estimated to live in extreme poverty.1 This reflects a delayed recovery to pre-pandemic trends, with sub-Saharan Africa accounting for more than half of the total.2 At the current rate of decline, the 2030 target is projected to be out of reach.3

[1]Kim & Park (2023), 「빈곤 통계의 재구성」, 『국제개발연구』 41(2)Kim & Park (2023), “Reconstructing Poverty Statistics,” Journal of International Development Studies 41(2)존재하지 않는 논문no such paper exists
[2]UN SDG Report 2025, Goal 1 §1.4 “지역별 분포”UN SDG Report 2025, Goal 1 §1.4 “Regional distribution”실재하지 않는 절no such section
[3]같은 보고서, pp. 214–216Same report, pp. 214–216문서 범위 밖beyond the document
유려함은 신뢰가 아니다.Fluency is not trustworthiness.
※ 위 답변은 시연을 위해 구성한 예시입니다.※ The answer above is a constructed example, shown for demonstration.
기조 · 응답Keynote · The response

같은 질문, 두 개의 경로One question, two paths

이 불안에 대한 기술적 응답이 RAG다. 2020년 Lewis와 동료들이 이 개념을 본격적으로 제시한The technical response to this unease is RAG. After Lewis and colleagues set out the concept in earnest in 2020,1Retrieval-Augmented Generation for Knowledge-Intensive NLP TasksLewis, Perez, Piktus et al. · NeurIPS 2020검색기(retriever)와 생성기(generator)를 결합한 구조를 제안하고, 모수(parametric) 기억에만 의존하는 모델보다 사실성이 개선됨을 보였다. RAG라는 이름이 자리 잡은 출발점.Proposed an architecture combining a retriever with a generator, and showed improved factuality over models relying on parametric memory alone. The point at which the name RAG took hold.arXiv:2005.11401 이후, RAG는 빠르게 확산해 생성형 AI의 약점을 보완하는 핵심 기술로 자리 잡았다. RAG spread quickly and became a core technique for shoring up the weaknesses of generative AI.2Retrieval-Augmented Generation for Large Language Models: A SurveyGao, Xiong, Gao et al. · arXiv 2023 (rev. 2024)RAG 연구를 Naive → Advanced → Modular 세 세대로 정리한 대표 서베이. 이 계보가 존재한다는 사실 자체가, 초기 RAG의 문제가 모델 성능이 아니라 구조에 있었음을 보여준다.The standard survey, organising RAG research into three generations — Naive → Advanced → Modular. That this lineage exists at all shows the problem with early RAG lay in structure, not model performance.arXiv:2312.10997

질문Question
Query
→
모델의 기억The model's memory
Parametric
→
답변Answer
Answer
출처 없음no source
질문Question
Query
→
R
검색한다Retrieve
Retrieval
→
A
증강한다Augment
Augmented
→
G
생성한다Generate
Generation
→
답변Answer
Answer
Goal 1 · pp. 10–11
그 사이에 무슨 일이 있었는지, 우리는 모른다.What happened in between, we cannot know.
말한 뒤에 근거를 찾지 않는다.
근거를 찾은 뒤에 말한다.
We do not look for grounds after speaking.
We speak after finding the grounds.
기조 · 반전Keynote · The turn

그렇다면 RAG가 다 해결해 주는가So does RAG solve everything?

전혀 그렇지 않다. 오히려 최근 보고되는 연구들은 RAG가 기대만큼 튼튼하지 않다고 말한다.Not at all. Recent studies report the opposite — that RAG is not as robust as we hoped.3Seven Failure Points When Engineering a Retrieval Augmented Generation SystemBarnett, Kurniawan, Thudumu et al. · CAIN 2024연구·교육·생의학 세 분야의 실제 구축 사례에서 실패 지점 일곱 개를 도출했다. 결정적인 것은 그 일곱 개가 모두 모델 가중치가 아니라 파이프라인 단계에 자리한다는 점이다.Derived seven failure points from real deployments across research, education and biomedicine. Decisively, all seven sit in pipeline stages, not model weights.arXiv:2401.05856 · DOI 10.1145/3644815.36449454A Systematic Literature Review of Retrieval-Augmented Generation: Techniques, Metrics, and ChallengesBrown, Roman, Devereux · arXiv 20252020년부터 2025년 5월까지 피인용 상위 128편을 PRISMA 방식으로 검토해, 평가 관행과 방법론의 공백을 정리했다. 가장 최신의 체계적 문헌고찰.A PRISMA review of the 128 most-cited papers from 2020 to May 2025, mapping gaps in evaluation practice and methodology. The most recent systematic review.arXiv:2508.06401 검색을 붙였는데도 환각이 사라지지 않는 사례가 축적되고 있고 Cases keep accumulating where hallucination survives even with retrieval attached,5RAGTruth: A Hallucination Corpus for Developing Trustworthy Retrieval-Augmented Language ModelsNiu, Wu, Zhu et al. · ACL 2024검색해 온 근거와 어긋나거나 근거가 없는 주장을 단어 단위로 주석한 코퍼스. 검색을 붙여도 환각은 살아남는다는 사실을 실증했다.A corpus annotating, word by word, claims that contradict or lack the retrieved evidence. Demonstrated empirically that hallucination survives retrieval.arXiv:2401.00396 · ACL 2024.acl-long.585, 그 원인은 RAG 바깥이 아니라 RAG의 설계 그 자체에 있다. and the cause lies not outside RAG but in the design of RAG itself.

자료SourceSource원천 오염contaminated at source6How Does Data Shape AI Responses?: A Comparative Experiment on RAG Responses Using the Sejong Sillok Jiriji「한문학논집」 74 · 2026 · 발표자 논문Journal of Korean Literature in Chinese 74 · 2026 · by the presenter『세종실록지리지』를 재료로, 투입한 자료를 어떻게 구성하느냐가 RAG의 답변을 어떻게 바꾸는지 비교 실험한 연구. 한국 고전 자료를 다루는 연구자에게 가장 가까운 사례다.A comparative experiment on the Sejong Sillok Jiriji, testing how the way you structure the input data changes RAG's answers. The closest case for researchers working with Korean classical sources.DOI 10.17260/jklc.2026.74..49 · KCI ART003361051
정제CleanClean조판 노이즈typesetting noise
청킹ChunkChunk의미 절단meaning cut apart7Is Semantic Chunking Worth the Computational Cost?Qu, Tu, Bao · Findings of NAACL 2025문서 검색·근거 검색·답변 생성 전반에서 의미 기반 청킹이 치른 계산 비용만큼의 일관된 이득을 주지 못했다. 청킹은 중요하지만, 통념과 다른 방향으로 중요하다.Across document retrieval, evidence retrieval and answer generation, semantic chunking did not deliver gains consistent with its computational cost. Chunking matters — but not in the way received wisdom says.arXiv:2410.13070 · ACL 2025.findings-naacl.114
임베딩EmbedEmbed차원 상한a ceiling on dimensions8On the Theoretical Limitations of Embedding-Based RetrievalWeller, Boratko, Naim, Lee · Google DeepMind, 2025임베딩 차원 d가 표현 가능한 상위 k 문서 조합을 원천적으로 제한함을 학습이론으로 증명하고, 아주 단순한 질의에서도 대부분의 단일 벡터 임베더가 recall@100 20%에 못 미침을 보였다. “더 좋은 임베딩 모델”이 해답이 아니라는 가장 단단한 근거.Proves via learning theory that embedding dimension d fundamentally limits which top-k document combinations are representable, and shows most single-vector embedders fall below 20% recall@100 even on very simple queries. The hardest evidence that “a better embedding model” is not the answer.arXiv:2508.21038
색인IndexIndex구성에 좌우hostage to configuration9Searching for Best Practices in Retrieval-Augmented GenerationWang, Wang, Gao et al. (Fudan Univ.) · EMNLP 2024질의 분류·검색·재순위·재구성·요약 등 각 단계를 하나씩 절제(ablation)하며 조합을 탐색했다. 전형적인 RAG 작업흐름은 여러 방식으로 실행될 수 있고, 그 조합에 따라 성능이 실질적으로 달라진다.Explored combinations by ablating each stage in turn — query classification, retrieval, reranking, repacking, summarisation. A typical RAG workflow can be executed many ways, and performance changes substantially with the combination.arXiv:2407.01219 · ACL 2024.emnlp-main.981
검색RetrieveRetrieve순서 붕괴order collapses10Lost in the Middle: How Language Models Use Long ContextsLiu, Lin, Hewitt et al. · TACL 2024정답 근거가 문맥의 처음이나 끝에 있을 때 정확도가 가장 높고, 중간에 놓이면 급격히 떨어진다. 검색 결과를 어떤 순서로 배열하느냐 하는 파이프라인 결정이 답변을 바꾼다.Accuracy is highest when the supporting evidence sits at the start or end of the context, and drops sharply when it lands in the middle. A pipeline decision — how you order retrieved results — changes the answer.arXiv:2307.03172 · ACL 2024.tacl-1.9
재순위 역효과reranking backfires11Drowning in Documents: Consequences of Scaling Reranker InferenceJacob et al. · ReNeuIR @ SIGIR 2025재순위 모델은 일정 지점까지는 결과를 개선하지만, 더 많은 문서를 채점하게 하면 1차 검색기보다도 성능이 떨어진다. 단일 단계가 품질을 적극적으로 해칠 수 있음을 보여주는 사례.Rerankers improve results up to a point, but when made to score more documents they fall below the first-stage retriever. A case where a single stage actively harms quality.arXiv:2411.11767
생성GenerateGenerate근거 무시evidence ignored12Sufficient Context: A New Lens on Retrieval Augmented Generation SystemsJoren, Zhang, Ferng et al. · ICLR 2025“검색이 근거를 충분히 주지 못한 실패”와 “근거를 받고도 모델이 못 쓴 실패”를 분리해 측정했다. Gemini 1.5 Pro·GPT-4o·Claude 3.5 같은 최상급 모델이 근거가 불충분할 때 기권하지 않고 확신에 차서 틀린다. LLM을 키운다고 검색 실패가 메워지지 않는다는 직접 증거.Separately measures “retrieval failed to supply enough evidence” from “the model had the evidence and still failed to use it.” Top-tier models — Gemini 1.5 Pro, GPT-4o, Claude 3.5 — do not abstain when evidence is insufficient; they are confidently wrong. Direct evidence that scaling the LLM does not paper over retrieval failure.arXiv:2411.06037
일곱 개의 마디. 초기에는 금색으로 표시된 둘만 좋으면 된다고 믿었다.Seven links. Early on we believed only the two marked in gold had to be good.
품질을 결정하는 것은 모델이 아니라,
모델과 모델 사이에 놓인 파이프라인이다.
What determines quality is not the model, but
the pipeline laid between the models.
기조 · 결론Keynote · The conclusion

무엇을 만드는가What we build

① 에서 무너졌던 그 카드를, 근거가 붙은 형태로 다시 세운다.We rebuild the card that collapsed in ①, this time with its grounds attached.

✓
Answer with provenance
“How many people still live in extreme poverty?”

보고서가 제시한 극빈 인구 규모와 감소 추세를 아래 근거 문단에 있는 내용만으로 정리해 답한다.Answers with the report's figures for the extreme-poverty population and its trend, using only what appears in the source passages below.

Sources
✓G01-S01Goal 1 No poverty · pp. 10–11
✓G01-S02Goal 1 No poverty · pp. 10–11
✓G01-S03Goal 1 No poverty · pp. 10–11
※ STEP 10에서 실제로 생성되는 형태입니다. 답변 문장과 수치는 그때 모델이 만듭니다.※ This is the shape actually produced in STEP 10. The sentences and figures are generated by the model at that point.
맡겨 두면Left to itself

전거는 따라오지 않는다Provenance does not follow

인용을 붙이도록 설계된 최신 모델조차 절반 가까운 경우에 근거가 불완전했다.Even recent models designed to attach citations left the grounds incomplete in nearly half of cases.13Enabling Large Language Models to Generate Text with CitationsGao, Yen, Yu, Chen (Princeton NLP) · EMNLP 2023인용 품질을 재는 최초의 벤치마크 ALCE를 제안했다. ELI5 과제에서 최고 성능 모델조차 약 절반의 경우 인용 근거가 온전하지 않았다. 전거는 모델에 맡겨 두면 확보되지 않는다.Proposed ALCE, the first benchmark for citation quality. On the ELI5 task, even the best-performing model had incomplete citation support in roughly half of cases. Provenance is not secured by leaving it to the model.arXiv:2305.14627 · ACL 2023.emnlp-main.398 아카이브 자료에서도 기성 파이프라인만으로는 부족했다. With archival material too, an off-the-shelf pipeline was not enough.14FolkRAG: a retrieval-augmented generation system for cultural heritage materialsKelly, Schild, Jafari · Neural Computing and Applications, 2025미국 의회도서관 American Folklife Center 소장 자료를 대상으로 한 RAG. 파편화된 아카이브 메타데이터 탓에 기성 구성으로는 작동하지 않아 문장 단위 검색·HyDE·재순위·벡터저장소 조정을 모두 거쳐야 했다.
확인 범위: 유료 접근이라 초록 수준까지만 검증함.
A RAG system over holdings of the American Folklife Center at the Library of Congress. Fragmented archival metadata meant an off-the-shelf configuration would not work; sentence-level retrieval, HyDE, reranking and vector-store tuning were all required.
Extent verified: paywalled — checked to abstract level only.
DOI 10.1007/s00521-025-11455-4

그러므로Therefore

전거는 설계해서 얻는다Provenance is obtained by design

메타데이터를 짜고, 청크마다 출처를 붙이고, 검색 결과에 실어 나르고, 답변 끝에 다시 꺼내 놓는다. 그 설계가 오늘 손으로 짓는 것이다.You compose the metadata, attach a source to every chunk, carry it through the retrieval results, and lay it out again at the end of the answer. That design is what we build by hand today.

우리가 만드는 것은 챗봇이 아니라,
출처(典據)를 갖춘 RAG 파이프라인이다.
What we build is not a chatbot, but
a RAG pipeline that carries its provenance.
기조 · 재료와 도구Keynote · Material and tools

무엇으로 만드는가What we build it with

재료 · CorpusMaterial · Corpus
SDG Report 2025
UN Statistics Division · 51쪽 · PDFUN Statistics Division · 51 pp. · PDF
왜 이 문서인가Why this document
  • 가장 널리 알려진 국제 보고서다. 내용을 몰라도 무엇을 묻고 싶은지는 안다.The best-known international report there is. Even without knowing its contents, you know what you want to ask it.
  • 목표·절·쪽이 뚜렷해 구조화가 가능하다. 실습 자료로서 이 점이 결정적이다.Goals, sections and pages are clearly marked, so it can be structured. For a hands-on corpus, that is decisive.
도구 · FrameworkTool · Framework
LangChain
FAISS · all-MiniLM-L6-v2 · Qwen3-0.6B
왜 이 도구인가Why this tool
  • RAG 파이프라인을 가장 간단하게 조립할 수 있는 코드다.It is the code that lets you assemble a RAG pipeline most simply.
  • 단계가 코드로 분리돼 있어 한 마디씩 열어 볼 수 있다. 오늘의 목적에 맞는다.The stages are separated in code, so you can open them one link at a time. That suits today's purpose.
그리고 우리는 일부러 느리게 간다. STEP 2에서는 실패하는 청킹을 먼저 만들어 보고, STEP 8에서는 FAISS가 한 줄로 해 주는 일을 손으로 계산한다.And we go deliberately slowly. In STEP 2 we first build a chunking that fails; in STEP 8 we compute by hand what FAISS does in a single line.

인용에 출처를 달고 검색된 근거 위에서만 진술하는 태도는 인문학이 오래 지켜 온 자료 비판의 규율 그 자체다. 실록이든 관보든 문학 텍스트든 — 다루는 자료는 달라도 규율은 같다. 오늘 하는 일은 그 규율을 기계에 이식하는 작업이다.Citing your sources and asserting only on retrieved grounds is the discipline of source criticism the humanities have long kept. Veritable records, official gazettes, literary texts — the material differs, the discipline does not. What we do today is transplant that discipline into a machine.

도입 · 개념Introduction · The concept

RAG란 무엇인가 — 두 국면의 흐름What RAG is — a flow in two phases

RAG는 성격이 다른 두 국면으로 나뉜다. A. 자료 준비는 한 번만 하는 오프라인 작업이고, B. 질문·검색·답변은 질문할 때마다 반복되는 온라인 작업이다.RAG divides into two phases of different character. A. Preparing the material is offline work done once; B. Question, retrieval, answer is online work repeated with every question.

각 상자를 누르면 해당 단계로 이동합니다 · 청록 상자(FAISS)가 A와 B를 잇는 경첩입니다Click any box to jump to that step · the teal box (FAISS) is the hinge joining A to B
FAISS = 잘 만든 색인(index)FAISS = a well-made index

A의 종착점이자 B의 진입점. 임베딩된 자료를 좌표로 정리해 둔 색인이다. 질문이 들어오면 이 색인을 뒤져 가장 가까운 항목을 찾는다 — 방대한 자료를 매번 처음부터 훑지 않고, 뒤에 붙은 색인으로 곧장 찾아가는 것과 같다.The terminus of A and the entrance to B. An index that arranges the embedded material by coordinates. When a question arrives, it searches this index for the nearest entries — like going straight to the index at the back of a book instead of reading a vast work from the beginning every time.

도입 · 지도Introduction · The map

오늘의 여정 — STEP 1에서 10까지Today's journey — STEP 1 to 10

앞의 A/B 흐름을 열 단계로 해체한다. STEP 1에서 준비를 끝내면, 이후는 네트워크가 끊겨도 돌아간다. ★ 표시가 오늘의 무게중심이다.We take the A/B flow apart into ten steps. Once STEP 1 finishes the preparation, everything after it runs even with the network cut. The ★ mark is today's centre of gravity.

런타임Runtime
Colab · GPU
T4
프레임워크Framework
LangChain
인코더Encoder
all-MiniLM-L6-v2
로컬, API 키 불필요local, no API key
벡터 저장소Vector store
FAISS
IndexFlatL2
LLM
Qwen3-0.6B
로컬, API 키 불필요local, no API key
코퍼스Corpus
SDG Report 2025
UN Statistics Division
도입 · 남는 것Introduction · What remains

끝나고 나면 무엇이 남는가What remains when this is over

반나절 뒤에 손에 쥐고 나가는 것은 셋이다. 각각이 무엇을 뜻하는지가 더 중요하다.Three things go home with you after half a day. What each of them means matters more.

01
RAG 파이프라인을 세부적으로 이해한다.You understand the RAG pipeline in detail.
이는 곧 당신이 직접 RAG 파이프라인을 설계할 수 있는 능력을 갖게 되었다는 뜻이다.Which means you now have the ability to design a RAG pipeline yourself.
02
RAG에서 전거(metadata)를 다는 일이 왜 중요한지 이해한다.You understand why attaching provenance (metadata) matters in RAG.
이는 곧 당신이 RAG의 기술철학을 이해했다는 뜻이다.Which means you have grasped the technical philosophy of RAG.
03
RAG의 성능을 개선하기 위한 조건을 이해한다.You understand the conditions for improving RAG's performance.
이는 곧 RAG의 한계와 가능성을 정확히 깨닫게 된다는 뜻이다.Which means you come to see RAG's limits and its possibilities precisely.
그리고, 남지 않는 것And what does not remain
✗ 훌륭한 코딩 실력Great coding skills 이 워크숍은 코딩 능력을 향상하기 위한 세션이 아니다.This workshop is not a session for improving how well you code.
✗ 완벽하게 작동하는 RAG 검색기A flawless RAG retriever 이 워크숍은 오히려 RAG의 실패 가능성을 더 깊게 탐구한다.If anything, this workshop digs deeper into the ways RAG fails.
01
STEP 1 · Setup & Asset Preparation

환경설정 · 자산준비Setup · asset preparation

시작 전 준비 · 1분Before we start · 1 minute
  1. 공유 Google Drive 폴더를 내 드라이브에 바로가기 추가 (다운로드 아님, 포인터만)Add a shortcut to the shared Google Drive folder in My Drive (not a download — just a pointer) → 구글 드라이브 추가 방법How to add the Google Drive shortcutgithub.com/littlekg87/DH2026/…/Workshop_procedure.md
  2. Colab 런타임을 T4 GPU로 설정 — 생성 모델 Qwen3에 필요Set the Colab runtime to T4 GPU — required by the Qwen3 generation model
모든 라이브러리·모델·데이터를 한 번에 준비한다. 이 단계만 지나면 네트워크가 끊겨도 파이프라인은 끝까지 돌아간다.Prepare every library, model and dataset in one go. Past this step, the pipeline runs to the end even with the network cut.

버전을 고정(pin)해 참가자 20명이 완전히 같은 환경에서 실행하도록 한다. Hugging Face Hub를 오프라인으로 봉인(HF_HUB_OFFLINE)해, 이후 어떤 셀도 몰래 인터넷에 나가지 않도록 못 박는다. 모델은 모두 공유 드라이브에서 로컬로 읽는다.Versions are pinned so all 20 participants run in exactly the same environment. The Hugging Face Hub is sealed offline (HF_HUB_OFFLINE), nailing down that no later cell quietly reaches for the internet. Every model is read locally from the shared Drive.

workshop_code.md1-2
# Hugging Face Hub 봉인 — 모든 자산은 이미 로컬에 있다seal the Hugging Face Hub — every asset is already local
os.environ["HF_HUB_OFFLINE"] = "1"
os.environ["TRANSFORMERS_OFFLINE"] = "1"

# Qwen3에는 GPU가 필요하다. 없으면 여기서 멈춘다.Qwen3 needs a GPU. Without one, stop here.
assert torch.cuda.is_available(), "No GPU detected..."
print("GPU:", torch.cuda.get_device_name(0))

drive.mount("/content/drive")
BASE        = "/content/drive/MyDrive/DH2026_Workshop"
ENCODER_DIR = f"{BASE}/Encoder"
LLM_DIR     = f"{BASE}/LLM"
필요한 것을 먼저 책상에 다 올려두기Everything you need on the desk first

본격적인 작업 전에 라이브러리·모델·데이터를 한자리에 모아 둔다. 이후 중간에 다시 자료를 찾으러 나가지 않도록 — 네트워크 봉인은 "이 자리에 있는 것만으로 끝까지 간다"는 약속이다.Before the real work begins, gather libraries, models and data in one place, so you never have to go looking for material mid-task. Sealing the network is a promise: we finish with what is on this desk.

workshop_code.md · STEP 1 ↗ 보조자료 · 우리가 쓰는 자료Companion · The Material We Use →
02
STEP 2 · PDF → text → naive chunks

naive chunk 실패 목격Witness naive chunking fail

묻지도 따지지도 않고 글자 수로 자른다. 이 청크는 검색에 쓰지 않는다 — 뒤에서 구조화 청크와 대비할 "이전(before)" 기준선이다.Cut by character count, no questions asked. These chunks are not used for retrieval — they are the “before” baseline against which the structured chunks will be set.

500자마다 눈 감고 자르고 50자를 겹친다. 구조도, 소제목도, 전거도 없다. 실행해 보면 왜 이것이 실패인지 눈으로 확인된다.Cut blind every 500 characters with a 50-character overlap. No structure, no headings, no provenance. Run it and you see with your own eyes why it fails.

workshop_code.md2-2
# 눈 감고 500자씩 절단, 50자 겹침 — 나이브 기준선cut blind every 500 chars, 50-char overlap — the naive baseline
splitter = RecursiveCharacterTextSplitter(
    chunk_size=500, chunk_overlap=50)
naive_chunks = splitter.split_text(raw_text)
✗ naive chunk가 낳는 참사✗ the wreckage naive chunking leaves

글자 수는 의미 경계를 모른다Character counts know nothing of meaning

문장이 중간에서 잘리고, 조판 지시문이 본문에 섞이며, 숫자 부스러기만 남은 청크가 생기고, Goal 경계가 뒤섞인다.Sentences are severed mid-way, typesetting instructions bleed into the body, chunks survive holding nothing but scraps of numbers, and Goal boundaries are jumbled together.

...end of Goal 1 pover 0p6 Stroke .25pt 789 613 552 ty affects...
진단Diagnosis

두 가지가 동시에 무너졌다Two things collapsed at once

① 원천 오염 — 조판 지시문·표 부스러기가 섞여 있다.
② 구조 무지 — 글자 수로 자르니 의미 단위를 모른다.
① Contaminated at source — typesetting instructions and table debris are mixed in.
② Blind to structure — cutting by character count knows no unit of meaning.

두 문제 다 구조를 모르기 때문이다. 구조를 명시하면 둘 다 풀린다 → XML(STEP 3)Both problems come from not knowing the structure. Make the structure explicit and both dissolve → XML (STEP 3)

자를 곳을 정하는 건 자(尺)가 아니다It is not the ruler that decides where to cut

글을 내용과 무관하게 일정 길이로 잘라 버리면, 한 문장이 두 조각으로 흩어지고 앞뒤 맥락을 잃는다. 어디서 끊을지는 글자 수가 아니라 의미의 단위가 정해야 하고, 그 단위를 아는 건 자료를 읽은 사람이다.Cut text to a fixed length regardless of content and a single sentence scatters into two pieces, losing the context on either side. Where to break should be decided by the unit of meaning, not the character count — and the person who knows that unit is the one who has read the material.

workshop_code.md · STEP 2 ↗ 보조자료 · 청크란 무엇인가Companion · What Is a Chunk →
03
STEP 3 · Structure the PDF into hierarchical XML

PDF → XML ★ 무게중심★ centre of gravity

평면 텍스트는 Goal > Subsection > Paragraph의 위계를 잃는다. 그런데 그 위계는 사라진 적이 없다 — 문서 안에 그대로 있다.Flat text loses the hierarchy of Goal > Subsection > Paragraph. Yet that hierarchy never disappeared — it is still there, inside the document.

편집자는 소제목을 굵은 11포인트로, 본문을 9포인트로 지정해 두었다. 조판이 곧 구조다. 그러니 "이 줄이 소제목인가"를 글자만 보고 추측할 필요가 없다. 문서가 이미 선언해 둔 것을 읽으면 된다.The editor set subheadings in bold 11-point and body text in 9-point. The typesetting is the structure. So there is no need to guess from the words alone whether a line is a subheading. Just read what the document has already declared.

GothamBold11pt소제목Subheading→ subsection
Whitney-Book9pt본문 문단Body paragraph→ paragraph
Gotham-Black16ptGoal 제목Goal title경계 판별marks boundaries
Whitney-Semibold8.5pt사진 캡션Photo caption제외excluded
Whitney-Semibold8pt도표 제목Figure title제외excluded
Whitney-Medium6pt도표 축 숫자·라벨Axis numbers and labels제외excluded
Gotham-Black8pt머리말 · 쪽번호Running head · page number제외excluded
두 줄만 취하면 된다. 조판 지시문·캡션·표 숫자는 서체가 다르므로 저절로 빠진다.Only two rows need to be taken. Typesetting instructions, captions and table numbers are set in different faces, so they drop out on their own.
build_xml.py판별부 전체full classifier
def classify(spans):
    font, size = spans[0]["font"], round(spans[0]["size"], 1)

    if "Gotham-Black" in font and 15 <= size <= 17:
        return "goal_title"
    if all("GothamBold" in s["font"] and 10.5 <= s["size"] <= 11.5 for s in spans):
        return "heading"      # ← 소제목subheading
    if font.startswith("Whitney-") and 8.8 <= size <= 9.2:
        return "body"         # ← 본문body text

    return "ignore"           # 나머지는 전부 버린다discard everything else
글자를 읽지 말고,
조판을 읽는다.
Do not read the letters —
read the typesetting.
workshop_code.md3-1
# build_xml.py : [입력 PDF] [출력 XML][input PDF] [output XML]
!python "{BUILD_SCRIPT}" "{PDF_PATH}" sdg_report_2025.xml
판식(版式)을 보고 판본을 가른다The page format tells you the edition

서지학은 활자와 행관(行款), 판식을 보고 판본을 가려낸다. 본문을 다 읽기 전에 형태가 먼저 말해 주기 때문이다. 여기서 하는 일도 같다 — 이 문서에서는 서체가 그 형태였다. 자료마다 구조를 담고 있는 자리는 다르고, 그 자리를 찾아내는 것이 연구자의 몫이다.Bibliography distinguishes editions by their type, line rulings and page format, because the form speaks first, before you have read the text through. What we do here is the same — in this document, the form was the typeface. Where the structure lives differs from source to source, and finding that place is the researcher's part of the work.

workshop_code.md · STEP 3 ↗ 보조자료 · 왜 XML인가Companion · Why XML →
04
STEP 4 · XML → chunks → LangChain Documents

XML → chunk

<subsection> 하나 = 청크 하나가 원칙이다. 본문은 검색 대상이 되고, Goal 번호·이름·쪽수·heading은 메타데이터(전거)가 되어 매 검색 결과에 따라붙는다.The principle: one <subsection> = one chunk. The body text becomes searchable; the Goal number, name, pages and heading become metadata (the provenance) and ride along with every retrieval result.

정본 XML은 드라이브에서 읽기 전용으로 불러오므로, 참가자 전원이 완전히 같은 판본에서 출발한다. 검색 대상이 되는 것은 소제목 + 본문이고, Goal 번호·이름·쪽수는 검색되지 않고 전거로만 실린다.The canonical XML is loaded read-only from the Drive, so every participant starts from exactly the same edition. What becomes searchable is subheading + body; the Goal number, name and pages are never searched — they ride only as provenance.

  • page_content소제목 + 본문 문단 — 이 전체가 벡터가 된다Subheading + body paragraphs — all of this becomes the vector
  • metadataid · goal · goal_name · pages · heading · part — 검색되지 않고 따라만 붙는다 — never searched, only carried along
소제목은 양쪽에 다 들어간다 — 앞에서는 검색을 돕고, 뒤에서는 출처를 밝힌다.The subheading goes on both sides — on the front it aids retrieval, on the back it names the source.
단, 인코더가 삼킬 수 있는 크기까지만But only as large as the encoder can swallow

인코더의 입력 한도는 256토큰이다. 넘으면 뒷부분이 잘린 채 벡터가 되어 검색에서 빠진다. 그래서 172단어(제목 포함)를 넘으면 문단 경계에서, 문단 하나가 그보다 길면 문장 경계에서 나눈다 — 문장은 자르지 않는다.The encoder's input limit is 256 tokens. Go over and the tail is truncated before it becomes a vector, dropping out of retrieval entirely. So beyond 172 words (title included) we split at a paragraph boundary, and if a single paragraph is longer than that, at a sentence boundary — we never cut a sentence.

그대로 둔 것Left whole

47 / 108 소제목47 / 108 subheadings

한도 안에 들어오므로 1 소제목 = 1 청크 그대로.They fit within the limit, so one subheading stays one chunk.

나눈 것Split

나머지 61 소제목The remaining 61 subheadings

문단·문장 경계에서 분할. part: "1/2"가 붙지만 heading·goal·pages는 동일하므로 전거는 그대로다.Split at paragraph and sentence boundaries. A part: "1/2" is attached, but heading, goal and pages stay identical, so the provenance is unchanged.

소제목 108개 → 청크 176개 · 최대 249토큰 (한도 256)108 subheadings → 176 chunks · max 249 tokens (limit 256)
workshop_code.md4-1
chunks.append({
    "metadata": {                    # 전거. 절대 임베딩 안 함provenance. never embedded
        "id":        f"G{g_num:02d}-S{i+1:02d}",
        "goal":      g_num,
        "goal_name": g_name,
        "pages":     g_pages,
        "heading":   heading,
    },
    "text": f"{heading}\n{body}",     # 본문. 이것만 임베딩body. only this is embedded
})
Document = 서지 정보가 붙은 색인 카드Document = an index card with its bibliography attached

LangChain Document는 출처가 적힌 색인 카드다. 앞면(page_content)엔 검색될 본문을, 뒷면(metadata)엔 출처를 적는다. 뒷면은 검색되지 않지만, 카드가 뽑힐 때 늘 함께 딸려 나온다 — 그것이 전거(典據, 출처 근거)다.A LangChain Document is an index card with its source written on it. The front (page_content) holds the text to be searched; the back (metadata) holds the source. The back is never searched, but it always comes out with the card when the card is drawn — that is provenance.

소제목만은 양면에 모두 적는다. 앞면에 두는 이유는 나뉜 조각 때문이다 — part 2/2는 본문 중간 문단들만 갖고 있어서, 소제목이 없으면 무슨 주제인지 알 수 없는 고아 문단이 된다. 제목을 붙여야 검색이 그 조각을 찾아낸다.The subheading alone is written on both faces. It goes on the front because of the split pieces — a part 2/2 holds only middle paragraphs, and without the subheading it is an orphan passage whose subject cannot be told. Attach the title and retrieval can find that piece.

workshop_code.md · STEP 4 ↗ 보조자료 · 전거가 실리는 법Companion · How Provenance Rides Along →
05
STEP 5 · Load the encoder · embed every chunk

Chunk → Vector

각 청크를 384개의 숫자로 바꾼다. 이 좌표가 의미의 위치다. GPU에서 전체가 약 1초면 끝난다.Turn each chunk into 384 numbers. Those coordinates are where its meaning sits. On a GPU the whole set takes about a second.

인코더는 드라이브에서 로컬로 불러오고(허브가 봉인돼 있으므로), normalize_embeddings=True로 정규화한다. 정규화된 벡터에서는 L2거리² = 2 − 2·코사인유사도 — L2와 코사인이 순위상 동치가 되어, 화면 숫자와 설명이 일치한다.The encoder is loaded locally from the Drive (the Hub is sealed) and normalised with normalize_embeddings=True. For normalised vectors, L2 distance² = 2 − 2·cosine similarity — L2 and cosine rank identically, so the numbers on screen match the explanation.

workshop_code.md5-1 · 5-2
embeddings = HuggingFaceEmbeddings(
    model_name=ENCODER_DIR,
    model_kwargs={"device": "cuda"},
    encode_kwargs={"normalize_embeddings": True},
)
# 각 문장 → 384개의 숫자each passage → 384 numbers
vectors = embeddings.embed_documents([c["text"] for c in chunks])
의미를 좌표로 — 384차원의 자리Meaning as coordinates — a place in 384 dimensions

글의 뜻을 384개 축 위의 한 지점으로 옮긴다. 비슷한 뜻은 가까이, 다른 뜻은 멀리 놓인다. 주제별로 자료의 자리를 정해 두는 분류 체계와 같되, 그 자리를 사람이 아니라 의미의 근접성이 결정한다.The sense of a passage is moved to a single point on 384 axes. Similar meanings land near each other, different ones far apart. It is like a classification scheme assigning each item a place by subject — except the place is decided not by a person but by proximity of meaning.

workshop_code.md · STEP 5 ↗ 보조자료 · 임베딩과 벡터Companion · Embeddings and Vectors →
06
STEP 6 · Build the vector store (FAISS)

Vector DB(FAISS) 구축Building the Vector DB (FAISS)

STEP 5의 벡터가 그대로 들어간다 — 아무것도 다시 계산하지 않는다. 벡터와 원문은 따로 저장되고, 색인 번호가 둘을 잇는다.The vectors from STEP 5 go straight in — nothing is recomputed. Vectors and source text are stored separately, joined by an index number.

여기서 A(자료 준비)가 끝나고 B(질문·검색)가 시작된다. 앞의 흐름도에서 청록으로 강조된 경첩이 바로 이 색인집이다. FAISS는 벡터, 원문, id 테이블 세 저장소를 나란히 두고, 색인 번호로 즉시 맞물린다.Here A (preparing the material) ends and B (question and retrieval) begins. The hinge picked out in teal in the earlier diagram is exactly this index. FAISS keeps three stores side by side — vectors, source text, and an id table — meshed instantly by index number.

workshop_code.md6-1
store = FAISS.from_embeddings(
    text_embeddings=list(zip(
        [c["text"] for c in chunks], vectors)),
    embedding=embeddings,
    metadatas=[c["metadata"] for c in chunks],
    ids=[c["metadata"]["id"] for c in chunks],
)
# 벡터 저장소 · id 테이블 · 원문 저장소가 색인 번호로 맞물린다vector store · id table · document store mesh by index number
색인의 완성 — A에서 B로 넘어가는 자리The index complete — where A hands over to B

수천 항목을 좌표로 정리해 둔 색인. 이제 어떤 질문이 와도 전체 원문을 처음부터 읽지 않고, 색인만 뒤져 가장 가까운 항목으로 곧장 간다. 메타데이터(전거)가 함께 저장되어, 찾은 항목마다 출처가 딸려 나온다.An index arranging thousands of entries by coordinate. Whatever question arrives, we no longer read the whole text from the start — we search the index alone and go straight to the nearest entries. The metadata (the provenance) is stored alongside, so every entry found brings its source with it.

workshop_code.md · STEP 6 ↗ 보조자료 · 벡터 데이터베이스Companion · The Vector Store →
07
STEP 7 · A question becomes a vector too

Query → Vector

청크를 임베딩한 바로 그 인코더가 질문을 임베딩한다. 유일한 차이 — 질문에는 메타데이터가 없다.The question is embedded by the very same encoder that embedded the chunks. The only difference — a question has no metadata.

질문과 청크가 같은 좌표계에 놓여야 거리를 잴 수 있다. 다른 자로 잰 길이는 비교할 수 없듯, 같은 인코더로 임베딩해야 한다. 여기서 B 국면(온라인)이 실제로 돌기 시작한다.Question and chunks must sit in the same coordinate system before a distance can be measured. Just as lengths taken with different rulers cannot be compared, both must be embedded by the same encoder. This is where phase B (online) actually starts running.

workshop_code.md7-1
query = "How many people still live in extreme poverty?"

# 청크와 같은 인코더 · 같은 384차원 좌표계same encoder as the chunks · same 384-dim coordinate system
qv = embeddings.embed_query(query)

print(f"vector: {len(qv)} dims")   # → 384
같은 척도로 재기Measuring on the same scale

질문과 자료를 비교하려면 같은 척도가 필요하다. 청크를 잰 그 인코더로 질문도 재야, 둘 사이의 거리가 의미를 갖는다. 서로 다른 도량형으로 잰 값은 나란히 둘 수 없다.Comparing a question with the material requires one scale. Only if the question is measured by the encoder that measured the chunks does the distance between them mean anything. Values taken in different systems of measure cannot be set side by side.

workshop_code.md · STEP 7 ↗ 보조자료 · 거리로 찾는다 (STEP 7·8)Companion · Finding by Distance (STEP 7–8) →
08
STEP 8 · Distance, by hand

Distance 계산Distance, by hand

검색이란 거리를 재서 정렬하는 것, 그 이상도 이하도 아니다. FAISS 없이 넘파이로 직접 해보며, FAISS가 대신 해주는 일을 눈으로 본다.Retrieval is measuring distances and sorting them — no more, no less. We do it ourselves in NumPy, without FAISS, and see with our own eyes what FAISS does on our behalf.

쿼리 벡터와 모든 청크 벡터의 차이를 제곱해 더하고 제곱근을 취한다 — 그게 L2 거리다. 정렬하면 가장 가까운 청크가 위로 온다. 다음 단계에서 FAISS 결과와 완전히 같음을 확인한다.Take the difference between the query vector and every chunk vector, square it, sum, and take the square root — that is L2 distance. Sort, and the nearest chunk rises to the top. In the next step we confirm this is exactly identical to what FAISS returns.

workshop_code.md8-1
V = store.index.reconstruct_n(0, store.index.ntotal)  # 모든 청크every chunk
Q = np.array(qv)                                    # 질문 하나one question

distances = []
for v in V:
    diff = v - Q                        # 384개의 차이384 differences
    dist = np.sqrt((diff ** 2).sum())   # 제곱→합→제곱근square→sum→root
    distances.append(dist)

order = np.argsort(distances)             # 가까운 순 정렬sort nearest first
블랙박스를 열어 본다Opening the black box

검색이 마법처럼 보이지만, 실은 손으로 잴 수 있는 산술이다. 원리를 직접 계산해 보는 것은, 도구가 내놓은 결과를 그대로 믿기 전에 그 결과가 어떻게 나왔는지 스스로 확인하는 태도다 — 인문학 연구가 근거를 손수 대조해 온 방식 그대로.Retrieval looks like magic, but it is arithmetic you can do by hand. Working the principle out yourself is the habit of checking how a result was arrived at before trusting what a tool hands you — exactly how humanities scholarship has always collated its evidence.

workshop_code.md · STEP 8 ↗ 보조자료 · 거리로 찾는다Companion · Finding by Distance →
09
STEP 9 · FAISS retrieval + provenance

FAISS 검색 + 전거FAISS retrieval + provenance

STEP 8에서 손으로 한 것을 FAISS가 한 줄로 한다. 결과가 같음을 확인한 뒤, 각 결과에 출처(Goal·subsection·쪽·거리)를 붙인다.What we did by hand in STEP 8, FAISS does in one line. Having confirmed the results match, we attach to each one its source (Goal · subsection · pages · distance).

"방금 손으로 한 게 이거였다." 손계산과 FAISS의 상위 3개가 정확히 일치함을 보여주고, 메타데이터로 전거를 표시한다 — 메타데이터는 검색되지 않지만 결과에 늘 딸려 나온다.“That is what we just did by hand.” We show the top 3 from the hand computation and from FAISS agreeing exactly, then display the provenance from the metadata — which is never searched, yet always comes out with the result.

workshop_code.md9-1 · 9-2
results = store.similarity_search_with_score(query, k=3)
print("STEP 8 (by hand):", hand_top3)
print("STEP 9 (FAISS) :", faiss_top3)
print("match          :", hand_top3 == faiss_top3)   # True

# 각 결과에 전거를 붙인다attach the provenance to each result
print(f"{m['id']} · Goal {m['goal']} {m['goal_name']} · pp. {m['pages']}")
전거(典據)의 부착 — 출처 없는 결과는 못 믿는다Attaching provenance — a result without a source cannot be trusted

찾은 대목마다 "어느 목표, 어느 절, 몇 쪽"을 명기한다. 인용에 반드시 출처를 다는 인문학의 규율 그대로다. 근거를 댈 수 없는 검색 결과는 신뢰할 수 없다.For every passage found, state which Goal, which section, which pages. It is the humanities' own discipline of always citing a source. A retrieval result whose grounds cannot be given is not trustworthy.

workshop_code.md · STEP 9 ↗ 보조자료 · 답변이 되기까지 (STEP 9·10)Companion · From Retrieval to Answer (STEP 9–10) →
10
STEP 10 · Generation with provenance (Qwen3-0.6B)

생성 + 전거Generation + provenance

검색기가 근거를 찾고, LLM이 그것을 답으로 엮는다. 모든 답변은 그 답이 딛고 선 출처와 함께 제시된다.The retriever finds the grounds; the LLM weaves them into an answer. Every answer is presented together with the sources it stands on.

Qwen3는 causal 모델(AutoModelForCausalLM)이자 chat 모델이라, 입력을 chat 템플릿으로 감싸고 답변만 잘라낸다. 핵심은 before/after 대비다.Qwen3 is a causal model (AutoModelForCausalLM) and a chat model, so we wrap the input in a chat template and slice out just the answer. The point is the before/after contrast.

BEFORE · context 없음BEFORE · no context

기억만으로 답한다Answering from memory alone

검색도 근거도 없이 모델의 기억에서 답을 꺼낸다. 그럴듯하지만 낡았을 수 있고, 틀렸을 수 있고, 확인할 출처가 없다.The answer is drawn from the model's memory, with no retrieval and no grounds. It is plausible, but it may be stale, it may be wrong, and there is no source to check.

answer = llm.invoke(query) # 출처 없음. 검증 불가.
answer = llm.invoke(query) # No source. Cannot be verified.
AFTER · 검색된 근거 위에서AFTER · on retrieved grounds

보고서에 딛고 선 답An answer standing on the report

근거를 검색해 LLM에 넣고, 답변을 출처와 함께 보여준다. 이제 모든 진술이 열어 확인할 수 있는 named source 위에 선다.The grounds are retrieved, fed to the LLM, and the answer is shown together with its sources. Now every statement stands on a named source you can open and check.

ask_with_sources(query) # 답변 + Sources: [G01-S01] # Goal 1 No poverty · pp. 10-11
ask_with_sources(query) # answer + Sources: [G01-S01] # Goal 1 No poverty · pp. 10-11
workshop_code.md10-3
def ask_with_sources(q, k=3):
    results = store.similarity_search_with_score(q, k=k)   # 1. 검색retrieve
    context = "\n\n".join(doc.page_content for doc, _ in results)
    prompt = f"Use only the following sources... {context}\n\nQuestion: {q}"
    answer = llm.invoke(prompt)                            # 3. 생성generate
    print(answer)
    print("\nSources")                                    # 4. 전거provenance
    for doc, _ in results:
        m = doc.metadata
        print(f"  [{m['id']}] Goal {m['goal']} · pp. {m['pages']}")
같은 질문, 두 개의 답. 첫째는 확신에 차 있으나 확인할 수 없고, 둘째는 열어볼 수 있는 출처 위에 선다. 그 대비가 전거 우선 RAG의 전부다.One question, two answers. The first is confident but uncheckable; the second stands on sources you can open. That contrast is the whole of provenance-first RAG.
workshop_code.md · STEP 10 ↗ 보조자료 · 답변이 되기까지Companion · From Retrieval to Answer →
마무리 · 정리Closing · Recap

구조를 먼저 이해하고, 정제는 거기에 맞춘다Understand the structure first, then fit the cleaning to it

자료의 구조가 검색 단위를 정하고,
검색 단위가 답변의 전거(典據) 단위를 정한다.
The structure of the material sets the unit of retrieval,
and the unit of retrieval sets the unit of provenance in the answer.
구조를 안다Know the structureUnderstand무엇이 목차이고
무엇이 본문인가
what is heading
and what is body
그에 맞춰 정제한다Clean to match itClean구조에 없는 것은
버린다
what the structure
omits, discard
구조대로 자른다Cut along the structureChunk경계가 곧
검색 단위
the boundary is
the unit of retrieval
전거가 따라온다Provenance followsCite구조가 곧
출처 주소
the structure is
the source address

오늘 우리는 STEP 2에서 구조를 모른 채 글자 수로 자르는 실패를 고의로 경험했다. 이렇게 할 경우 실패의 원인은 명확하다 — 자료의 구조를 먼저 확정하지 않았다는 것.Today, in STEP 2, we deliberately went through the failure of cutting by character count without knowing the structure. When you do that, the cause of the failure is clear — the structure of the material was not established first.

구조를 확정하고 나면 나머지는 따라온다. 무엇을 버릴지가 분명해지고, 어디서 자를지가 분명해지고, 잘린 조각마다 제 주소가 붙는다. 전거는 마지막에 덧붙이는 장식이 아니라, 구조를 지킨 결과로 저절로 남는 것이다.Once the structure is settled, the rest follows. What to discard becomes clear, where to cut becomes clear, and every piece cut carries its own address. Provenance is not an ornament added at the end — it is what remains of its own accord when the structure has been kept.

이 워크샵이 남기는 것은 챗봇 한 개가 아니라, 여러분의 자료에 그대로 옮겨 쓸 수 있는 방법이다. 실록이든 관보든 문학 텍스트든 철학 원전이든 — 자료마다 구조가 놓인 자리는 다르지만, 구조를 먼저 읽고 거기에 정제를 맞춘다는 순서는 같다. 그 순서를 세우는 자리에서 오늘의 작업이 다시 쓰인다.What this workshop leaves you is not one chatbot but a method you can carry straight over to your own material. Veritable records, official gazettes, literary texts, philosophical originals — where the structure sits differs with every source, but the order is the same: read the structure first, then fit the cleaning to it. Wherever you set that order, today's work is written again.

마무리 · 핵심 메시지Closing · The core message

그래서, 가장 먼저 보아야 할 것So, what to look at first

RAG의 철학은 '근거'를 바탕으로 답변을 '생성'하는 것이다.The philosophy of RAG is to generate an answer grounded in evidence.
그렇기 때문에 RAG를 설계할 때 우선적으로 고려해야 하는 것은 —That is why the first thing to consider when designing a RAG is —
트렌디한 최신 LLMthe trendiest new LLM

오히려 인문학, 특히 역사학에서 오랫동안 강조해온 것, 그리고 다소 지루한 것.It is, rather, what the humanities — history above all — have long insisted on, and what sounds rather dull.

바로 '자료'가 어떤 내용인지,
어떻게 구조화되어 있는지 아는 것이다.
Namely, knowing what your material actually says,
and how it is structured.
감사합니다 · 내가 만든 것들Thank you · What I've built

오늘의 원칙으로, 저도 만들고 있습니다Built on the very principles we practiced today

반나절을 끝까지 함께해 주셔서 고맙습니다. 오늘 실습한 그 원칙 그대로, 저는 제 자료 위에 RAG를 짓고 있습니다. QR이나 링크로 직접 만나 보세요.Thank you for staying through the whole half-day. On the very principles we practiced today, I build RAG systems on my own material. Meet them by QR or link.

AskSillok
RAG · 380,000 records
15–19세기 한반도를 다스린 조선의 기록, 《조선왕조실록》 38만 건의 사료 위에 세운 RAG입니다. 영어 버전도 있으니 편히 들어와 보세요.A RAG built on 380,000 records of the Veritable Records of the Joseon Dynasty — the archive of Joseon, the state that governed the Korean peninsula from the 15th to the 19th century. An English version is available too.
beta.asksillok.com ↗
마르쿠스와의 대화A Talk with Marcus
RAG · Meditations
심심풀이로 만든 《명상록》 기반 RAG 챗봇입니다. 로마의 철인 황제 마르쿠스 아우렐리우스와 이야기하고 싶다면 들어와 보세요 — 당신의 고민에 꽤 그럴듯한 답을 건넬 겁니다.A little side project: a RAG chatbot grounded in the Meditations. If you'd like to talk with Marcus Aurelius, the philosopher-emperor of Rome, step in — he'll offer a surprisingly plausible answer to whatever weighs on you.
QR로 여세요 (주소가 깁니다)Open via QR (the URL is long) ↗
초대 · DH2026 발표An invitation · My DH2026 talks

시간이 되신다면, 제 발표에도 와 주세요If you have the time, come to my talks

이번 DH2026에서 두 편을 발표합니다. 특히 수요일 발표는 오늘 이야기한 정교한 RAG 파이프라인 구축 전략을 다룹니다.I'm presenting two papers at DH2026. The Wednesday talk in particular is about strategies for building a well-crafted RAG pipeline — exactly today's theme.

Short Paper 수요일 · RAGWed · RAG Jul 29 · 16:30–18:00 · S048 · Room 106
From Searchable Archives to Askable Archives: Designing a RAG-Based Research Interface for The Annals of the Joseon Dynasty
오늘의 파이프라인을 실제 연구 인터페이스로 끌어올린 이야기입니다.How today's pipeline grows into a real research interface.
Long Paper Jul 30 · 11:00–12:30 · S029 · Room 104
A Distant Reading of the Bulletin of Korean Historical Studies: Temporal Consciousness in Korean Historiographical Publications
한국 역사학 출판물을 원거리 읽기(distant reading)로 분석한 연구입니다.A distant reading of Korean historiographical publications.
저는 RAG에 디지털인문학의 미래가 있다고 믿습니다. 앞으로도 이 길에서 여러 연구를 이어갈 예정이니, 국제적인 연구 협력을 기대합니다.I believe the future of Digital Humanities lies in RAG. I'll keep pursuing this path, and I look forward to research collaboration across borders.