STEP 6 벡터 데이터베이스The Vector Store ← 발표자료Slides
DH2026 Workshop · 보조자료Supplement

좌표를 어디에, 어떻게 담는가Where the Coordinates Live

STEP 5에서 청크 176개가 각각 숫자 384개를 갖게 됐다. 이제 이것을 찾기 좋게 정리해 둘 차례다. 그런데 벡터만 담아서는 쓸모가 없다 — 찾아낸 좌표가 어느 청크였는지 알아야 하고, 그 청크의 출처도 알아야 한다. 벡터 데이터베이스가 실제로 무엇을 담는지 열어 본다.In STEP 5 each of our 176 chunks acquired 384 numbers. Now they need to be filed so they can be found. But storing vectors alone is useless — you have to know which chunk a coordinate came from, and where that chunk came from. Let us open up what a vector store actually holds.
① 문제The problem

벡터만 있으면 아무 쓸모가 없다A Vector on Its Own Is Useless

검색은 벡터로 한다. 질문 벡터와 가장 가까운 좌표를 찾는 것이다. 그런데 찾고 나면 숫자 384개가 손에 남는다. 그것으로는 아무것도 못 한다 — 사람에게 보여줄 수도, 출처를 댈 수도 없다.Search happens in vector space: find the coordinate nearest the query. But when you have found it, what you hold is 384 numbers. You can do nothing with that — you cannot show it to a reader, and you cannot cite it.

벡터만 저장하면Vectors only

“가장 가까운 건 이 좌표입니다”“The nearest coordinate is this”

답으로 [0.0172, -0.0312, …]를 내놓을 수는 없다. 원문도 출처도 사라진 상태다.You cannot answer with [0.0172, -0.0312, …]. The text and its origin are both gone.

함께 저장하면Stored together

“Goal 1, 10–11쪽, 이 문단입니다”“Goal 1, pp. 10–11, this paragraph”

좌표에 번호표를 달아 두고, 그 번호로 원문과 메타데이터를 꺼낸다. 전거가 따라붙는 것은 이 구조 덕분이다.Each coordinate carries an index number, and that number retrieves the text and its metadata. Provenance survives because of this arrangement.

② 구조Structure

세 개의 저장소, 하나의 번호Three Stores, One Number

FAISS 저장소는 사실 세 개가 나란히 있는 것이다. 아래 칸을 눌러 색인 번호를 골라 보라 — 같은 번호로 세 곳에서 각각 무엇이 나오는지 보인다.A FAISS store is really three stores side by side. Click a slot below to pick an index number — and watch what each of the three returns.

① index — 벡터 배열the vectors
store.index.reconstruct(i)
—
② id 테이블 — 번호표table — the label
store.index_to_docstore_id[i]
—
③ docstore — 원문·전거text and provenance
store.docstore.search(id)
—
workshop_code.md6-1
# 같은 번호 i 로 세 저장소를 나란히 조회한다query all three stores with the same index i
print("vector store :", store.index.reconstruct(i)[:4])
print("id table     :", i, "→", store.index_to_docstore_id[i])
print("text store   :", store.docstore.search(...).metadata["heading"])
벡터와 원문은 따로 산다. 색인 번호가 둘을 잇는다. 이 분리가 있어야 검색은 숫자로, 출력은 사람의 말로 할 수 있다.Vectors and text live apart. The index number joins them. That separation is what lets you search in numbers and answer in words.
청구기호와 서가Call numbers and shelves

도서관 목록에는 책 내용이 없다. 청구기호만 있다. 그 기호를 들고 서가에 가야 책이 나온다. 색인 번호가 청구기호이고, docstore가 서가다. 목록과 서가를 나누는 것이 도서관의 기본 설계인 것처럼, 벡터와 원문을 나누는 것이 벡터 DB의 기본 설계다.A library catalogue holds no books — only call numbers. You take the number to the shelves to get the book. The index number is the call number; the docstore is the shelf. Separating catalogue from shelves is the basic design of a library, and separating vectors from text is the basic design of a vector store.

③ 규모Scale

정직하게 — 우리 자료엔 색인이 필요 없다Honestly — We Do Not Need an Index

오늘 쓰는 IndexFlatL2의 Flat은 “납작하다”, 즉 아무 기교 없이 전부 비교한다는 뜻이다. 압축도, 근사도, 군집화도 하지 않는다. 질문이 오면 176개 전부와 거리를 재고 정렬한다 — STEP 8에서 우리가 손으로 할 일과 똑같다.The Flat in IndexFlatL2 means exactly that — flat, no tricks, compare against everything. No compression, no approximation, no clustering. A query is measured against all 176 and sorted — precisely what we will do by hand in STEP 8.

자료 규모Corpus size곱셈 횟수Multiplications 메모리Memory질의 1회Per query
176 · 우리 자료ours67,5840.3 MB0.01 ms
10,0003,840,00014.6 MB0.19 ms
100,00038,400,000146.5 MB3.8 ms
1,000,000384,000,0001464.8 MB34.54 ms
같은 노트북에서 실제로 재 본 값이다 · 전부 IndexFlatL2 전수 비교Measured on this same laptop · all with IndexFlatL2 brute-force search
우리 벡터 전체All our vectors
264 KB
176 × 384 × 4 바이트bytes
질의 1회One query
0.01 ms
사실상 즉시effectively instant
100만 개라면At one million
34.54 ms
1464.8 MB · 여기서부터 고민이 시작된다this is where it starts to matter
176개에서는 색인의 이득이 없다. 그래도 FAISS를 쓰는 이유는 속도가 아니라 구조 때문이다 — 벡터·번호표·원문을 한 묶음으로 관리해 주고, 자료가 커졌을 때 코드를 바꾸지 않고 근사 색인으로 갈아탈 수 있다.At 176 items an index buys you nothing. We still use FAISS — not for speed but for structure. It keeps vectors, labels and text together, and when the corpus grows you can swap in an approximate index without changing the code.
④ 정리In sum

여기가 A와 B의 경첩이다This Is the Hinge Between A and B

여기까지가 A · 자료 준비다. 한 번만 하면 된다. 이제부터는 B · 질문과 검색이고, 질문이 올 때마다 반복된다. 그 사이를 잇는 것이 방금 만든 이 저장소다.That completes A · preparing the material — done once. From here it is B · question and retrieval, repeated on every query. The store we just built is what joins the two.

검색은 숫자로 하고,
대답은 사람의 말로 한다.
Search happens in numbers.
The answer comes back in words.

다음 두 단계는 짧다. STEP 7에서 질문도 같은 인코더로 좌표가 되고, STEP 8에서 그 좌표와 176개 좌표 사이의 거리를 손으로 재 본다 — 방금 본 IndexFlatL2가 하는 일을 직접 해 보는 것이다.The next two steps are short. In STEP 7 the question becomes a coordinate through the same encoder; in STEP 8 we measure the distance from it to all 176 by hand — doing exactly what IndexFlatL2 just did for us.

다음은 STEP 7–8 — 질문을 좌표로 바꾸고, 거리를 잰다.Next: STEP 7–8 — turn the question into a coordinate, then measure.
DH2026 Workshop · Build a Working RAG in Half a Day
벡터는 Source/sdg_embeddings.jsonl의 실제 값 · 속도는 faiss.IndexFlatL2로 이 노트북에서 실측 (질의 5회 평균)Vectors are the real values in Source/sdg_embeddings.jsonl · Timings measured on this laptop with faiss.IndexFlatL2 (mean of 5 queries)
← 발표자료로 돌아가기Back to the slides · STEP 5 · STEP 7–8