STEP 3 왜 XML인가Why XML ← 발표자료Slides
DH2026 Workshop · 보조자료Supplement

구조를 담는 그릇A Vessel That Holds Structure

STEP 2에서 본 실패의 원인은 하나였다 — 문서의 구조를 모른다. 그렇다면 구조를 아는 형태로 자료를 옮겨 두면 된다. 여기서는 XML이라는 형식 자체가 왜 청킹에 이상적인지를 본다. 만드는 규칙은 문서마다 다르지만, 이 이유는 어느 자료에나 통한다.Every failure in STEP 2 came down to one thing — we did not know the document’s structure. So move the material into a form that does know it. This page is about why XML as a format suits chunking so well. How you build it differs from document to document; why you want it holds for any of them.
① 대조Contrast

같은 내용, 두 가지 형태Same Content, Two Forms

왼쪽은 PDF에서 뽑은 그대로의 텍스트, 오른쪽은 같은 대목을 XML로 옮긴 것이다. 글자는 같다. 다른 것은 경계가 보이느냐다.On the left, text as extracted from the PDF. On the right, the same passage as XML. The words are identical. What differs is whether the boundaries are visible.

◧ 평면 텍스트 — 경계를 추측해야 한다Flat text — boundaries must be guessed
vintage with the 
2021 PPPs. Hence, the difference between the two series is not only due to new PPPs and 
the new international poverty line, but also due to the inclusion of new survey data. Dotted 
lines are projected data or nowcasts.□
Working poverty rate has decreased worldwide but persists in vulnerable regions
Worldwide, working poverty has significantly declined over the past 25 
years, but recent trends in most regions suggest a slowdown in progress. 
In 2024, 6.9 per cent of the employed population – more than 240 million 
workers worldwide – lived on less than $2.15 in 2017 PPP per day, down from 
8.4 per cent in 2015. 
Eastern and South-Ea
◨ XML — 경계가 선언되어 있다XML — boundaries are declared
<goal number="1" name="No poverty" pages="10-11">
  <subsection heading="Working poverty rate has decreased worldwide but persists …">
    <paragraph>Worldwide, working poverty has significantly declined over the past 25 years, but recent trends …</paragraph>
    <paragraph>Eastern and South-Eastern Asia and Central and Southern Asia have made significant progress, red…</paragraph>
  </subsection>
</goal>
텍스트Plain text

“여기가 끝인가?”를 매번 묻는다You ask “does it end here?” every time

어디까지가 한 소제목의 몫인지, 이 줄이 제목인지 본문인지 — 전부 추론해야 한다. 추론은 틀릴 수 있고, 틀리면 조용히 틀린다.Where one heading’s territory ends, whether a line is a heading or body — all of it must be inferred. Inference can be wrong, and when it is, it fails silently.

XML

“여기서 끝난다”가 적혀 있다It says where it ends

</subsection>이 경계를 말한다. 프로그램은 묻지 않고 읽기만 한다. 추측이 사라지면 오류도 사라진다.</subsection> states the boundary. The program does not ask; it reads. Remove the guessing and you remove that class of error.

② 전거Provenance

위계가 곧 주소다The Hierarchy Is the Address

XML에서 모든 문단은 자기가 어디에 속하는지 안다. 트리에서의 위치가 그대로 인용 주소가 된다. 아무 마디나 눌러 보라.In XML every paragraph knows where it belongs. Its position in the tree is already a citation. Click any node.

Goal 선택Choose a Goal
트리에서의 경로가 전거 주소가 된다 — 이 주소는 STEP 9의 검색 결과와 STEP 10의 답변까지 그대로 따라간다.The path through the tree becomes a citation — and it travels unchanged into the STEP 9 results and the STEP 10 answer.
③ 선택Choice

청크 단위를 나중에 고를 수 있다You Can Choose the Chunk Unit Later

이것이 XML의 가장 실질적인 이점이다. 자료를 다시 파싱하지 않고, 코드 한 줄만 바꿔 청크 단위를 바꿀 수 있다.This is XML’s most practical advantage. Without re-parsing anything, one line of code changes what a chunk is.

토큰 수 분포 · 주홍은 인코더 한도(256토큰)를 넘는 구간Token distribution · red marks the range beyond the encoder’s 256-token limit
같은 파일에서 17개 · 108개 · 243개 — 세 가지 청킹이 모두 나온다. 평면 텍스트였다면 매번 처음부터 다시 잘라야 했다.From one file: 17, 108, or 243 — three chunkings, all available. With flat text you would have to cut it all over again each time.
④ 결정Decision

그래서 무엇을 골랐나So What Did We Choose

셋 다 장단이 있다. 우리는 소제목을 기본 단위로 삼되, 인코더 한도를 넘는 것만 문단 경계에서 나눴다. 메뉴에서 고른 것이 아니라 조합한 것이다.Each has its trade-off. We took the subsection as the base unit and split only those exceeding the encoder’s limit, at paragraph boundaries. Not picked off the menu — composed.

goal

너무 크다Too large

17개 전부가 한도를 넘는다. 맥락은 완전하지만 검색 단위로는 쓸 수 없다.All 17 exceed the limit. Complete in context, unusable as a search unit.

subsection ← 선택chosen

의미 단위A unit of meaning

하나의 주장이 하나의 청크가 된다. 전거도 여기서 가장 자연스럽다.One claim becomes one chunk. Provenance sits most naturally here too.

paragraph

너무 잘다Too fine

크기는 안전하지만 한 주장이 여러 조각으로 흩어진다.Safe in size, but a single claim scatters across pieces.

최종 청크Final chunks
176
소제목 108 + 분할108 subsections + splits
분할 없이 유지Kept whole
47
108개 중of 108
최대 토큰Largest chunk
249
한도 256 이내within the 256 limit
정본(定本)을 만들어 두는 일Establishing a critical edition

교감을 마친 정본이 있으면 이후의 모든 인용이 그 위에서 이뤄진다. XML은 그 정본에 해당한다 — 한 번 만들어 두면 청킹·검색·인용이 전부 이 하나를 근거로 삼는다.Once a collated edition exists, every later citation rests on it. The XML plays that role — settle it once, and chunking, retrieval and citation all refer back to it.

⑤ 정리In sum

XML이 청킹에 이상적인 네 가지 이유Four Reasons XML Suits Chunking

하나One
경계가 선언되어 있다Boundaries are declared
어디서 끊을지 추측하지 않는다. </subsection>이 말해 준다.No guessing where to cut. </subsection> says so.
둘Two
위계가 주소가 된다The hierarchy is an address
트리에서의 위치가 그대로 전거가 된다. Goal·쪽수·소제목이 자료에 붙어 다닌다.Position in the tree is the citation. Goal, pages and heading travel with the text.
셋Three
단위를 나중에 고를 수 있다The unit is a later decision
XPath 한 줄로 17개·108개·243개를 오간다. 자료를 다시 만들지 않는다.One XPath moves between 17, 108 and 243. The material is never rebuilt.
넷Four
검증할 수 있다It can be verified
Goal 17 · 소제목 108 · 문단 243 — 세어서 확인된다. 평면 텍스트는 셀 수 없다.17 goals, 108 subsections, 243 paragraphs — countable, checkable. Flat text cannot be counted.
구조를 아는 형태로 옮겨 두면,
그 뒤의 결정은 전부 쉬워진다.
Move it into a form that knows its own structure,
and every later decision gets easier.
다음은 STEP 4 — 이 XML에서 실제로 청크를 꺼내고, 인코더가 삼킬 수 있는 크기로 다듬는다.Next is STEP 4 — pulling chunks out of this XML and trimming them to a size the encoder can swallow.
DH2026 Workshop · Build a Working RAG in Half a Day
모든 수치는 Source/sdg_report_2025.xml을 실제로 파싱해 계산했습니다 · 토큰은 all-MiniLM-L6-v2의 WordPiece 실측All figures were computed by parsing the real Source/sdg_report_2025.xml · Token counts use the actual all-MiniLM-L6-v2 WordPiece vocabulary
← 발표자료로 돌아가기Back to the slides · STEP 2 · STEP 4