STEP 5 임베딩과 벡터Embeddings and Vectors ← 발표자료Slides
DH2026 Workshop · 보조자료Supplement

문장 하나가 숫자 384개가 되기까지How One Sentence Becomes 384 Numbers

기계는 글자의 뜻을 모른다. 두 문장이 비슷한지 판단하려면 먼저 뜻을 잴 수 있는 것으로 바꿔야 한다. 그 변환이 임베딩이고, 결과물이 벡터다. 여기서는 실제 청크 하나가 숫자 384개가 되는 과정을 끝까지 따라간다.A machine does not know what words mean. To judge whether two sentences are alike, you must first turn them into something measurable. That conversion is embedding; the result is a vector. Here we follow one real chunk all the way to its 384 numbers.
① 이유Why

왜 숫자로 바꾸는가Why Turn Words Into Numbers

사람은 “빈곤”과 “가난”이 비슷하다는 걸 안다. 기계는 모른다. 기계에게 두 글자는 서로 다른 기호일 뿐이다.A person knows that “poverty” and “destitution” are close in meaning. A machine does not. To it they are simply two different symbols.

글자로 비교하면Comparing as text

같거나 다르거나, 둘뿐Only same or different

“working poverty”와 “extreme poverty”는 글자가 다르다. 얼마나 다른지는 셀 수 없다. 비슷함에 정도를 매길 방법이 없다.“working poverty” and “extreme poverty” are different strings. How different cannot be counted. Similarity has no degree.

숫자로 바꾸면Turned into numbers

거리를 잴 수 있다Distance becomes measurable

각 문장에 좌표를 주면 사이의 거리가 나온다. 가까우면 비슷하고 멀면 다르다 — 비슷함이 수치가 된다.Give each sentence a coordinate and you get a distance between them. Near means alike, far means unalike — similarity becomes a number.

검색이란 결국 거리를 재서 가까운 것을 고르는 일이다. 거리를 재려면 먼저 좌표가 있어야 한다. 그 좌표를 만드는 것이 임베딩이다.Retrieval is, in the end, measuring distance and taking the nearest. To measure you need coordinates. Making those coordinates is what embedding does.
② 정의Definition

벡터 — 그저 숫자를 나열한 좌표A Vector Is Just a List of Coordinates

지도 위 한 점은 숫자 둘로 적는다. 공간 속 한 점은 셋으로 적는다. 숫자를 더 많이 쓰면 더 많은 축을 가진 공간의 한 점이 된다. 그게 전부다.A point on a map takes two numbers. A point in space takes three. Use more numbers and you have a point in a space with more axes. That is all there is to it.

평면 위의 점A point on a plane
2
(x, y)
공간 속의 점A point in space
3
(x, y, z)
우리 인코더Our encoder
384
숫자 384개로 한 점one point in 384 numbers
서가의 자리를 정하는 일Assigning a place on the shelf

도서관은 책마다 청구기호를 붙여 자리를 정한다. 주제가 비슷하면 옆자리에 놓인다. 임베딩도 같은 일을 한다 — 다만 자리를 정하는 것이 사서가 아니라 학습된 모델이고, 서가가 384차원일 뿐이다.A library gives each book a call number and thereby a place; books on kindred subjects end up side by side. Embedding does the same — except the placement is decided by a trained model rather than a librarian, and the shelf has 384 dimensions.

③ 과정The process

어떻게 숫자가 되는가How It Becomes Numbers

실제 청크 하나(G01-S03)를 넣어 따라가 보자.Let us follow one real chunk — G01-S03 — through.

01
토큰으로 쪼갠다Split into tokens
203
→
02
토큰마다 숫자 384개384 numbers per token
203 × 384
→
03
평균 내어 한 줄로Average into one row
1 × 384
→
04
길이를 1로 맞춘다Scale to length 1
norm = 1

01 · 토큰으로 쪼갠다Split into tokens

모델은 단어가 아니라 토큰 단위로 읽는다. 자주 쓰는 말은 통째로, 드문 말은 조각으로 나뉜다. 금색이 쪼개진 조각, 청록은 문장의 시작과 끝을 알리는 특수 토큰이다.The model reads tokens, not words. Common words stay whole; rarer ones break into pieces. Gold marks a broken-off piece, teal the special tokens that mark where the text begins and ends.

03 · 평균 내어 한 줄로Average into one row

토큰마다 숫자 384개가 나오므로 203 × 384 표가 된다. 그런데 우리에게 필요한 건 문장 하나에 좌표 하나다. 그래서 세로로 평균을 내어 한 줄로 접는다.Each token yields 384 numbers, so you get a 203 × 384 table. But what we need is one coordinate for one passage. So we average down the columns and fold it into a single row.

mean pooling
# 203개 토큰의 같은 자리끼리 평균average the same position across all 203 tokens
vector = tokens.mean(axis=0)     # (203, 384) → (384,)
vector = vector / norm(vector)  # 길이를 1로scale to length 1
④ 결과The result

남는 것은 숫자 384개What Remains Is 384 Numbers

아래가 G01-S03의 실제 벡터다. 가공하지 않은 값 그대로다.Below is the actual vector for G01-S03 — the raw values, unedited.

이 숫자 하나하나가 무슨 뜻인지는 아무도 모른다. 137번째 숫자가 “빈곤스러움”을 뜻하는 것이 아니다. 의미는 개별 숫자가 아니라 384개가 이루는 위치에 있다.What any single number means, nobody knows. The 137th is not a measure of “poverty-ness”. The meaning lies not in any one number but in the position all 384 together describe.

음수는 왜 나오는가Why Are There Negative Numbers

절반 가까이가 음수다. 그런데 음수는 “없음”이 아니라 “반대쪽”이다. 위도 −37도가 “위도가 모자란다”는 뜻이 아니라 남반구를 가리키듯, 각 차원은 원점을 기준으로 양쪽으로 뻗은 축이고 음수는 그 반대편이다.Nearly half of them are negative. But a negative is not “less than nothing” — it is “the other side”. Latitude −37 does not mean a shortage of latitude; it means the southern hemisphere. Each dimension is an axis running both ways from the origin, and a negative value simply points the other way.

전체 값 중 음수Negative values
50.7%
거의 정확히 절반almost exactly half
값의 범위Value range
-0.2211 ~ 0.2104
0을 중심으로 대칭symmetric about zero
이 청크의 음수Negatives in this chunk
191
384개 중of 384
그래도 제곱합은Yet the sum of squares
1.0
제곱하면 부호가 사라진다squaring erases the sign
왜 절반인가Why half

길이를 1로 맞췄기 때문Because it was scaled to length 1

정규화하면 벡터는 384차원 구(球) 위의 한 점이 된다. 그 구에서 모든 좌표가 양수인 영역은 전체의 1/2384 — 사실상 0이다. 음수가 없는 쪽이 오히려 불가능하다.Normalised, the vector is a point on a 384-dimensional sphere. On that sphere the region where every coordinate is positive is 1/2384 of the whole — effectively nothing. Having no negatives is the impossible case.

왜 필요한가Why they are needed

반대 방향을 나타내려면To point the opposite way

음수가 있어야 두 벡터가 정반대를 가리킬 수 있다. 전부 양수라면 모든 벡터가 한 귀퉁이에 몰려서 서로 구별되지 않는다. “뜻이 정반대”가 “거리가 가장 멀다”로 나타나려면 음수가 있어야 한다.Negatives are what let two vectors point in opposite directions. If everything were positive, every vector would huddle in one corner and none could be told apart. “Opposite in meaning” can only show up as “farthest away” if negatives exist.

좌표 하나만 보면 아무것도 아니다One coordinate alone says nothing

위도 37도라는 숫자만으로는 어디인지 알 수 없다. 경도와 함께 놓여야 서울이 된다. 384개의 숫자도 마찬가지다 — 함께 있을 때만 자리를 가리킨다.Latitude 37 on its own tells you nothing; only with a longitude does it become Seoul. The 384 numbers are the same — they name a place only together.

⑤ 확인Verification

정말 뜻이 가까우면 가까이 놓이는가Do Close Meanings Really Sit Close

말로만 하면 믿기 어렵다. 실제 176개 벡터로 확인해 보자. 청크를 하나 고르면, 그 벡터에서 가장 가까운 셋과 가장 먼 하나를 보여준다.Claims are cheap. Let us check against all 176 real vectors. Pick a chunk and see its three nearest neighbours and its single farthest one.

같은 Goal 평균 거리Mean distance, same Goal
0.9332
가깝다closer
다른 Goal 평균 거리Mean distance, other Goals
1.2022
멀다farther
최근접 이웃이 같은 GoalNearest neighbour shares the Goal
83%
176개 중of 176
아무도 “이 청크는 Goal 1에 속한다”고 알려 주지 않았다. 그런데도 가장 가까운 이웃이 같은 Goal인 경우가 83%다. 뜻이 가까운 것끼리 실제로 모여 있다.Nobody told the model which Goal any chunk belonged to. Even so, the nearest neighbour shares the Goal 83% of the time. Things close in meaning really do cluster.
⑥ 차원Dimensions

왜 하필 384개나 되는가Why as Many as 384

둘이나 셋이면 그림으로 그릴 수 있어 편할 텐데, 왜 384개일까. 줄여 보면 답이 나온다. 아래는 같은 벡터를 몇 차원까지만 남겼을 때 “가장 가까운 이웃이 같은 Goal인 비율”이다.Two or three would be drawable and convenient — so why 384? Reduce them and the answer appears. Below is the share of chunks whose nearest neighbour shares their Goal, when only the first so many dimensions are kept.

2차원으로 누르면 19%까지 무너진다. 30차원쯤 되어야 384차원과 같아진다. 뜻을 담으려면 그만큼의 축이 필요하다.Squeezed to two dimensions it collapses to 19%. Only around thirty does it match the full 384. Holding meaning takes that many axes.

그림으로 그리면 이렇게 된다Drawn Out, It Looks Like This

아래는 176개 청크를 3차원에 눌러 담은 것이다. 색은 Goal이고, 끌어서 돌려 볼 수 있다. 2차원(정확도 19%)보다는 낫지만 여전히 37%에 그친다.Here are all 176 chunks pressed into three dimensions. Colour is the Goal, and you can drag to rotate. Better than two dimensions (19%), but still only 37%.

100%
⑦ 정리In sum

다음 단계로On to the Next Step

임베딩은 뜻을 좌표로 옮기는 일이다.
옮기고 나면, 비슷함은 거리가 된다.
Embedding moves meaning into coordinates.
Once moved, likeness becomes distance.

이제 청크 176개가 각각 384개의 숫자를 갖게 되었다. STEP 6에서는 이 좌표들을 찾기 쉽게 정리해 둔다 — 그것이 벡터 데이터베이스다. STEP 7에서는 질문도 같은 방법으로 좌표가 되고, STEP 8에서 둘 사이의 거리를 손으로 재 본다.Each of the 176 chunks now carries 384 numbers. STEP 6 files those coordinates so they can be found — that is the vector store. In STEP 7 the question becomes a coordinate the same way, and in STEP 8 we measure the distance between them by hand.

다음은 STEP 6 — 176개의 좌표를 색인에 담는다.Next: STEP 6 — filing 176 coordinates into an index.
DH2026 Workshop · Build a Working RAG in Half a Day
벡터는 Source/sdg_embeddings.jsonl의 실제 값입니다 · 토큰은 all-MiniLM-L6-v2의 WordPiece 실측 · 차원 축소는 주성분분석(PCA)Vectors are the real values in Source/sdg_embeddings.jsonl · Tokens use the actual all-MiniLM-L6-v2 WordPiece vocabulary · Dimensionality reduction by PCA
← 발표자료로 돌아가기Back to the slides · STEP 4 · STEP 6