검색은 벡터로 한다. 질문 벡터와 가장 가까운 좌표를 찾는 것이다. 그런데 찾고 나면 숫자 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.
답으로 [0.0172, -0.0312, …]를 내놓을 수는 없다. 원문도 출처도 사라진 상태다.You cannot answer with [0.0172, -0.0312, …]. The text and its origin are both gone.
좌표에 번호표를 달아 두고, 그 번호로 원문과 메타데이터를 꺼낸다. 전거가 따라붙는 것은 이 구조 덕분이다.Each coordinate carries an index number, and that number retrieves the text and its metadata. Provenance survives because of this arrangement.
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.
# 같은 번호 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"])
도서관 목록에는 책 내용이 없다. 청구기호만 있다. 그 기호를 들고 서가에 가야 책이 나온다. 색인 번호가 청구기호이고, 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.
오늘 쓰는 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 · 우리 자료ours | 67,584 | 0.3 MB | 0.01 ms |
| 10,000 | 3,840,000 | 14.6 MB | 0.19 ms |
| 100,000 | 38,400,000 | 146.5 MB | 3.8 ms |
| 1,000,000 | 384,000,000 | 1464.8 MB | 34.54 ms |
IndexFlatL2 전수 비교Measured on this same laptop · all with IndexFlatL2 brute-force search여기까지가 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.
다음 두 단계는 짧다. 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.
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)