거리 메트릭 및 인덱싱 기초
벡터 유사도를 정의하는 거리 메트릭과 대규모 벡터 검색을 빠르게 만드는 근사 최근접 이웃 인덱스를 배웁니다.
거리 메트릭 및 인덱싱 기초은(는) CoddyKit의 무료 Vector Databases: Pinecone, Weaviate & pgvector 강의입니다. 이것은 4개 중 4번째 강의입니다. 아래에서 전체 강의를 무료로 읽을 수 있으며, 내장 코드 에디터와 24/7 AI 튜터와 함께 브라우저에서 직접 실습할 수 있습니다. 이 강의는 Vector Databases: Pinecone, Weaviate & pgvector 학습 경로의 일부이며, 진행 상황이 웹과 CoddyKit 앱에 동기화됩니다. Vector Databases: Pinecone, Weaviate & pgvector 강의에는 총 4개의 강의가 포함되어 있습니다.
이 강의의 일부는 아직 번역되지 않았으며 영어로 표시됩니다.
Measuring Closeness
A vector DB finds vectors close to your query, but 'close' is defined by a distance metric — and the metric you pick shapes what counts as similar.
Euclidean Distance
Euclidean (L2) distance is the straight-line distance between two points: smaller means closer. Run the example to see it.
import math
def l2(a, b):
return math.sqrt(sum((x-y)**2 for x, y in zip(a, b)))
print(round(l2([0,0],[3,4]), 1))Cosine Similarity
Cosine similarity measures the angle between vectors, ignoring magnitude. It's the go-to for text embeddings, since direction carries the meaning.
import math
def cosine(a, b):
dot = sum(x*y for x, y in zip(a, b))
na = math.sqrt(sum(x*x for x in a))
nb = math.sqrt(sum(y*y for y in b))
return dot / (na*nb)
print(round(cosine([1,0],[1,1]), 3))Dot Product
The dot product blends angle and magnitude. With normalized vectors it equals cosine similarity — which is why many systems normalize, then use dot product for speed.
Choosing a Metric
Match the metric to what your model was trained for: text usually cosine, normalized vectors dot product, some image or geo data Euclidean. A mismatch silently hurts results.
The Brute-Force Problem
Brute force — comparing the query to every stored vector — is exact but slow: millions of vectors mean millions of comparisons per query. It doesn't scale.
Approximate Nearest Neighbor
ANN indexes trade a sliver of accuracy for massive speed by cleverly skipping most candidates. Recall stays high while latency drops by orders of magnitude.
HNSW Indexes
HNSW builds a layered graph you navigate coarse to fine for excellent recall and speed — the default in many vector DBs, tunable via ef and M.
IVF Indexes
IVF clusters vectors into buckets and only searches the ones nearest your query. Fewer probes mean faster search, at a small accuracy cost.
The Recall-Speed Trade-off
Every ANN index exposes knobs that trade recall for speed. Searching more candidates raises both recall and latency. Tune to your accuracy target, then push speed.
Putting It Together
Putting it together: pick the right distance metric for your embeddings, then use an ANN index (HNSW or IVF) to query fast at scale, tuning the recall-speed knobs.
Quick Check
Test your understanding of metrics and indexes.
Recap
Recap: the core distance metrics (Euclidean, cosine, dot product) — text usually cosine — plus ANN indexes like HNSW and IVF that trade a little recall for big speed.
자주 묻는 질문
“거리 메트릭 및 인덱싱 기초” 강의는 무료인가요?
네 — “거리 메트릭 및 인덱싱 기초” 전체 내용을 이 웹사이트에서 무료로 읽을 수 있습니다. 인터랙티브하게 실습하려면(내장 코드 에디터와 24/7 AI 튜터), CoddyKit PRO로 업그레이드하면 Vector Databases: Pinecone, Weaviate & pgvector 강의 전체를 잠금 해제할 수 있습니다. Vector Databases: Pinecone, Weaviate & pgvector 강의에는 총 4개의 강의가 포함되어 있습니다.
“거리 메트릭 및 인덱싱 기초”에서 뭘 배우나요?
벡터 유사도를 정의하는 거리 메트릭과 대규모 벡터 검색을 빠르게 만드는 근사 최근접 이웃 인덱스를 배웁니다. 브라우저에서 직접 실행하는 실습 코드로 Vector Databases: Pinecone, Weaviate & pgvector을(를) 배우며, 24/7 AI 튜터가 강의를 진행하면서 질문에 답변해줍니다.
Vector Databases: Pinecone, Weaviate & pgvector을(를) 시작하는 데 경험이 필요한가요?
사전 경험은 필요하지 않습니다. CoddyKit의 Vector Databases: Pinecone, Weaviate & pgvector은(는) 초급자부터 고급 학습자까지를 위해 구성되어 있으므로, 여기서 시작하거나 처음부터 시작할 수 있으며 자신의 속도대로 진행할 수 있습니다. 이것은 4개 중 4번째 강의입니다.
“거리 메트릭 및 인덱싱 기초” 강의는 얼마나 걸리나요?
대부분의 CoddyKit 강의는 약 5~10분이 소요됩니다. 각 강의는 간결하고 인터랙티브하여 꾸준한 진행이 가능하며, 웹과 앱에서 중단한 부분부터 바로 시작할 수 있습니다.
이 Vector Databases: Pinecone, Weaviate & pgvector 강의에서 코드를 작성하고 실행할 수 있나요?
네. 모든 Vector Databases: Pinecone, Weaviate & pgvector 강의에는 내장 코드 에디터가 포함되어 있으므로, 브라우저에서 바로 실제 코드를 작성하고 실행한 후 즉시 AI 피드백을 받을 수 있습니다 — 로컬 설정이 필요 없습니다.
이 강의의 모든 강의
- 벡터 데이터베이스란 무엇인가요
- 임베딩: 핵심 개념
- 유사도 검색 이해하기
- 거리 메트릭 및 인덱싱 기초